Rename asm.var.sub to asm.sub.var ##cons (#17717)

* Rename `asm.var.sub` to `asm.sub.var`
* Rename tests for `asm.var.sub`
This commit is contained in:
Aswin C 2020-09-28 15:21:38 +05:30 committed by GitHub
parent 8fea09e21d
commit 45c0024300
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 40 deletions

View file

@ -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~=)");

View file

@ -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);

View file

@ -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);

View file

@ -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 */

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -2,9 +2,9 @@ NAME=pd varsub-issue
FILE=bins/mach0/mac-ls2
CMDS=<<EOF
s 0x100001232
e asm.var.sub=0
e asm.sub.var=0
pd 1
e asm.var.sub=1
e asm.sub.var=1
pd 1
f fin.dus=0x1000054d0
pd 1
@ -580,7 +580,7 @@ CMDS=<<EOF
e anal.vars.stackname=true
e asm.arch=x86
e asm.bits=64
e asm.var.sub=true
e asm.sub.var=true
e asm.lines.bb=false
e asm.bytes=false
e asm.comments=false
@ -1883,7 +1883,7 @@ EXPECT=<<EOF
EOF
RUN
NAME=arm asm.var.sub, asm.ucase and asm.pseudo (fp)
NAME=arm asm.sub.var, asm.ucase and asm.pseudo (fp)
FILE=bins/elf/analysis/armcall
CMDS=<<EOF
e asm.bytes=false
@ -1893,16 +1893,16 @@ wv4 0xe59b0008 @ 0x00010464
wv4 0xe59b100c @ 0x00010468
af @ main
e asm.pseudo=false
e asm.var.sub=true
e asm.sub.var=true
e asm.ucase=true
pd 4 @ 0x0001045c
?e
e asm.var.sub=false
e asm.sub.var=false
e asm.ucase=false
pd 4 @ 0x0001045c
?e
e asm.pseudo=true
e asm.var.sub=true
e asm.sub.var=true
e asm.sub.varonly=false
pd 4 @ 0x0001045c
?e

View file

@ -11,7 +11,7 @@ NAME=ELF: mipsbe-ubusd
FILE=bins/elf/analysis/mipsbe-ubusd
CMDS=<<EOF
af
e asm.var.sub=false
e asm.sub.var=false
pif
EOF
EXPECT=<<EOF
@ -40,7 +40,7 @@ NAME=ELF: mipsbe-busybox
FILE=bins/elf/analysis/mipsbe-busybox
CMDS=<<EOF
af
e asm.var.sub=false
e asm.sub.var=false
pif
EOF
EXPECT=<<EOF