debug-info.debug-info: do not use global opt_* symbols anymore
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 5 May 2017 16:53:54 +0000 (12:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:42 +0000 (12:57 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/debug-info/bin-info.c
plugins/debug-info/bin-info.h
plugins/debug-info/copy.c
plugins/debug-info/debug-info.c
plugins/debug-info/debug-info.h
plugins/debug-info/plugin.c

index 81bfe63e1978a2265c725b680800e8988c426482..170b351f20fdc4cc4e75b9c151bf94925b9ae6fe 100644 (file)
@@ -66,7 +66,8 @@ int bin_info_init(void)
 
 BT_HIDDEN
 struct bin_info *bin_info_create(const char *path, uint64_t low_addr,
-               uint64_t memsz, bool is_pic)
+               uint64_t memsz, bool is_pic, const char *debug_info_dir,
+               const char *target_prefix)
 {
        struct bin_info *bin = NULL;
 
@@ -79,8 +80,8 @@ struct bin_info *bin_info_create(const char *path, uint64_t low_addr,
                goto error;
        }
 
-       if (opt_debug_info_target_prefix) {
-               bin->elf_path = g_build_path("/", opt_debug_info_target_prefix,
+       if (target_prefix) {
+               bin->elf_path = g_build_path("/", target_prefix,
                                                path, NULL);
        } else {
                bin->elf_path = strdup(path);
@@ -90,6 +91,13 @@ struct bin_info *bin_info_create(const char *path, uint64_t low_addr,
                goto error;
        }
 
+       if (debug_info_dir) {
+               bin->debug_info_dir = strdup(debug_info_dir);
+               if (!bin->debug_info_dir) {
+                       goto error;
+               }
+       }
+
        bin->is_pic = is_pic;
        bin->memsz = memsz;
        bin->low_addr = low_addr;
@@ -111,6 +119,7 @@ void bin_info_destroy(struct bin_info *bin)
 
        dwarf_end(bin->dwarf_info);
 
+       free(bin->debug_info_dir);
        free(bin->elf_path);
        free(bin->dwarf_path);
        g_free(bin->build_id);
@@ -270,7 +279,7 @@ int bin_info_set_dwarf_info_build_id(struct bin_info *bin)
                goto error;
        }
 
-       dbg_dir = opt_debug_info_dir ? : DEFAULT_DEBUG_DIR;
+       dbg_dir = bin->debug_info_dir ? : DEFAULT_DEBUG_DIR;
 
        /* 2 characters per byte printed in hex, +1 for '/' and +1 for '\0' */
        build_id_file_len = (2 * bin->build_id_len) + 1 +
@@ -372,7 +381,7 @@ int bin_info_set_dwarf_info_debug_link(struct bin_info *bin)
                goto error;
        }
 
-       dbg_dir = opt_debug_info_dir ? : DEFAULT_DEBUG_DIR;
+       dbg_dir = bin->debug_info_dir ? : DEFAULT_DEBUG_DIR;
 
        dir_name = dirname(bin->elf_path);
        if (!dir_name) {
@@ -909,8 +918,8 @@ error:
 }
 
 BT_HIDDEN
-int bin_info_lookup_function_name(struct bin_info *bin, uint64_t addr,
-               char **func_name)
+int bin_info_lookup_function_name(struct bin_info *bin,
+               uint64_t addr, char **func_name)
 {
        int ret = 0;
        char *_func_name = NULL;
index c4da928ae4c7e423c57a07a6eaf76afe8e7a9f61..05d0d797d0372697a45eb23f33394507df965ed0 100644 (file)
@@ -60,6 +60,8 @@ struct bin_info {
        /* FDs to ELF and DWARF files. */
        int elf_fd;
        int dwarf_fd;
+       /* Configuration. */
+       char *debug_info_dir;
        /* Denotes whether the executable is position independent code. */
        bool is_pic:1;
        /*
@@ -92,12 +94,16 @@ int bin_info_init(void);
  * @param memsz        In-memory size of the executable
  * @param is_pic       Whether the executable is position independent
  *                     code (PIC)
+ * @param debug_info_dir Directory containing debug info or NULL.
+ * @param target_prefix  Path to the root file system of the target
+ *                       or NULL.
  * @returns            Pointer to the new bin_info on success,
  *                     NULL on failure.
  */
 BT_HIDDEN
 struct bin_info *bin_info_create(const char *path, uint64_t low_addr,
-               uint64_t memsz, bool is_pic);
+               uint64_t memsz, bool is_pic, const char *debug_info_dir,
+               const char *target_prefix);
 
 /**
  * Destroy the given bin_info instance
index 824774ff128ae36addb22c0a9ef6a5f22edacc4e..2689a703a44aa978ea560d37cbbd7bea27092fed 100644 (file)
@@ -479,7 +479,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it,
        }
        BT_PUT(field);
 
-       debug_info = debug_info_create();
+       debug_info = debug_info_create(debug_it->debug_info_component);
        if (!debug_info) {
                fprintf(debug_it->err, "[error] %s in %s:%d\n", __func__,
                                __FILE__, __LINE__);
index 93e51081b23d40549795ac8817824a98fcf08f34..bc8fa6ddd7273c2639ced371879be0f09100f0cb 100644 (file)
@@ -47,6 +47,8 @@ struct proc_debug_info_sources {
 };
 
 struct debug_info {
+       struct debug_info_component *comp;
+
        /*
         * Hash table of VPIDs (pointer to int64_t) to
         * (struct ctf_proc_debug_infos*); owned by debug_info.
@@ -320,7 +322,7 @@ end:
 }
 
 BT_HIDDEN
-struct debug_info *debug_info_create(void)
+struct debug_info *debug_info_create(struct debug_info_component *comp)
 {
        int ret;
        struct debug_info *debug_info;
@@ -337,6 +339,7 @@ struct debug_info *debug_info_create(void)
                goto error;
        }
 
+       debug_info->comp = comp;
        ret = debug_info_init(debug_info);
        if (ret) {
                goto error;
@@ -600,7 +603,9 @@ void handle_bin_info_event(FILE *err, struct debug_info *debug_info,
                goto end;
        }
 
-       bin = bin_info_create(path, baddr, memsz, is_pic);
+       bin = bin_info_create(path, baddr, memsz, is_pic,
+               debug_info->comp->arg_debug_dir,
+               debug_info->comp->arg_target_prefix);
        if (!bin) {
                goto end;
        }
index 974e5c012b04b50eb11f3c510de8e2d6b146c954..41618b0aa66645cdbafe4d559978d4fa12c2b296 100644 (file)
@@ -80,7 +80,7 @@ struct debug_info_source {
 };
 
 BT_HIDDEN
-struct debug_info *debug_info_create(void);
+struct debug_info *debug_info_create(struct debug_info_component *comp);
 
 BT_HIDDEN
 void debug_info_destroy(struct debug_info *debug_info);
index c9ae94fad22b82b550bfdd237da8563555340035..85b12a67432d825b846a6610fc4880c5ca43cb76 100644 (file)
@@ -476,7 +476,7 @@ error:
 /* Initialize plug-in entry points. */
 BT_PLUGIN(debug_info);
 BT_PLUGIN_DESCRIPTION("Babeltrace Debug Informations Plug-In.");
-BT_PLUGIN_AUTHOR("Jérémie Galarneau");
+BT_PLUGIN_AUTHOR("Julien Desfossez");
 BT_PLUGIN_LICENSE("MIT");
 
 BT_PLUGIN_FILTER_COMPONENT_CLASS(debug_info, debug_info_iterator_next);
This page took 0.028576 seconds and 4 git commands to generate.