diff --git a/librz/analysis/dwarf_process.c b/librz/analysis/dwarf_process.c index f37962140b3..8bd6a4a62cd 100644 --- a/librz/analysis/dwarf_process.c +++ b/librz/analysis/dwarf_process.c @@ -1937,15 +1937,6 @@ static bool dwarf_integrate_function(void *user, const ut64 k, const void *value return true; } - /* Apply signature as a comment at a function address */ - RzCallable *callable = dw_fn->prefer_name ? rz_type_func_get(analysis->typedb, dw_fn->prefer_name) - : ht_up_find(analysis->debug_info->callable_by_offset, dw_fn->offset, NULL); - if (callable) { - char *sig = rz_type_callable_as_string(analysis->typedb, callable); - rz_meta_set_string(analysis, RZ_META_TYPE_COMMENT, dw_fn->low_pc, sig); - free(sig); - } - if (dw_fn->prefer_name && !rz_str_startswith(dw_fn->prefer_name, "anonymous")) { char *dwf_name = rz_str_newf("dbg.%s", dw_fn->prefer_name); rz_analysis_function_rename((RzAnalysisFunction *)fn, dwf_name); diff --git a/librz/core/disasm.c b/librz/core/disasm.c index 17ed3744910..ff5ec9bbc2c 100644 --- a/librz/core/disasm.c +++ b/librz/core/disasm.c @@ -2173,6 +2173,24 @@ static void __preline_flag(RzDisasmState *ds, RzFlagItem *flag) { } } +// check the equality between names from symbol tab and debug info +// like sym.func_name and dbg.func_name +static bool is_sym_dbg_equal(const char *a, const char *b) { + if (!rz_str_startswith(a, "sym.") && !rz_str_startswith(a, "dbg.")) { + return false; + } + if (!rz_str_startswith(b, "sym.") && !rz_str_startswith(b, "dbg.")) { + return false; + } + const size_t sym_n = strlen("sym."); + return !strcmp(a + sym_n, b + sym_n); +} + +static inline bool is_flag_overlapped(RzFlagItem *flag, RzAnalysisFunction *f) { + const bool name_overlapped = !strcmp(flag->name, f->name) || is_sym_dbg_equal(flag->name, f->name); + return f->addr == flag->offset && name_overlapped; +} + #define printPre (outline || !*comma) static void ds_show_flags(RzDisasmState *ds, bool overlapped) { // const char *beginch; @@ -2197,7 +2215,7 @@ static void ds_show_flags(RzDisasmState *ds, bool overlapped) { RzAnalysisBlock *switch_block = NULL; const char *switch_enum_name = NULL; rz_list_foreach (uniqlist, iter, flag) { - if (!overlapped && f && f->addr == flag->offset && !strcmp(flag->name, f->name)) { + if (!overlapped && f && is_flag_overlapped(flag, f)) { // do not show non-overlapped flags that have the same name as the function continue; } @@ -5516,6 +5534,7 @@ RZ_API int rz_core_print_disasm(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL u ds_show_refs(ds); } } + core->print->resetbg = true; ds_newline(ds); if (ds->line) { diff --git a/test/db/analysis/rl78 b/test/db/analysis/rl78 index e6e250b420e..a237aa91e33 100644 --- a/test/db/analysis/rl78 +++ b/test/db/analysis/rl78 @@ -66,7 +66,7 @@ EXPECT=<] void * prout(void *str, const char *buf, size_t n); - ;-- prout: / void * prout(void *str, const char *buf, size_t n) | ; var int32_t arg6 @ a5 | ; arg void *str @ a4 | ; arg const char *buf @ a4 | ; arg size_t n @ d5 -| 0x80000c04 mov.aa a15, a4 ; printf.c:5 ; arg5 ; void * prout(void *str, const char *buf, size_t n) +| 0x80000c04 mov.aa a15, a4 ; printf.c:5 ; arg5 --------- arg fp_number_type *b @ a2 arg fp_number_type *a @ a4 @@ -948,7 +943,6 @@ false a_fraction fractype DWARF loclist: [(0x80003cd4, 1 fp_number_type * _fpadd_parts(fp_number_type *a, fp_number_type *b, fp_number_type *tmp); ; CALL XREF from dbg.__adddf3 @ 0x80003e32 ; CALL XREF from dbg.__subdf3 @ 0x80003e72 - ;-- _fpadd_parts: / fp_number_type * _fpadd_parts(fp_number_type *a, fp_number_type *b, fp_number_type *tmp) | ; var int32_t arg6 @ a5 | ; arg fp_number_type *a @ a4 @@ -959,7 +953,7 @@ fp_number_type * _fpadd_parts(fp_number_type *a, fp_number_type *b, fp_number_ty | ; var int b_normal_exp @ d2 | ; var fractype a_fraction @ LOCLIST | ; var fractype b_fraction @ COMPOSITE -| 0x80003c60 ld.bu d15, [a4]#0 ; fp-bit.c:604 ; arg5 ; fp_number_type * _fpadd_parts(fp_number_type *a, fp_number_type *b, fp_number_type *tmp) +| 0x80003c60 ld.bu d15, [a4]#0 ; fp-bit.c:604 ; arg5 --------- arg const char *s @ a2 var const char *sc @ a2 @@ -973,13 +967,12 @@ false arg5 int32_t rizin a4 true maxsize size_t DWARF loclist: [(0x800030ca, 8): d4, (0x800030ea, 2): d4] size_t strnlen_s(const char *s, size_t maxsize); ; CALL XREF from dbg._Fail_s @ 0x8000191e - ;-- strnlen_s: / size_t strnlen_s(const char *s, size_t maxsize) | ; var int32_t arg5 @ a4 | ; arg const char *s @ a2 | ; arg size_t maxsize @ d4 | ; var const char *sc @ a2 -| 0x800030ca mov d2, #0 ; strnlen_s.c:6 ; size_t strnlen_s(const char *s, size_t maxsize) +| 0x800030ca mov d2, #0 ; strnlen_s.c:6 --------- var _Statab *pwcstate @ a13 arg char *s @ a4 @@ -995,14 +988,13 @@ true wc wchar_t DWARF loclist: [(0x800018a6, 21): d4, ( false pmbstate _Statab * DWARF empty int _Wctomb(char *s, wchar_t wc, mbstate_t *pst); ; CALL XREF from dbg._Putstr @ 0x800014d2 - ;-- _Wctomb: / int _Wctomb(char *s, wchar_t wc, mbstate_t *pst) | ; arg char *s @ a4 | ; arg wchar_t wc @ d4 | ; arg mbstate_t *pst @ a5 | ; var _Statab *pmbstate @ ... | ; var _Statab *pwcstate @ a13 -| 0x800018a6 movh.a a2, #0xd000 ; xwctomb.c:123 ; int _Wctomb(char *s, wchar_t wc, mbstate_t *pst) +| 0x800018a6 movh.a a2, #0xd000 ; xwctomb.c:123 --------- arg mbstate_t *pst @ a12 arg const char *s @ a13 @@ -1022,7 +1014,6 @@ false arg7 int32_t rizin a6 true nin size_t DWARF loclist: [(0x80003084, 23): d4, (0x8000309b, 21): d15] int _Mbtowc(wchar_t *pwc, const char *s, size_t nin, mbstate_t *pst); ; CALL XREF from dbg._Printf @ 0x80000d02 - ;-- _Mbtowc: / int _Mbtowc(wchar_t *pwc, const char *s, size_t nin, mbstate_t *pst) | ; var int32_t arg5 @ a4 | ; var int32_t arg6 @ a5 @@ -1031,7 +1022,7 @@ int _Mbtowc(wchar_t *pwc, const char *s, size_t nin, mbstate_t *pst); | ; arg const char *s @ a13 | ; arg size_t nin @ d15 | ; arg mbstate_t *pst @ a12 -| 0x80003084 movh.a a15, #0xd000 ; xmbtowc.c:150 ; int _Mbtowc(wchar_t *pwc, const char *s, size_t nin, mbstate_t *pst) +| 0x80003084 movh.a a15, #0xd000 ; xmbtowc.c:150 --------- arg int except @ d4 is_arg name type constraints origin addr @@ -1039,10 +1030,9 @@ is_arg name type constraints origin addr true except int DWARF d4 int feraiseexcept(int except); ; CALL XREF from dbg._Feraise @ 0x8000343e - ;-- feraiseexcept: / int feraiseexcept(int except) | ; arg int except @ d4 -| 0x800037d8 mov d2, #0 ; feraiseexcept.c:173 ; int feraiseexcept(int except) +| 0x800037d8 mov d2, #0 ; feraiseexcept.c:173 --------- var size_t size_arg @ a0 var Ppvoidfn newfuns @ a2 @@ -1055,12 +1045,11 @@ false inc size_t DWARF d15 int _Atrealloc(); ; CALL XREF from dbg.atexit @ 0x80001a4c ; CALL XREF from dbg._Atexit @ 0x800033b8 - ;-- _Atrealloc: / int _Atrealloc() | ; var size_t size_arg @ a0 | ; var size_t inc @ d15 | ; var Ppvoidfn newfuns @ a2 -| 0x80001994 movh.a a15, #0xd000 ; exit.c:22 ; int _Atrealloc() +| 0x80001994 movh.a a15, #0xd000 ; exit.c:22 --------- arg some_t **out @ stack - 0x18 arg struct Some *gg @ stack - 0x14 @@ -1084,7 +1073,6 @@ false arg6 int32_t rizin a5 false arg7 int32_t rizin a6 void dbg.fn1(int a, char *g, double q, struct Some *gg, some_t **out); ; CALL XREF from dbg.main @ 0x8000059e - ;-- fn1: / _Bool fn1(int a, char *g, double q, struct Some *gg, some_t **out) | ; var int32_t arg5 @ a4 | ; var int32_t arg6 @ a5 @@ -1095,7 +1083,7 @@ void dbg.fn1(int a, char *g, double q, struct Some *gg, some_t **out); | ; arg double q @ stack - 0x10 | ; arg struct Some *gg @ stack - 0x14 | ; arg some_t **out @ stack - 0x18 -| 0x8000041c mov.aa a14, sp ; float_ex1.c:15 ; _Bool fn1(int a, char *g, double q, struct Some *gg, some_t **out) +| 0x8000041c mov.aa a14, sp ; float_ex1.c:15 --------- EOF RUN diff --git a/test/db/cmd/dwarf b/test/db/cmd/dwarf index fd09cebec29..1080c4fb530 100644 --- a/test/db/cmd/dwarf +++ b/test/db/cmd/dwarf @@ -1782,7 +1782,7 @@ EXPECT=<