X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fso-info.c;h=239320d9c30cf5582d5e4034bef4b7ff1a4fba4c;hb=1b3f6ee3507f712ff1792cfaf255007195d24308;hp=6998fbfbf0328700c1bd8ce925a62c2b38e1dfd2;hpb=1c47ec6cee3670631b54e449939703aebe4e182e;p=babeltrace.git diff --git a/lib/so-info.c b/lib/so-info.c index 6998fbfb..239320d9 100644 --- a/lib/so-info.c +++ b/lib/so-info.c @@ -78,7 +78,13 @@ struct so_info *so_info_create(const char *path, uint64_t low_addr, goto error; } - so->elf_path = strdup(path); + if (opt_debug_info_target_prefix) { + so->elf_path = g_build_path("/", opt_debug_info_target_prefix, + path, NULL); + } else { + so->elf_path = strdup(path); + } + if (!so->elf_path) { goto error; } @@ -249,10 +255,10 @@ error: static int so_info_set_dwarf_info_build_id(struct so_info *so) { - int i = 0, ret = 0, dbg_dir_trailing_slash = 0; + int i = 0, ret = 0; char *path = NULL, *build_id_file = NULL; const char *dbg_dir = NULL; - size_t build_id_file_len, path_len; + size_t build_id_file_len; if (!so || !so->build_id) { goto error; @@ -260,10 +266,10 @@ int so_info_set_dwarf_info_build_id(struct so_info *so) dbg_dir = opt_debug_info_dir ? : DEFAULT_DEBUG_DIR; - dbg_dir_trailing_slash = dbg_dir[strlen(dbg_dir) - 1] == '/'; - - /* 2 characters per byte printed in hex, +2 for '/' and '\0' */ - build_id_file_len = (2 * so->build_id_len) + 2; + /* 2 characters per byte printed in hex, +1 for '/' and +1 for + * '\0' */ + build_id_file_len = (2 * so->build_id_len) + 1 + + strlen(BUILD_ID_SUFFIX) + 1; build_id_file = malloc(build_id_file_len); if (!build_id_file) { goto error; @@ -275,26 +281,13 @@ int so_info_set_dwarf_info_build_id(struct so_info *so) snprintf(&build_id_file[path_idx], 3, "%02x", so->build_id[i]); } + strcat(build_id_file, BUILD_ID_SUFFIX); - path_len = strlen(dbg_dir) + strlen(BUILD_ID_SUBDIR) + - strlen(build_id_file) + strlen(BUILD_ID_SUFFIX) + 1; - if (!dbg_dir_trailing_slash) { - path_len += 1; - } - - path = malloc(path_len); + path = g_build_path("/", dbg_dir, BUILD_ID_SUBDIR, build_id_file, NULL); if (!path) { goto error; } - strcpy(path, dbg_dir); - if (!dbg_dir_trailing_slash) { - strcat(path, "/"); - } - strcat(path, BUILD_ID_SUBDIR); - strcat(path, build_id_file); - strcat(path, BUILD_ID_SUFFIX); - ret = so_info_set_dwarf_info_from_path(so, path); if (ret) { goto error;