From 45c0024300437fd5a69e9986135895b22db7f562 Mon Sep 17 00:00:00 2001 From: Aswin C Date: Mon, 28 Sep 2020 15:21:38 +0530 Subject: [PATCH] Rename `asm.var.sub` to `asm.sub.var` ##cons (#17717) * Rename `asm.var.sub` to `asm.sub.var` * Rename tests for `asm.var.sub` --- libr/core/cconfig.c | 4 ++-- libr/core/cmd_anal.c | 14 +++++++------- libr/core/disasm.c | 18 +++++++++--------- libr/include/r_parse.h | 4 ++-- libr/parse/p/parse_arm_pseudo.c | 4 ++-- libr/parse/p/parse_mips_pseudo.c | 4 ++-- libr/parse/p/parse_wasm_pseudo.c | 4 ++-- libr/parse/p/parse_x86_pseudo.c | 4 ++-- libr/parse/parse.c | 6 +++--- test/db/cmd/cmd_pd | 14 +++++++------- test/db/formats/elf/mips | 4 ++-- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/libr/core/cconfig.c b/libr/core/cconfig.c index 03114f37aa..59bd334637 100644 --- a/libr/core/cconfig.c +++ b/libr/core/cconfig.c @@ -3086,7 +3086,7 @@ R_API int r_core_config_init(RCore *core) { SETBPREF ("asm.lines.wide", "false", "Put a space between lines"); SETBPREF ("asm.fcnsig", "true", "Show function signature in disasm"); SETICB ("asm.lines.width", 7, &cb_asmlineswidth, "Number of columns for program flow arrows"); - SETICB ("asm.sub.varmin", 0x100, &cb_asmsubvarmin, "Minimum value to substitute in instructions (asm.var.sub)"); + SETICB ("asm.sub.varmin", 0x100, &cb_asmsubvarmin, "Minimum value to substitute in instructions (asm.sub.var)"); SETCB ("asm.sub.tail", "false", &cb_asmsubtail, "Replace addresses with prefix .. syntax"); SETBPREF ("asm.middle", "false", "Allow disassembling jumps in the middle of an instruction"); SETBPREF ("asm.noisy", "true", "Show comments considered noisy but possibly useful"); @@ -3119,7 +3119,7 @@ R_API int r_core_config_init(RCore *core) { SETBPREF ("asm.capitalize", "false", "Use camelcase at disassembly"); SETBPREF ("asm.var", "true", "Show local function variables in disassembly"); SETBPREF ("asm.var.access", "false", "Show accesses of local variables"); - SETBPREF ("asm.var.sub", "true", "Substitute variables in disassembly"); + SETBPREF ("asm.sub.var", "true", "Substitute variables in disassembly"); SETI ("asm.var.summary", 0, "Show variables summary instead of full list in disasm (0, 1, 2)"); SETBPREF ("asm.sub.varonly", "true", "Substitute the entire variable expression with the local variable name (e.g. [local10h] instead of [ebp+local10h])"); SETBPREF ("asm.sub.reg", "false", "Substitute register names with their associated role name (drp~=)"); diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index fddfcf0e98..3989a66786 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -1845,7 +1845,7 @@ static void core_anal_bytes(RCore *core, const ut8 *buf, int len, int nops, int } else if (fmt == 'j') { char strsub[128] = { 0 }; // pc+33 - r_parse_varsub (core->parser, NULL, + r_parse_subvar (core->parser, NULL, core->offset + idx, asmop.size, r_asm_op_get_asm (&asmop), strsub, sizeof (strsub)); @@ -1868,7 +1868,7 @@ static void core_anal_bytes(RCore *core, const ut8 *buf, int len, int nops, int { RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, addr, 0); if (fcn) { - r_parse_varsub (core->parser, fcn, addr, asmop.size, + r_parse_subvar (core->parser, fcn, addr, asmop.size, strsub, strsub, sizeof (strsub)); } } @@ -1995,7 +1995,7 @@ static void core_anal_bytes(RCore *core, const ut8 *buf, int len, int nops, int } } else { char disasm[128] = { 0 }; - r_parse_varsub (core->parser, NULL, + r_parse_subvar (core->parser, NULL, core->offset + idx, asmop.size, r_asm_op_get_asm (&asmop), disasm, sizeof (disasm)); @@ -2025,7 +2025,7 @@ static void core_anal_bytes(RCore *core, const ut8 *buf, int len, int nops, int { RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, addr, 0); if (fcn) { - r_parse_varsub (core->parser, fcn, addr, asmop.size, + r_parse_subvar (core->parser, fcn, addr, asmop.size, disasm, disasm, sizeof (disasm)); } } @@ -7466,7 +7466,7 @@ static char *get_buf_asm(RCore *core, ut64 from, ut64 addr, RAnalFunction *fcn, ut8 buf[12]; RAsmOp asmop = {0}; char *buf_asm = NULL; - bool asm_varsub = r_config_get_i (core->config, "asm.var.sub"); + bool asm_subvar = r_config_get_i (core->config, "asm.sub.var"); core->parser->pseudo = r_config_get_i (core->config, "asm.pseudo"); core->parser->subrel = r_config_get_i (core->config, "asm.sub.rel"); core->parser->localvar_only = r_config_get_i (core->config, "asm.sub.varonly"); @@ -7480,11 +7480,11 @@ static char *get_buf_asm(RCore *core, ut64 from, ut64 addr, RAnalFunction *fcn, int ba_len = r_strbuf_length (&asmop.buf_asm) + 128; char *ba = malloc (ba_len); strcpy (ba, r_strbuf_get (&asmop.buf_asm)); - if (asm_varsub) { + if (asm_subvar) { core->parser->get_ptr_at = r_anal_function_get_var_stackptr_at; core->parser->get_reg_at = r_anal_function_get_var_reg_at; core->parser->get_op_ireg = get_op_ireg; - r_parse_varsub (core->parser, fcn, addr, asmop.size, + r_parse_subvar (core->parser, fcn, addr, asmop.size, ba, ba, sizeof (asmop.buf_asm)); } RAnalHint *hint = r_anal_hint_get (core->anal, addr); diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 2f15277326..d1ef9cedc0 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -91,7 +91,7 @@ typedef struct { int filter; int interactive; bool subjmp; - bool varsub; + bool subvar; bool show_lines; bool show_lines_bb; bool show_lines_ret; @@ -633,7 +633,7 @@ static RDisasmState * ds_init(RCore *core) { ds->filter = r_config_get_i (core->config, "asm.filter"); ds->interactive = r_cons_is_interactive (); ds->subjmp = r_config_get_i (core->config, "asm.sub.jmp"); - ds->varsub = r_config_get_i (core->config, "asm.var.sub"); + ds->subvar = r_config_get_i (core->config, "asm.sub.var"); core->parser->subrel = r_config_get_i (core->config, "asm.sub.rel"); core->parser->subreg = r_config_get_i (core->config, "asm.sub.reg"); core->parser->localvar_only = r_config_get_i (core->config, "asm.sub.varonly"); @@ -1013,13 +1013,13 @@ static void ds_build_op_str(RDisasmState *ds, bool print_color) { && ds->analop.ptr != UT64_MAX) { core->parser->subrel_addr = ds->analop.ptr; } - if (ds->varsub && ds->opstr) { + if (ds->subvar && ds->opstr) { ut64 at = ds->vat; RAnalFunction *f = fcnIn (ds, at, R_ANAL_FCN_TYPE_NULL); core->parser->get_op_ireg = get_op_ireg; core->parser->get_ptr_at = get_ptr_at; core->parser->get_reg_at = get_reg_at; - r_parse_varsub (core->parser, f, at, ds->analop.size, + r_parse_subvar (core->parser, f, at, ds->analop.size, ds->opstr, ds->strsub, sizeof (ds->strsub)); if (*ds->strsub) { free (ds->opstr); @@ -1087,9 +1087,9 @@ static void ds_build_op_str(RDisasmState *ds, bool print_color) { r_parse_filter (core->parser, ds->vat, core->flags, ds->hint, asm_str, ds->str, sizeof (ds->str), core->print->big_endian); free (asm_str); - // varsub depends on filter - if (ds->varsub) { - // HACK to do varsub outside rparse becacuse the whole rparse api must be rewritten + // subvar depends on filter + if (ds->subvar) { + // HACK to do subvar outside rparse becacuse the whole rparse api must be rewritten char *ox = strstr (ds->str, "0x"); if (ox) { char *e = strchr (ox, ']'); @@ -6033,12 +6033,12 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte // f = r_anal_get_fcn_in (core->anal, at, f = fcnIn (ds, at, R_ANAL_FCN_TYPE_FCN | R_ANAL_FCN_TYPE_SYM | R_ANAL_FCN_TYPE_LOC); - if (ds->varsub && f) { + if (ds->subvar && f) { int ba_len = r_strbuf_length (&asmop.buf_asm) + 128; char *ba = malloc (ba_len); if (ba) { strcpy (ba, r_asm_op_get_asm (&asmop)); - r_parse_varsub (core->parser, f, at, ds->analop.size, + r_parse_subvar (core->parser, f, at, ds->analop.size, ba, ba, ba_len); r_asm_op_set_asm (&asmop, ba); free (ba); diff --git a/libr/include/r_parse.h b/libr/include/r_parse.h index 9058eedacb..0dcd4e92b1 100644 --- a/libr/include/r_parse.h +++ b/libr/include/r_parse.h @@ -48,7 +48,7 @@ typedef struct r_parse_plugin_t { int (*parse)(RParse *p, const char *data, char *str); bool (*assemble)(RParse *p, char *data, char *str); int (*filter)(RParse *p, ut64 addr, RFlag *f, char *data, char *str, int len, bool big_endian); - bool (*varsub)(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len); + bool (*subvar)(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len); int (*replace)(int argc, const char *argv[], char *newstr); } RParsePlugin; @@ -67,7 +67,7 @@ R_API bool r_parse_use(RParse *p, const char *name); R_API bool r_parse_parse(RParse *p, const char *data, char *str); R_API bool r_parse_assemble(RParse *p, char *data, char *str); // XXX deprecate, unused and probably useless, related to write-hack R_API bool r_parse_filter(RParse *p, ut64 addr, RFlag *f, RAnalHint *hint, char *data, char *str, int len, bool big_endian); -R_API bool r_parse_varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len); +R_API bool r_parse_subvar(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len); R_API char *r_parse_immtrim(char *opstr); /* c */ diff --git a/libr/parse/p/parse_arm_pseudo.c b/libr/parse/p/parse_arm_pseudo.c index 5cfa4acd7e..d0ef1c6f1d 100644 --- a/libr/parse/p/parse_arm_pseudo.c +++ b/libr/parse/p/parse_arm_pseudo.c @@ -325,7 +325,7 @@ static char *mount_oldstr(RParse* p, const char *reg, st64 delta, bool ucase) { return oldstr; } -static bool varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { +static bool subvar(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { RList *spargs = NULL; RList *bpargs = NULL; RListIter *iter; @@ -442,7 +442,7 @@ RParsePlugin r_parse_plugin_arm_pseudo = { .name = "arm.pseudo", .desc = "ARM/ARM64 pseudo syntax", .parse = parse, - .varsub = &varsub, + .subvar = &subvar, }; #ifndef R2_PLUGIN_INCORE diff --git a/libr/parse/p/parse_mips_pseudo.c b/libr/parse/p/parse_mips_pseudo.c index f26e0cbdd8..076806f7be 100644 --- a/libr/parse/p/parse_mips_pseudo.c +++ b/libr/parse/p/parse_mips_pseudo.c @@ -250,7 +250,7 @@ static int parse(RParse *p, const char *data, char *str) { return true; } -static bool varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { +static bool subvar(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { RListIter *iter; char *oldstr; char *tstr = strdup (data); @@ -372,7 +372,7 @@ RParsePlugin r_parse_plugin_mips_pseudo = { .init = NULL, .fini = NULL, .parse = parse, - .varsub = varsub, + .subvar = subvar, }; #ifndef R2_PLUGIN_INCORE diff --git a/libr/parse/p/parse_wasm_pseudo.c b/libr/parse/p/parse_wasm_pseudo.c index 42c34133cc..4ca9ae8a82 100644 --- a/libr/parse/p/parse_wasm_pseudo.c +++ b/libr/parse/p/parse_wasm_pseudo.c @@ -20,7 +20,7 @@ static char* get_fcn_name(RAnal *anal, ut32 fcn_id) { return s; } -static bool varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { +static bool subvar(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { char *fcn_name = NULL; str[0] = 0; if (!strncmp (data, "call ", 5)) { @@ -38,7 +38,7 @@ static bool varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data RParsePlugin r_parse_plugin_wasm_pseudo = { .name = "wasm.pseudo", .desc = "WASM pseudo syntax", - .varsub = &varsub, + .subvar = &subvar, }; #ifndef R2_PLUGIN_INCORE diff --git a/libr/parse/p/parse_x86_pseudo.c b/libr/parse/p/parse_x86_pseudo.c index 8f0b470983..e63c3f1017 100644 --- a/libr/parse/p/parse_x86_pseudo.c +++ b/libr/parse/p/parse_x86_pseudo.c @@ -344,7 +344,7 @@ static inline void mk_reg_str(const char *regname, int delta, bool sign, bool at r_strbuf_free (sb); } -static bool varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { +static bool subvar(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { RList *bpargs, *spargs; RAnal *anal = p->analb.anal; RListIter *bpargiter, *spiter; @@ -550,7 +550,7 @@ RParsePlugin r_parse_plugin_x86_pseudo = { .name = "x86.pseudo", .desc = "X86 pseudo syntax", .parse = &parse, - .varsub = &varsub, + .subvar = &subvar, }; #ifndef R2_PLUGIN_INCORE diff --git a/libr/parse/parse.c b/libr/parse/parse.c index 532fc9dbca..559d14907d 100644 --- a/libr/parse/parse.c +++ b/libr/parse/parse.c @@ -134,9 +134,9 @@ R_API char *r_parse_immtrim(char *opstr) { return opstr; } -R_API bool r_parse_varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { - if (p->cur && p->cur->varsub) { - return p->cur->varsub (p, f, addr, oplen, data, str, len); +R_API bool r_parse_subvar(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len) { + if (p->cur && p->cur->subvar) { + return p->cur->subvar (p, f, addr, oplen, data, str, len); } return false; } diff --git a/test/db/cmd/cmd_pd b/test/db/cmd/cmd_pd index e0cfd9cf1b..1652ecb6f2 100644 --- a/test/db/cmd/cmd_pd +++ b/test/db/cmd/cmd_pd @@ -2,9 +2,9 @@ NAME=pd varsub-issue FILE=bins/mach0/mac-ls2 CMDS=<