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;
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);
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;
dwarf_end(bin->dwarf_info);
+ free(bin->debug_info_dir);
free(bin->elf_path);
free(bin->dwarf_path);
g_free(bin->build_id);
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 +
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) {
}
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;
/* 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;
/*
* @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
}
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__);
};
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.
}
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;
goto error;
}
+ debug_info->comp = comp;
ret = debug_info_init(debug_info);
if (ret) {
goto error;
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;
}
};
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);
/* 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);