Skip to content
Snippets Groups Projects

Add inspect-library helper

Merged Ludovico de Nittis requested to merge wip/denittis/inspect-library into master
1 file
+ 16
4
Compare changes
  • Side-by-side
  • Inline
+ 16
4
@@ -32,6 +32,8 @@
#include <dlfcn.h>
#include <link.h>
void clean_exit (void *handle);
int
main (int argc,
char **argv)
@@ -55,13 +57,13 @@ main (int argc,
if (handle == NULL)
{
g_warning ("Unable to find the library: %s\n", dlerror ());
g_print ("}\n");
clean_exit (handle);
return 1;
}
if (dlinfo (handle, RTLD_DI_ORIGIN, library_path) != 0)
{
g_warning ("Unable to obtain the path: %s\n", dlerror ());
g_print ("}\n");
clean_exit (handle);
return 1;
}
g_print (" \"path\": \"%s\",\n", library_path);
@@ -69,7 +71,7 @@ main (int argc,
if (dlinfo (handle, RTLD_DI_LINKMAP, &dep_map) != 0)
{
g_warning ("Unable to obtain the dependencies list: %s\n", dlerror ());
g_print ("}\n");
clean_exit (handle);
return 1;
}
@@ -85,7 +87,17 @@ main (int argc,
g_print (",\n \"%s\"", dep_map->l_name);
}
g_print ("\n ]\n }\n}\n");
g_print ("\n ]\n }\n");
clean_exit (handle);
return 0;
}
void
clean_exit (void *handle)
{
if (handle != NULL)
dlclose (handle);
g_print ("}\n");
}
Loading