Skip to content

Commit

Permalink
Fix load separate debug file
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed Oct 21, 2023
1 parent 1027d5e commit c046cdf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 7 additions & 5 deletions librz/bin/dwarf/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static inline RzBinDWARF *dwarf_from_debuglink(

return NULL;
ok:
dw = rz_bin_dwarf_dwo_from_file(path);
dw = rz_bin_dwarf_from_path(path, false);
free(dir);
free(path);
free(file_dir);
Expand All @@ -142,7 +142,7 @@ static inline RzBinDWARF *dwarf_from_build_id(
char *dir = rz_file_path_join(debug_file_directory, ".build-id");
char *path = rz_file_path_join(dir, build_id_path);
if (rz_file_exists(path)) {
RzBinDWARF *dw = rz_bin_dwarf_dwo_from_file(path);
RzBinDWARF *dw = rz_bin_dwarf_from_path(path, false);
free(dir);
free(path);
return dw;
Expand Down Expand Up @@ -171,7 +171,8 @@ RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_search_debug_file_directory(
}
char *debuglink = read_debuglink(bf);
if (debuglink) {
char *file_dir = rz_file_dirname(bf->file);
char *file_abspath = rz_file_abspath(bf->file);
char *file_dir = file_abspath ? rz_file_dirname(file_abspath) : NULL;
if (file_dir) {
dw = dwarf_from_debuglink(file_dir, debug_file_directorys, debuglink);
}
Expand All @@ -189,7 +190,8 @@ RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_search_debug_file_directory(
* \param filepath The file path
* \return RzBinDWARF pointer or NULL if failed
*/
RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_dwo_from_file(RZ_BORROW RZ_NONNULL const char *filepath) {
RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_from_path(
RZ_BORROW RZ_NONNULL const char *filepath, bool is_dwo) {
rz_return_val_if_fail(filepath, NULL);

RzBinDWARF *dwo = NULL;
Expand All @@ -203,7 +205,7 @@ RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_dwo_from_file(RZ_BORROW RZ_NONNULL const
if (!bf) {
goto beach;
}
dwo = dwarf_from_file(bf, true);
dwo = dwarf_from_file(bf, is_dwo);

beach:
rz_bin_free(bin_tmp);
Expand Down
4 changes: 2 additions & 2 deletions librz/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ static inline RzBinDWARF *load_dwarf(RzCore *core, RzBinFile *binfile) {

const char *dwo_path = rz_config_get(core->config, "bin.dbginfo.dwo_path");
if (RZ_STR_ISNOTEMPTY(dwo_path)) {
RzBinDWARF *dwo = rz_bin_dwarf_dwo_from_file(core->bin, dwo_path);
RzBinDWARF *dwo = rz_bin_dwarf_from_path(dwo_path, true);
if (dwo) {
dwo->parent = dw;
return dwo;
Expand Down Expand Up @@ -1733,7 +1733,7 @@ static bool bin_dwarf(RzCore *core, RzBinFile *binfile, RzCmdStateOutput *state)

RzBinDWARF *dw = (core->analysis && core->analysis->debug_info && core->analysis->debug_info->dw)
? core->analysis->debug_info->dw
: rz_bin_dwarf_from_file(binfile);
: load_dwarf(core, binfile);
if (!dw) {
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion librz/include/rz_bin_dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,8 @@ RZ_API void rz_bin_dwarf_line_op_fini(RZ_OWN RZ_NULLABLE RzBinDwarfLineOp *op);
RZ_API void rz_bin_dwarf_line_free(RZ_OWN RZ_NULLABLE RzBinDwarfLine *li);

RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_from_file(RZ_BORROW RZ_NONNULL RzBinFile *bf);
RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_dwo_from_file(RZ_BORROW RZ_NONNULL const char *filepath);
RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_from_path(
RZ_BORROW RZ_NONNULL const char *filepath, bool is_dwo);
RZ_API RZ_OWN RzBinDWARF *rz_bin_dwarf_search_debug_file_directory(
RZ_BORROW RZ_NONNULL RzBinFile *bf,
RZ_BORROW RZ_NONNULL RzList /*<const char *>*/ *debug_file_directorys);
Expand Down

0 comments on commit c046cdf

Please sign in to comment.