OSDN Git Service

Add debug prints to plugin loading
authorChris Larson <clarson@kergoth.com>
Sat, 1 Nov 2008 20:45:57 +0000 (20:45 +0000)
committerChris Larson <clarson@kergoth.com>
Sat, 1 Nov 2008 20:45:57 +0000 (20:45 +0000)
Add some debug prints (and include stdio.h) which can help diagnose
plugin load problems.

Signed-off-by: Ville Syrjala <syrjala@sci.fi>
Signed-off-by: Chris Larson <clarson@kergoth.com>
src/ts_load_module.c

index 266740e..9605b5c 100644 (file)
@@ -15,6 +15,7 @@
 #ifdef HAVE_ALLOCA_H
 #include <alloca.h>
 #endif
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <dlfcn.h>
@@ -46,17 +47,27 @@ int __ts_load_module(struct tsdev *ts, const char *module, const char *params, i
        printf ("Loading module %s\n", fn);
 #endif
        handle = dlopen(fn, RTLD_NOW);
-       if (!handle)
+       if (!handle) {
+#ifdef DEBUG
+               fprintf (stderr, "%s dlopen() failed: %s\n", fn, dlerror());
+#endif
                return -1;
+       }
 
        init = dlsym(handle, "mod_init");
        if (!init) {
+#ifdef DEBUG
+               fprintf (stderr, "%s dlsym() failed: %s\n", fn, dlerror());
+#endif
                dlclose(handle);
                return -1;
        }
 
        info = init(ts, params);
        if (!info) {
+#ifdef DEBUG
+               fprintf (stderr, "Can't init %s\n", fn);
+#endif
                dlclose(handle);
                return -1;
        }
@@ -69,6 +80,9 @@ int __ts_load_module(struct tsdev *ts, const char *module, const char *params, i
                ret = __ts_attach(ts, info);
        }
        if (ret) {
+#ifdef DEBUG
+               fprintf (stderr, "Can't attach %s\n", fn);
+#endif
                info->ops->fini(info);
                dlclose(handle);
        }