Hi all,

Le 19 janv. 09 à 10:38, Akim Demaille a écrit :


Le 14 janv. 09 à 11:16, Akim Demaille a écrit :

Le 10 janv. 09 à 22:25, Ralf Wildenhues a écrit :

So what do you recommend to store persistent information? A function
that returns some static variable (sort of a singleton)?  Or an
additional argument everywhere (gee...).  Maybe I can do it using
advices to hand over the verbosity flags, but that does sound like a
nuisance for the API.

A lt_dlget* and a lt_dlset* function, if the user needs to be able to
provide a type.  Don't provide the user with a direct pointer if you
don't have to.

Note that I didn't say global variables are bad, although they are
obviously bad, too, for two reasons: slow access, and, well, globality.
Assume that you write a library that uses ltdl internally, and I use
your library in a program that also links against a completely different library that also uses ltdl. You'll most likely not want interference. Well, in your case I'm not so sure. But if not, then adding a module
loading advisor to change verbosity would seem appropriate.

I thought about this, and I think that the best option would be to have a callback function with a signature more or less like:

void log(void* user_data, level_type level, const char* format, ...);

Here is my proposal.

There are a few issues on which I'd be happy to have feedback:

- I discovered slist only afterwards, and I did not convert
 my code to use it.  I believe it would bring nothing useful,
 because we really need no specific features here.  Using
 slist would probably require more auxiliary structures and
 routines.  But I can understand the advantages of reusing
 slist.

- This interface is not convenient for messages that are forged
 in several pieces (first "%s", and then "%s\n").  syslog does
 not support them, so maybe I should just always require the log
 message to be a \n-ending line?  It is annoying for
 lt_dlloader_dump.  Maybe in this case I should forge a dynamic
 string first, and log it afterwards, instead of logging several
 lines.

Now every call to the logging functions is given a complete line. I still provide the \n, but maybe I should not. No strong opinion here.

- I have not decided what LEVELs should be.  We could use
 syslog's values.  No strong opinion here.  Or a bitfield?

- I have to address stdarg portability, doc, tests, NEWS etc.

<0001-Provide-support-for-user-logging-functions.txt>

Here is an updated version.

From 3e75be1a759d060da825a4d828c895234baa2a11 Mon Sep 17 00:00:00 2001
From: Akim Demaille <demai...@gostai.com>
Date: Fri, 9 Jan 2009 14:38:13 +0100
Subject: [PATCH] Provide support for user logging functions.

        * libltdl/libltdl/lt__debug.h, libltdl/lt__debug.c: New.
        * libltdl/Makefile.inc, libtoolize.m4sh: Compile/ship/install them.
        * libltdl/libltdl/lt__private.h: Include lt__debug.h.
        (lt__log_list): New.
        * libltdl/libltdl/lt_system.h: Include stdarg.h.
        * libltdl/ltdl.h (LT_LOG, LT_LOG0, LT_LOG1, LT_LOG2, LT_LOG3)
        (LT_NONNULL, LT_NAME): New.
        * libltdl/ltdl.c, libltdl/lt_dlloader.c: Use them.
        * libltdl/lt_dlloader.c (loader_length_callback)
        (loader_strcat_callback): New.
        (lt_dlloader_dump): Rename as...
        (lt_dllog_loaders): this.
        (lt_dlloader_dump): Issue full lines.
        * tests/libtoolize.at: Adjust expected libtoolize output.
---
 libltdl/Makefile.inc          |    4 +-
 libltdl/libltdl/lt__debug.h   |   65 +++++++++++++++++++++++++
 libltdl/libltdl/lt__private.h |   13 +++++-
 libltdl/libltdl/lt_dlloader.h |    4 +-
 libltdl/libltdl/lt_system.h   |    3 +-
 libltdl/lt__debug.c           |  105 +++++++++++++++++++++++++++++++++++++++++
 libltdl/lt_dlloader.c         |   42 +++++++++++------
 libltdl/ltdl.c                |   62 +++++++++++++++---------
 libltdl/ltdl.h                |   23 ++++++++-
 libtoolize.m4sh               |    5 +-
 tests/libtoolize.at           |   12 ++++-
 11 files changed, 288 insertions(+), 50 deletions(-)
 create mode 100644 libltdl/libltdl/lt__debug.h
 create mode 100644 libltdl/lt__debug.c

diff --git a/libltdl/Makefile.inc b/libltdl/Makefile.inc
index 0cd982d..7ace644 100644
--- a/libltdl/Makefile.inc
+++ b/libltdl/Makefile.inc
@@ -1,6 +1,6 @@
 ## Makefile.inc -- includable Makefile.am snippet
 ##
-##   Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+##   Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
 ##   Written by Gary V. Vaughan, 2003
 ##
 ##   NOTE: The canonical source of this file is maintained with the
@@ -54,6 +54,7 @@ noinst_LTLIBRARIES     += libltdl/libltdlc.la
 endif
 
 libltdl_libltdl_la_SOURCES = libltdl/libltdl/lt__alloc.h \
+                         libltdl/libltdl/lt__debug.h \
                          libltdl/libltdl/lt__dirent.h \
                          libltdl/libltdl/lt__glibc.h \
                          libltdl/libltdl/lt__private.h \
@@ -64,6 +65,7 @@ libltdl_libltdl_la_SOURCES = libltdl/libltdl/lt__alloc.h \
                          libltdl/libltdl/slist.h \
                          libltdl/loaders/preopen.c \
                          libltdl/lt__alloc.c \
+                         libltdl/lt__debug.c \
                          libltdl/lt_dlloader.c \
                          libltdl/lt_error.c \
                          libltdl/ltdl.c \
diff --git a/libltdl/libltdl/lt__debug.h b/libltdl/libltdl/lt__debug.h
new file mode 100644
index 0000000..267141b
--- /dev/null
+++ b/libltdl/libltdl/lt__debug.h
@@ -0,0 +1,65 @@
+/* lt__debug.h -- debugging and logging
+
+   Copyright (C) 2009 Free Software Foundation, Inc.
+   Written by Akim Demaille, 2009
+
+   NOTE: The canonical source of this file is maintained with the
+   GNU Libtool package.  Report bugs to bug-libt...@gnu.org.
+
+GNU Libltdl is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU Libtool, you may include this file under the
+same distribution terms that you use for the rest of that program.
+
+GNU Libltdl is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
+or obtained by writing to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#if !defined(LT__DEBUG_H)
+#define LT__DEBUG_H 1
+
+#include "lt_system.h"
+
+LT_BEGIN_C_DECLS
+
+/* Register a message to log functions.  */
+int lt_dllog (unsigned level, const char* ormat, ...);
+
+/* --- DEBUGGING --- */
+
+#if defined LT_DEBUG_LOADERS
+# define LT_LOG(Args)                           \
+  lt_dllog Args;
+#else
+# define LT_LOG(Args)
+#endif
+
+#define LT_LOG0(Level, Format)                  \
+  LT_LOG((Level, Format))
+#define LT_LOG1(Level, Format, Arg1)            \
+  LT_LOG((Level, Format, Arg1))
+#define LT_LOG2(Level, Format, Arg1, Arg2)      \
+  LT_LOG((Level, Format, Arg1, Arg2))
+#define LT_LOG3(Level, Format, Arg1, Arg2, Arg3)        \
+  LT_LOG((Level, Format, Arg1, Arg2, Arg3))
+
+#define LT_NONNULL(Arg)                         \
+  ((Arg) ? (Arg) : "(null)")
+#define LT_NAME(Arg)                            \
+  ((Arg) && (Arg)->name ? (Arg)->name : "(null)")
+LT_END_C_DECLS
+
+#endif /*!defined(LT__DEBUG_H)*/
diff --git a/libltdl/libltdl/lt__private.h b/libltdl/libltdl/lt__private.h
index 7d0894f..32d376f 100644
--- a/libltdl/libltdl/lt__private.h
+++ b/libltdl/libltdl/lt__private.h
@@ -1,6 +1,6 @@
 /* lt__private.h -- internal apis for libltdl
 
-   Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 
Inc.
    Written by Gary V. Vaughan, 2004
 
    NOTE: The canonical source of this file is maintained with the
@@ -49,6 +49,7 @@ or obtained by writing to the Free Software Foundation, Inc.,
 
 /* Import internal interfaces...  */
 #include "lt__alloc.h"
+#include "lt__debug.h"
 #include "lt__dirent.h"
 #include "lt__strl.h"
 #include "lt__glibc.h"
@@ -129,6 +130,16 @@ struct lt__advise {
   unsigned int try_preload_only:1;/* only preloaded modules will be tried. */
 };
 
+/* --- DEBUGGING --- */
+
+/* A linked list of pairs of a log function and its associated data. */
+typedef struct lt__log_list {
+  lt_dllog_function   *function;
+  void                *data;
+  struct lt__log_list *next;
+} lt__log_list;
+
+
 /* --- ERROR HANDLING --- */
 
 /* Extract the diagnostic strings from the error table macro in the same
diff --git a/libltdl/libltdl/lt_dlloader.h b/libltdl/libltdl/lt_dlloader.h
index ae131fa..fb3956c 100644
--- a/libltdl/libltdl/lt_dlloader.h
+++ b/libltdl/libltdl/lt_dlloader.h
@@ -1,6 +1,6 @@
 /* lt_dlloader.h -- dynamic library loader interface
 
-   Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
    Written by Gary V. Vaughan, 2004
 
    NOTE: The canonical source of this file is maintained with the
@@ -82,7 +82,7 @@ LT_SCOPE const lt_dlvtable *lt_dlloader_get   (lt_dlloader 
loader);
 typedef  const lt_dlvtable *lt_get_vtable      (lt_user_data data);
 
 #ifdef LT_DEBUG_LOADERS
-LT_SCOPE void          lt_dlloader_dump        (void);
+LT_SCOPE void           lt_dlloader_log         (void);
 #endif
 
 LT_END_C_DECLS
diff --git a/libltdl/libltdl/lt_system.h b/libltdl/libltdl/lt_system.h
index dab2ab6..c383702 100644
--- a/libltdl/libltdl/lt_system.h
+++ b/libltdl/libltdl/lt_system.h
@@ -1,6 +1,6 @@
 /* lt_system.h -- system portability abstraction layer
 
-   Copyright (C) 2004, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc.
    Written by Gary V. Vaughan, 2004
 
    NOTE: The canonical source of this file is maintained with the
@@ -31,6 +31,7 @@ or obtained by writing to the Free Software Foundation, Inc.,
 #if !defined(LT_SYSTEM_H)
 #define LT_SYSTEM_H 1
 
+#include <stdarg.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <sys/types.h>
diff --git a/libltdl/lt__debug.c b/libltdl/lt__debug.c
new file mode 100644
index 0000000..cf1ee0f
--- /dev/null
+++ b/libltdl/lt__debug.c
@@ -0,0 +1,105 @@
+/* lt__debug.c -- debugging and logging
+   Copyright (C) 2009 Free Software Foundation, Inc.
+   Written by Akim Demaille, 2009
+
+   NOTE: The canonical source of this file is maintained with the
+   GNU Libtool package.  Report bugs to bug-libt...@gnu.org.
+
+GNU Libltdl is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU Libtool, you may include this file under the
+same distribution terms that you use for the rest of that program.
+
+GNU Libltdl is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
+or obtained by writing to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include "lt__private.h"
+
+static lt__log_list* lt_logs = 0;
+
+static
+lt__log_list*
+lt__log_new (lt_dllog_function   *function,
+             void                *data,
+             lt__log_list        *next)
+{
+  lt__log_list* res = MALLOC (lt__log_list, 1);
+  res->function = function;
+  res->data = data;
+  res->next = next;
+  return res;
+}
+
+static
+void
+lt__log_delete (lt__log_list* l)
+{
+  assert (!l->next);
+  FREE (l);
+}
+
+
+int
+lt_dladd_log_function (lt_dllog_function *fun, void *data)
+{
+  lt_logs = lt__log_new (fun, data, lt_logs);
+  return 0;
+}
+
+/* Look in and remove from *LIST.  */
+static
+int
+lt__dlremove_log_function (lt__log_list** list,
+                           lt_dllog_function *fun)
+{
+  if (!list || !*list)
+    return 1;
+  else if ((*list)->function == fun)
+    {
+      lt__log_list* found = *list;
+      *list = found->next;
+      found->next = 0;
+      lt__log_delete (found);
+      return 0;
+    }
+  else
+    return lt__dlremove_log_function (&(*list)->next, fun);
+}
+
+int
+lt_dlremove_log_function (lt_dllog_function *fun)
+{
+  return lt__dlremove_log_function (&lt_logs, fun);
+}
+
+int
+lt_dllog (unsigned level, const char* format, ...)
+{
+  unsigned errors = 0;
+  if (lt_logs)
+    {
+      va_list args;
+      va_start(args, format);
+      {
+        lt__log_list *l;
+        for (l = lt_logs; l; l = l->next)
+          errors += (*l->function) (l->data, level, format, args);
+      }
+      va_end(args);
+    }
+  return errors;
+}
diff --git a/libltdl/lt_dlloader.c b/libltdl/lt_dlloader.c
index 4e66a6c..896b9e8 100644
--- a/libltdl/lt_dlloader.c
+++ b/libltdl/lt_dlloader.c
@@ -1,6 +1,6 @@
 /* lt_dlloader.c -- dynamic library loader interface
 
-   Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
    Written by Gary V. Vaughan, 2004
 
    NOTE: The canonical source of this file is maintained with the
@@ -99,29 +99,41 @@ lt_dlloader_add (const lt_dlvtable *vtable)
 
 #ifdef LT_DEBUG_LOADERS
 static void *
-loader_dump_callback (SList *item, void *userdata)
+loader_length_callback (SList *item, void *userdata)
 {
   const lt_dlvtable *vtable = (const lt_dlvtable *) item->userdata;
-  fprintf (stderr, ", %s", (vtable && vtable->name) ? vtable->name : "(null)");
+  size_t *len = (size_t *) userdata;
+  // We use ' ' as separator.
+  *len += 1 + LT_STRLEN (LT_NAME (vtable));
+  return 0;
+}
+
+static void *
+loader_strcat_callback (SList *item, void *userdata)
+{
+  const lt_dlvtable *vtable = (const lt_dlvtable *) item->userdata;
+  char *cp = (char *) userdata;
+  strcat (cp, " ");
+  strcat (cp, LT_NAME (vtable));
   return 0;
 }
 
 void
-lt_dlloader_dump (void)
+lt_dlloader_log (void)
 {
-  fprintf (stderr, "loaders: ");
-  if (!loaders)
-    {
-      fprintf (stderr, "(empty)");
-    }
-  else
+  char *cp = 0;
+  const char *loader_names = " (empty)";
+  if (loaders)
     {
-      const lt_dlvtable *head = (const lt_dlvtable *) loaders->userdata;
-      fprintf (stderr, "%s", (head && head->name) ? head->name : "(null)");
-      if (slist_tail (loaders))
-       slist_foreach (slist_tail (loaders), loader_dump_callback, NULL);
+      size_t len = 0;
+      slist_foreach (loaders, loader_length_callback, &len);
+      cp = MALLOC (char, len + 1);
+      cp[0] = 0;
+      slist_foreach (loaders, loader_strcat_callback, cp);
+      loader_names = cp;
     }
-  fprintf (stderr, "\n");
+  LT_LOG1 (1, "loaders:%s\n", loader_names);
+  FREE(cp);
 }
 #endif
 
diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c
index 4da9676..15a94dd 100644
--- a/libltdl/ltdl.c
+++ b/libltdl/ltdl.c
@@ -151,6 +151,7 @@ static      char           *user_search_path= 0;
 static lt_dlhandle     handles = 0;
 static int             initialized     = 0;
 
+
 /* Our memory failure callback sets the error message to be passed back
    up to the client, so we must be careful to return from mallocation
    callers if allocation fails (as this callback returns!!).  */
@@ -245,7 +246,7 @@ lt_dlinit (void)
     }
 
 #ifdef LT_DEBUG_LOADERS
-  lt_dlloader_dump();
+  lt_dlloader_log ();
 #endif
 
   return errors;
@@ -362,11 +363,9 @@ tryall_dlopen (lt_dlhandle *phandle, const char *filename,
   const char * saved_error     = 0;
   int          errors          = 0;
 
-#ifdef LT_DEBUG_LOADERS
-  fprintf (stderr, "tryall_dlopen (%s, %s)\n",
-          filename ? filename : "(null)",
-          vtable ? vtable->name : "(ALL)");
-#endif
+  LT_LOG2 (1, "tryall_dlopen (%s, %s)\n",
+           LT_NONNULL (filename),
+           vtable ? vtable->name : "(ALL)");
 
   LT__GETERROR (saved_error);
 
@@ -426,17 +425,13 @@ tryall_dlopen (lt_dlhandle *phandle, const char *filename,
        else
          loader_vtable = lt_dlloader_get (loader);
 
-#ifdef LT_DEBUG_LOADERS
-       fprintf (stderr, "Calling %s->module_open (%s)\n",
-                (loader_vtable && loader_vtable->name) ? loader_vtable->name : 
"(null)",
-                filename ? filename : "(null)");
-#endif
-       handle->module = (*loader_vtable->module_open) 
(loader_vtable->dlloader_data,
-                                                       filename, advise);
-#ifdef LT_DEBUG_LOADERS
-       fprintf (stderr, "  Result: %s\n",
-                handle->module ? "Success" : "Failed");
-#endif
+       LT_LOG2 (2, "Calling %s->module_open (%s)\n",
+                 LT_NAME(loader_vtable), LT_NONNULL (filename));
+        handle->module =
+          (*loader_vtable->module_open) (loader_vtable->dlloader_data,
+                                         filename, advise);
+       LT_LOG1 (2, "  Result: %s\n",
+                 handle->module ? "Success" : "Failed");
 
        if (handle->module != 0)
          {
@@ -756,7 +751,8 @@ find_file (const char *search_path, const char *base_name, 
char **pdir)
   FILE *file = 0;
 
   foreach_dirinpath (search_path, base_name, find_file_callback, pdir, &file);
-
+  LT_LOG3 (4, "find_find (\"%s\" in \"%s\") = %s\n",
+           base_name, search_path, *pdir ? *pdir : "not found");
   return file;
 }
 
@@ -800,6 +796,7 @@ static int
 load_deplibs (lt_dlhandle handle, char * LT__UNUSED deplibs)
 {
   handle->depcount = 0;
+  LT_LOG1 (1, "load_deplibs(%s): not implemented\n", LT_NONNULL (deplibs));
   return 0;
 }
 
@@ -813,6 +810,8 @@ load_deplibs (lt_dlhandle handle, char *deplibs)
   char **names = 0;
   int  errors = 0;
 
+  LT_LOG1 (1, "load_deplibs(%s)\n", LT_NONNULL (deplibs));
+
   handle->depcount = 0;
 
   if (!deplibs)
@@ -909,6 +908,7 @@ load_deplibs (lt_dlhandle handle, char *deplibs)
              if (!name)
                goto cleanup_names;
 
+              LT_LOG1 (2, "found dependency %s\n", name);
              names[depcount++] = name;
              *end = save;
            }
@@ -1023,6 +1023,10 @@ parse_dotla_file(FILE *file, char **dlname, char 
**libdir, char **deplibs,
   size_t       line_len = LT_FILENAME_MAX;
   char *       line = MALLOC (char, line_len);
 
+#define LT_LOG_FIELD(Field)                   \
+  LT_LOG1 (3, "*.la: " #Field ": %s\n", LT_NONNULL (*Field))
+
+
   if (!line)
     {
       LT__SETERROR (FILE_NOT_FOUND);
@@ -1066,6 +1070,7 @@ parse_dotla_file(FILE *file, char **dlname, char 
**libdir, char **deplibs,
       if (strncmp (line, STR_DLNAME, sizeof (STR_DLNAME) - 1) == 0)
        {
          errors += trim (dlname, &line[sizeof (STR_DLNAME) - 1]);
+          LT_LOG_FIELD (dlname);
        }
 
 #undef  STR_OLD_LIBRARY
@@ -1074,12 +1079,14 @@ parse_dotla_file(FILE *file, char **dlname, char 
**libdir, char **deplibs,
            sizeof (STR_OLD_LIBRARY) - 1) == 0)
        {
          errors += trim (old_name, &line[sizeof (STR_OLD_LIBRARY) - 1]);
+          LT_LOG_FIELD (old_name);
        }
 #undef  STR_LIBDIR
 #define STR_LIBDIR     "libdir="
       else if (strncmp (line, STR_LIBDIR, sizeof (STR_LIBDIR) - 1) == 0)
        {
          errors += trim (libdir, &line[sizeof(STR_LIBDIR) - 1]);
+          LT_LOG_FIELD (libdir);
        }
 
 #undef  STR_DL_DEPLIBS
@@ -1088,14 +1095,17 @@ parse_dotla_file(FILE *file, char **dlname, char 
**libdir, char **deplibs,
            sizeof (STR_DL_DEPLIBS) - 1) == 0)
        {
          errors += trim (deplibs, &line[sizeof (STR_DL_DEPLIBS) - 1]);
+          LT_LOG_FIELD (deplibs);
        }
       else if (streq (line, "installed=yes\n"))
        {
          *installed = 1;
+          LT_LOG1 (3, "*.la: installed: %d\n", *installed);
        }
       else if (streq (line, "installed=no\n"))
        {
          *installed = 0;
+          LT_LOG1 (3, "*.la: installed: %d\n", *installed);
        }
 
 #undef  STR_LIBRARY_NAMES
@@ -1117,11 +1127,14 @@ parse_dotla_file(FILE *file, char **dlname, char 
**libdir, char **deplibs,
                }
              MEMREASSIGN (*dlname, last_libname);
            }
+          LT_LOG_FIELD (dlname);
        }
 
       if (errors)
        break;
     }
+#undef LT_LOG_FIELD
+
 cleanup:
   FREE (line);
   return errors;
@@ -1146,11 +1159,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, 
const char *ext,
   assert (phandle);
   assert (*phandle == 0);
 
-#ifdef LT_DEBUG_LOADERS
-  fprintf (stderr, "try_dlopen (%s, %s)\n",
-          filename ? filename : "(null)",
-          ext ? ext : "(null)");
-#endif
+  LT_LOG2 (1, "try_dlopen (%s, %s)\n", LT_NONNULL (filename), LT_NONNULL 
(ext));
 
   LT__GETERROR (saved_error);
 
@@ -1360,9 +1369,13 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, 
const char *ext,
        }
 
       /* read the .la file */
+      LT_LOG1 (2, "Parsing *.la file: %s\n", attempt);
       if (parse_dotla_file(file, &dlname, &libdir, &deplibs,
            &old_name, &installed) != 0)
-       ++errors;
+        {
+          LT_LOG1 (2, "Parsing *.la file failed: %s\n", attempt);
+          ++errors;
+        }
 
       fclose (file);
 
@@ -1601,6 +1614,7 @@ lt_dlopenext (const char *filename)
   lt_dlhandle  handle  = 0;
   lt_dladvise  advise;
 
+  LT_LOG1 (1, "lt_dlopenext (%s)\n", LT_NONNULL (filename));
   if (!lt_dladvise_init (&advise) && !lt_dladvise_ext (&advise))
     handle = lt_dlopenadvise (filename, advise);
 
diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h
index 8b516ad..0f2bf40 100644
--- a/libltdl/ltdl.h
+++ b/libltdl/ltdl.h
@@ -1,7 +1,7 @@
 /* ltdl.h -- generic dlopen functions
 
    Copyright (C) 1998-2000, 2004, 2005,
-                 2007, 2008 Free Software Foundation, Inc.
+                 2007, 2008, 2009 Free Software Foundation, Inc.
    Written by Thomas Tanner, 1998
 
    NOTE: The canonical source of this file is maintained with the
@@ -44,6 +44,23 @@ LT_BEGIN_C_DECLS
 #define LT_STRLEN(s)   (((s) && (s)[0]) ? strlen (s) : 0)
 
 
+/* --- DEBUGGING --- */
+
+/* A log function. DATA is opaque user data registered with the log
+   function.  LEVEL defines the verbosity of the message (the higher,
+   the least important).  FORMAT and ARGS are printf-like arguments.
+   Returns 0 iff no error.
+   */
+typedef int (lt_dllog_function) (void* data, unsigned level,
+                                 const char* format, va_list args);
+
+/* Register a log function and its associated data.
+   Return 0 iff no error. */
+LT_SCOPE int lt_dladd_log_function (lt_dllog_function *fun, void *data);
+/* Unregister a log function.  Its associated data is unregistered too.
+   Return 0 iff no error. */
+LT_SCOPE int lt_dlremove_log_function (lt_dllog_function *fun);
+
 /* --- DYNAMIC MODULE LOADING API --- */
 
 
@@ -57,7 +74,7 @@ LT_SCOPE int      lt_dlexit           (void);
 LT_SCOPE int       lt_dladdsearchdir    (const char *search_dir);
 LT_SCOPE int       lt_dlinsertsearchdir (const char *before,
                                                  const char *search_dir);
-LT_SCOPE int       lt_dlsetsearchpath   (const char *search_path);
+LT_SCOPE int       lt_dlsetsearchpath   (const char *search_path);
 LT_SCOPE const char *lt_dlgetsearchpath         (void);
 LT_SCOPE int       lt_dlforeachfile     (
                        const char *search_path,
@@ -102,7 +119,7 @@ LT_SCOPE int        lt_dlpreload_open    (const char 
*originator,
                                      lt_dlpreload_callback_func *func);
 
 #define lt_preloaded_symbols   lt__PROGRAM__LTX_preloaded_symbols
-#define LTDL_SET_PRELOADED_SYMBOLS()                   LT_STMT_START{  \
+#define LTDL_SET_PRELOADED_SYMBOLS()                   LT_STMT_START{  \
        extern const lt_dlsymlist lt_preloaded_symbols[];               \
        lt_dlpreload_default(lt_preloaded_symbols);                     \
                                                        }LT_STMT_END
diff --git a/libtoolize.m4sh b/libtoolize.m4sh
index 27f17a7..a3aa74d 100644
--- a/libtoolize.m4sh
+++ b/libtoolize.m4sh
@@ -5,7 +5,8 @@ AS_INIT[]m4_divert_push([HEADER-COPYRIGHT])dnl
 # libtoolize (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
 # Written by Gary V. Vaughan <g...@gnu.org>, 2003
 
-# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -122,7 +123,7 @@ configure_ac=configure.in
 # without --install, and the project may not be using Automake.
 all_pkgconfig_files="ltmain.sh"
 all_pkgmacro_files="argz.m4 libtool.m4 ltdl.m4 ltoptions.m4 ltsugar.m4 
ltversion.in ltversion.m4 lt~obsolete.m4"
-all_pkgltdl_files="COPYING.LIB Makefile Makefile.in Makefile.inc Makefile.am 
README acinclude.m4 aclocal.m4 argz_.h argz.c config.h.in config-h.in configure 
configure.ac configure.in libltdl/lt__alloc.h libltdl/lt__dirent.h 
libltdl/lt__glibc.h libltdl/lt__private.h libltdl/lt__strl.h 
libltdl/lt_dlloader.h libltdl/lt_error.h libltdl/lt_system.h libltdl/slist.h 
loaders/dld_link.c loaders/dlopen.c loaders/dyld.c loaders/load_add_on.c 
loaders/loadlibrary.c loaders/preopen.c loaders/shl_load.c lt__alloc.c 
lt__dirent.c lt__strl.c lt_dlloader.c lt_error.c ltdl.c ltdl.h slist.c"
+all_pkgltdl_files="COPYING.LIB Makefile Makefile.in Makefile.inc Makefile.am 
README acinclude.m4 aclocal.m4 argz_.h argz.c config.h.in config-h.in configure 
configure.ac configure.in libltdl/lt__alloc.h libltdl/lt__debug.h 
libltdl/lt__dirent.h libltdl/lt__glibc.h libltdl/lt__private.h 
libltdl/lt__strl.h libltdl/lt_dlloader.h libltdl/lt_error.h libltdl/lt_system.h 
libltdl/slist.h loaders/dld_link.c loaders/dlopen.c loaders/dyld.c 
loaders/load_add_on.c loaders/loadlibrary.c loaders/preopen.c 
loaders/shl_load.c lt__alloc.c libltdl/lt__debug.c lt__dirent.c lt__strl.c 
lt_dlloader.c lt_error.c ltdl.c ltdl.h slist.c"
 
 # Parse environment options
 {
diff --git a/tests/libtoolize.at b/tests/libtoolize.at
index fa229b9..1c89ef0 100644
--- a/tests/libtoolize.at
+++ b/tests/libtoolize.at
@@ -1,6 +1,6 @@
 # libtoolize.at -- test libtoolize operation                  -*- Autotest -*-
 #
-#   Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+#   Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
 #   Written by Gary V. Vaughan, 2005
 #
 #   This file is part of GNU Libtool.
@@ -308,6 +308,7 @@ libtoolize: copying file `ltdl/loaders/shl_load.c'
 libtoolize: copying file `ltdl/lt__dirent.c'
 libtoolize: copying file `ltdl/lt__strl.c'
 libtoolize: copying file `ltdl/libltdl/lt__alloc.h'
+libtoolize: copying file `ltdl/libltdl/lt__debug.h'
 libtoolize: copying file `ltdl/libltdl/lt__dirent.h'
 libtoolize: copying file `ltdl/libltdl/lt__glibc.h'
 libtoolize: copying file `ltdl/libltdl/lt__private.h'
@@ -318,6 +319,7 @@ libtoolize: copying file `ltdl/libltdl/lt_system.h'
 libtoolize: copying file `ltdl/libltdl/slist.h'
 libtoolize: copying file `ltdl/loaders/preopen.c'
 libtoolize: copying file `ltdl/lt__alloc.c'
+libtoolize: copying file `ltdl/lt__debug.c'
 libtoolize: copying file `ltdl/lt_dlloader.c'
 libtoolize: copying file `ltdl/lt_error.c'
 libtoolize: copying file `ltdl/ltdl.c'
@@ -387,6 +389,7 @@ libtoolize: linking file `ltdl/loaders/shl_load.c'
 libtoolize: linking file `ltdl/lt__dirent.c'
 libtoolize: linking file `ltdl/lt__strl.c'
 libtoolize: linking file `ltdl/libltdl/lt__alloc.h'
+libtoolize: linking file `ltdl/libltdl/lt__debug.h'
 libtoolize: linking file `ltdl/libltdl/lt__dirent.h'
 libtoolize: linking file `ltdl/libltdl/lt__glibc.h'
 libtoolize: linking file `ltdl/libltdl/lt__private.h'
@@ -397,6 +400,7 @@ libtoolize: linking file `ltdl/libltdl/lt_system.h'
 libtoolize: linking file `ltdl/libltdl/slist.h'
 libtoolize: linking file `ltdl/loaders/preopen.c'
 libtoolize: linking file `ltdl/lt__alloc.c'
+libtoolize: linking file `ltdl/lt__debug.c'
 libtoolize: linking file `ltdl/lt_dlloader.c'
 libtoolize: linking file `ltdl/lt_error.c'
 libtoolize: linking file `ltdl/ltdl.c'
@@ -486,6 +490,7 @@ libtoolize: copying file `ltdl/loaders/shl_load.c'
 libtoolize: copying file `ltdl/lt__dirent.c'
 libtoolize: copying file `ltdl/lt__strl.c'
 libtoolize: copying file `ltdl/libltdl/lt__alloc.h'
+libtoolize: copying file `ltdl/libltdl/lt__debug.h'
 libtoolize: copying file `ltdl/libltdl/lt__dirent.h'
 libtoolize: copying file `ltdl/libltdl/lt__glibc.h'
 libtoolize: copying file `ltdl/libltdl/lt__private.h'
@@ -496,6 +501,7 @@ libtoolize: copying file `ltdl/libltdl/lt_system.h'
 libtoolize: copying file `ltdl/libltdl/slist.h'
 libtoolize: copying file `ltdl/loaders/preopen.c'
 libtoolize: copying file `ltdl/lt__alloc.c'
+libtoolize: copying file `ltdl/lt__debug.c'
 libtoolize: copying file `ltdl/lt_dlloader.c'
 libtoolize: copying file `ltdl/lt_error.c'
 libtoolize: copying file `ltdl/ltdl.c'
@@ -810,6 +816,7 @@ libtoolize: copying file `ltdl/loaders/shl_load.c'
 libtoolize: copying file `ltdl/lt__dirent.c'
 libtoolize: copying file `ltdl/lt__strl.c'
 libtoolize: copying file `ltdl/libltdl/lt__alloc.h'
+libtoolize: copying file `ltdl/libltdl/lt__debug.h'
 libtoolize: copying file `ltdl/libltdl/lt__dirent.h'
 libtoolize: copying file `ltdl/libltdl/lt__glibc.h'
 libtoolize: copying file `ltdl/libltdl/lt__private.h'
@@ -820,6 +827,7 @@ libtoolize: copying file `ltdl/libltdl/lt_system.h'
 libtoolize: copying file `ltdl/libltdl/slist.h'
 libtoolize: copying file `ltdl/loaders/preopen.c'
 libtoolize: copying file `ltdl/lt__alloc.c'
+libtoolize: copying file `ltdl/lt__debug.c'
 libtoolize: copying file `ltdl/lt_dlloader.c'
 libtoolize: copying file `ltdl/lt_error.c'
 libtoolize: copying file `ltdl/ltdl.c'
@@ -903,6 +911,7 @@ libtoolize: copying file `ltdl/loaders/shl_load.c'
 libtoolize: copying file `ltdl/lt__dirent.c'
 libtoolize: copying file `ltdl/lt__strl.c'
 libtoolize: copying file `ltdl/libltdl/lt__alloc.h'
+libtoolize: copying file `ltdl/libltdl/lt__debug.h'
 libtoolize: copying file `ltdl/libltdl/lt__dirent.h'
 libtoolize: copying file `ltdl/libltdl/lt__glibc.h'
 libtoolize: copying file `ltdl/libltdl/lt__private.h'
@@ -913,6 +922,7 @@ libtoolize: copying file `ltdl/libltdl/lt_system.h'
 libtoolize: copying file `ltdl/libltdl/slist.h'
 libtoolize: copying file `ltdl/loaders/preopen.c'
 libtoolize: copying file `ltdl/lt__alloc.c'
+libtoolize: copying file `ltdl/lt__debug.c'
 libtoolize: copying file `ltdl/lt_dlloader.c'
 libtoolize: copying file `ltdl/lt_error.c'
 libtoolize: copying file `ltdl/ltdl.c'
-- 
1.6.2.rc0.35.g1b53


Reply via email to