Fix #12202 - Add asm.maxflags to specify how many flags per offset we want to see ##disasm (#12283)

This commit is contained in:
radare 2018-11-22 21:21:39 +01:00 committed by GitHub
parent d0e6a692cb
commit 9279231918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -2580,6 +2580,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("asm.lines.right", "false", "Show lines before opcode instead of offset");
SETPREF ("asm.lines.wide", "false", "Put a space between lines");
SETICB ("asm.lines.width", 7, &cb_asmlineswidth, "Number of columns for program flow arrows");
SETI ("asm.maxflags", 0, "Maximum number of flags to show in a single offset");
SETICB ("asm.var.submin", 0x100, &cb_asmvarsubmin, "Minimum value to substitute in instructions (asm.var.sub)");
SETCB ("asm.tailsub", "false", &cb_asmtailsub, "Replace addresses with prefix .. syntax");
SETPREF ("asm.middle", "false", "Allow disassembling jumps in the middle of an instruction");

View File

@ -274,6 +274,7 @@ typedef struct {
bool use_json;
bool first_line;
const char *strip;
int maxflags;
} RDisasmState;
static void ds_setup_print_pre(RDisasmState *ds, bool tail, bool middle);
@ -606,6 +607,7 @@ static RDisasmState * ds_init(RCore *core) {
ds->show_varsum = r_config_get_i (core->config, "asm.var.summary");
ds->show_varaccess = r_config_get_i (core->config, "asm.var.access");
ds->maxrefs = r_config_get_i (core->config, "asm.xrefs.max");
ds->maxflags = r_config_get_i (core->config, "asm.maxflags");
ds->foldxrefs = r_config_get_i (core->config, "asm.xrefs.fold");
ds->show_lines = r_config_get_i (core->config, "asm.lines");
ds->show_lines_bb = ds->show_lines ? r_config_get_i (core->config, "asm.lines.bb") : false;
@ -2011,11 +2013,19 @@ static void ds_show_flags(RDisasmState *ds) {
f = fcnIn (ds, ds->at, R_ANAL_FCN_TYPE_NULL);
const RList *flaglist = r_flag_get_list (core->flags, ds->at);
RList *uniqlist = flaglist? r_list_uniq (flaglist, flagCmp): NULL;
int count = 0;
r_list_foreach (uniqlist, iter, flag) {
if (f && f->addr == flag->offset && !strcmp (flag->name, f->name)) {
// do not show flags that have the same name as the function
continue;
}
bool no_fcn_lines = (f && f->addr == flag->offset);
if (ds->maxflags && count >= ds->maxflags) {
ds_pre_xrefs (ds, no_fcn_lines);
r_cons_printf ("...\n");
break;
}
count++;
if (!strncmp (flag->name, "case.", 5)) {
sscanf (flag->name + 5, "%63[^.].%d", addr, &case_current);
ut64 saddr = r_num_math (core->num, addr);
@ -2034,7 +2044,6 @@ static void ds_show_flags(RDisasmState *ds) {
}
ds_begin_json_line (ds);
bool fake_flag_marks = (!ds->show_offset && ds->show_marks);
if (ds->show_flgoff) {
ds_beginline (ds);
@ -2043,7 +2052,6 @@ static void ds_show_flags(RDisasmState *ds) {
r_cons_printf (" ");
}
} else {
bool no_fcn_lines = (f && f->addr == flag->offset);
ds_pre_xrefs (ds, no_fcn_lines);
}