-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dwarf sourceline info #3449
Dwarf sourceline info #3449
Changes from 7 commits
209d0b1
617da92
28fbeb4
6dcf9d8
6b751e0
bd75206
dcc316f
76ce94c
808eb27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,6 +292,7 @@ typedef struct { | |
int _tabsoff; | ||
bool dwarfFile; | ||
bool dwarfAbspath; | ||
bool dwarfShowLines; | ||
bool showpayloads; | ||
bool showrelocs; | ||
int cmtcount; | ||
|
@@ -349,7 +350,8 @@ static void ds_print_sysregs(RzDisasmState *ds); | |
static void ds_print_fcn_name(RzDisasmState *ds); | ||
static void ds_print_as_string(RzDisasmState *ds); | ||
static bool ds_print_core_vmode(RzDisasmState *ds, int pos); | ||
static void ds_print_dwarf(RzDisasmState *ds); | ||
// static void ds_print_dwarf(RzDisasmState *ds); | ||
static void ds_print_dwarf(RzCore *core, RzCmdStateOutput *state, RzDisasmState *ds); | ||
static void ds_print_asmop_payload(RzDisasmState *ds, const ut8 *buf); | ||
static char *ds_esc_str(RzDisasmState *ds, const char *str, int len, const char **prefix_out, bool is_comment); | ||
static void ds_print_ptr(RzDisasmState *ds, int len, int idx); | ||
|
@@ -721,6 +723,7 @@ static RzDisasmState *ds_init(RzCore *core) { | |
ds->show_dwarf = rz_config_get_b(core->config, "asm.dwarf"); | ||
ds->dwarfFile = rz_config_get_b(ds->core->config, "asm.dwarf.file"); | ||
ds->dwarfAbspath = rz_config_get_b(ds->core->config, "asm.dwarf.abspath"); | ||
ds->dwarfShowLines = rz_config_get_b(ds->core->config, "asm.dwarf.lines"); | ||
ds->show_lines_call = ds->show_lines ? rz_config_get_b(core->config, "asm.lines.call") : false; | ||
ds->show_lines_ret = ds->show_lines ? rz_config_get_b(core->config, "asm.lines.ret") : false; | ||
ds->show_size = rz_config_get_b(core->config, "asm.size"); | ||
|
@@ -3811,7 +3814,50 @@ static void ds_align_comment(RzDisasmState *ds) { | |
rz_cons_print(" "); | ||
} | ||
|
||
static void ds_print_dwarf(RzDisasmState *ds) { | ||
static void ds_print_dwarf(RzCore *core, RzCmdStateOutput *state, RzDisasmState *ds) { | ||
|
||
bool binFileExists = true; | ||
bool SourceLineInfoExists = true; | ||
|
||
RzBinFile *binfile = core->bin->cur; | ||
if (!binfile || !binfile->o) { | ||
// rz_cons_printf("No file loaded.\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
binFileExists = false; | ||
// return false; | ||
} | ||
RzBinSourceLineInfo *li = binfile->o->lines; | ||
if (!li) { | ||
// rz_cons_printf("No Source line information available"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
SourceLineInfoExists = false; | ||
// return true; | ||
} | ||
if (ds->dwarfShowLines && ds->show_dwarf && SourceLineInfoExists && binFileExists) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary empty line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can extract that part into a separate static function for clarity |
||
rz_cmd_state_output_array_start(state); | ||
rz_cons_break_push(NULL, NULL); | ||
RzBinSourceLineSample *temps = NULL; | ||
for (size_t i = 0; i < li->samples_count; i++) { | ||
if (rz_cons_is_breaked()) { | ||
break; | ||
} | ||
temps = &li->samples[i]; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
ds_align_comment(ds); | ||
if (ds->vat == temps->address) { | ||
// rz_cons_printf(/*"0x%08" PFMT64x */ "\t%s\t"/*temps->address,*/,temps->file ? temps->file : "-"); | ||
rz_cons_printf("\tLine number%s", temps->file ? temps->file : "-"); | ||
|
||
if (temps->line) { | ||
rz_cons_printf("%" PFMT32u "\n", temps->line); | ||
} else { | ||
rz_cons_print("-\n"); | ||
} | ||
} | ||
} | ||
rz_cons_break_pop(); | ||
rz_cmd_state_output_array_end(state); | ||
} | ||
|
||
if (ds->show_dwarf) { | ||
// TODO: cache value in ds | ||
int dwarfFile = (int)ds->dwarfFile + (int)ds->dwarfAbspath; | ||
|
@@ -5534,7 +5580,6 @@ RZ_API int rz_core_print_disasm(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL u | |
ds_adistrick_comments(ds); | ||
/* XXX: This is really cpu consuming.. need to be fixed */ | ||
ds_show_functions(ds); | ||
|
||
if (ds->show_comments && !ds->show_comment_right) { | ||
ds_show_refs(ds); | ||
ds_build_op_str(ds, false); | ||
|
@@ -5556,7 +5601,6 @@ RZ_API int rz_core_print_disasm(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL u | |
} | ||
ds_show_comments_describe(ds); | ||
} | ||
|
||
f = fcnIn(ds, ds->addr, 0); | ||
ds_begin_line(ds); | ||
ds_print_labels(ds, f); | ||
|
@@ -5576,7 +5620,6 @@ RZ_API int rz_core_print_disasm(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL u | |
} | ||
} | ||
} | ||
//// | ||
int mi_type; | ||
bool mi_found = ds_print_meta_infos(ds, buf, len, idx, &mi_type); | ||
if (ds->asm_hint_pos == 0) { | ||
|
@@ -5592,7 +5635,7 @@ RZ_API int rz_core_print_disasm(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL u | |
ds_print_family(ds); | ||
ds_print_stackptr(ds); | ||
if (mi_found) { | ||
ds_print_dwarf(ds); | ||
ds_print_dwarf(core, state, ds); | ||
ret = ds_print_middle(ds, ret); | ||
|
||
ds_print_asmop_payload(ds, buf + addrbytes * idx); | ||
|
@@ -5632,7 +5675,7 @@ RZ_API int rz_core_print_disasm(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL u | |
ds_build_op_str(ds, true); | ||
ds_print_opstr(ds); | ||
ds_end_line_highlight(ds); | ||
ds_print_dwarf(ds); | ||
ds_print_dwarf(core, state, ds); | ||
ret = ds_print_middle(ds, ret); | ||
|
||
ds_print_asmop_payload(ds, buf + addrbytes * idx); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove