Skip to content

Commit

Permalink
Add asm.lines.jmp and make asm.lines config var for all lines (#1…
Browse files Browse the repository at this point in the history
…0254)

* First substition asm.lines with asm.lines.jmp
* ds->show_lines with ds->show_lines_jmp
* revert wrong substitutions
* rename asm.lines.jmp to asm.lines.bb
  • Loading branch information
cyanpencil authored and radare committed Jun 4, 2018
1 parent 4e25681 commit b119dad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions libr/core/cconfig.c
Expand Up @@ -2477,6 +2477,7 @@ R_API int r_core_config_init(RCore *core) {
SETDESC (n, "Realign disassembly if there is a flag in the middle of an instruction");
SETPREF ("asm.lbytes", "true", "Align disasm bytes to left");
SETPREF ("asm.lines", "true", "Show ASCII-art lines at disassembly");
SETPREF ("asm.lines.bb", "true", "Show flow lines at jumps");
SETPREF ("asm.lines.call", "false", "Enable call lines");
SETPREF ("asm.lines.ret", "false", "Show separator lines after ret");
SETPREF ("asm.lines.out", "true", "Show out of block lines");
Expand Down
6 changes: 3 additions & 3 deletions libr/core/cmd_print.c
Expand Up @@ -3292,7 +3292,7 @@ static void func_walk_blocks(RCore *core, RAnalFunction *f, char input, char typ
}
r_cons_print ("]");
} else {
bool asm_lines = r_config_get_i (core->config, "asm.lines");
bool asm_lines = r_config_get_i (core->config, "asm.lines.bb");
bool emu = r_config_get_i (core->config, "asm.emu");
ut64 saved_gp = 0;
ut8 *saved_arena = NULL;
Expand All @@ -3301,7 +3301,7 @@ static void func_walk_blocks(RCore *core, RAnalFunction *f, char input, char typ
saved_gp = core->anal->gp;
saved_arena = r_reg_arena_peek (core->anal->reg);
}
r_config_set_i (core->config, "asm.lines", 0);
r_config_set_i (core->config, "asm.lines.bb", 0);
for (; locs_it && (tmp_func = locs_it->data); locs_it = locs_it->n) {
if (tmp_func->addr >= f->addr) {
break;
Expand Down Expand Up @@ -3330,7 +3330,7 @@ static void func_walk_blocks(RCore *core, RAnalFunction *f, char input, char typ
}
}
core->anal->stackptr = saved_stackptr;
r_config_set_i (core->config, "asm.lines", asm_lines);
r_config_set_i (core->config, "asm.lines.bb", asm_lines);
}
}

Expand Down
22 changes: 12 additions & 10 deletions libr/core/disasm.c
Expand Up @@ -95,6 +95,7 @@ typedef struct {
bool jmpsub;
bool varsub;
bool show_lines;
bool show_lines_bb;
bool show_lines_ret;
bool show_lines_call;
int linesright;
Expand Down Expand Up @@ -600,6 +601,7 @@ static RDisasmState * ds_init(RCore *core) {
ds->maxrefs = r_config_get_i (core->config, "asm.xrefs.max");
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;
ds->linesright = r_config_get_i (core->config, "asm.lines.right");
ds->show_indent = r_config_get_i (core->config, "asm.indent");
ds->indent_space = r_config_get_i (core->config, "asm.indentspace");
Expand All @@ -608,8 +610,8 @@ static RDisasmState * ds_init(RCore *core) {
ds->show_dwarf = r_config_get_i (core->config, "asm.dwarf");
ds->dwarfFile = r_config_get_i (ds->core->config, "asm.dwarf.file");
ds->dwarfAbspath = r_config_get_i (ds->core->config, "asm.dwarf.abspath");
ds->show_lines_call = r_config_get_i (core->config, "asm.lines.call");
ds->show_lines_ret = r_config_get_i (core->config, "asm.lines.ret");
ds->show_lines_call = ds->show_lines ? r_config_get_i (core->config, "asm.lines.call") : false;
ds->show_lines_ret = ds->show_lines ? r_config_get_i (core->config, "asm.lines.ret") : false;
ds->show_size = r_config_get_i (core->config, "asm.size");
ds->show_trace = r_config_get_i (core->config, "asm.trace");
ds->linesout = r_config_get_i (core->config, "asm.lines.out");
Expand Down Expand Up @@ -655,7 +657,7 @@ static RDisasmState * ds_init(RCore *core) {
ds->asm_meta = r_config_get_i (core->config, "asm.meta");
ds->show_reloff = r_config_get_i (core->config, "asm.reloff");
ds->show_reloff_flags = r_config_get_i (core->config, "asm.reloff.flags");
ds->show_lines_fcn = r_config_get_i (core->config, "asm.lines.fcn");
ds->show_lines_fcn = ds->show_lines ? r_config_get_i (core->config, "asm.lines.fcn") : false;
ds->show_comments = r_config_get_i (core->config, "asm.comments");
ds->show_jmphints = r_config_get_i (core->config, "asm.jmphints");
ds->show_leahints = r_config_get_i (core->config, "asm.leahints");
Expand Down Expand Up @@ -724,7 +726,7 @@ static RDisasmState * ds_init(RCore *core) {
ds->linesopts |= R_ANAL_REFLINE_TYPE_UTF8;
}
}
if (ds->show_lines) {
if (ds->show_lines_bb) {
ds->ocols += 10; // XXX
}
if (ds->show_offset) {
Expand Down Expand Up @@ -779,7 +781,7 @@ static void ds_reflines_init(RDisasmState *ds) {

lastaddr = UT64_MAX;

if (ds->show_lines) {
if (ds->show_lines_bb) {
ds_reflines_fini (ds);
anal->reflines = r_anal_reflines_get (anal,
ds->addr, ds->buf, ds->len, ds->l,
Expand All @@ -797,7 +799,7 @@ static void ds_reflines_init(RDisasmState *ds) {
static void ds_reflines_fcn_init(RDisasmState *ds, RAnalFunction *fcn, const ut8* buf) {
RCore *core = ds->core;
RAnal *anal = core->anal;
if (ds->show_lines) {
if (ds->show_lines_bb) {
// TODO: make anal->reflines implicit
free (anal->reflines); // TODO: leak
anal->reflines = r_anal_reflines_fcn_get (anal, fcn, -1, ds->linesout, ds->show_lines_call);
Expand Down Expand Up @@ -1895,7 +1897,7 @@ static void ds_show_flags(RDisasmState *ds) {
}

static void ds_update_ref_lines(RDisasmState *ds) {
if (ds->show_lines) {
if (ds->show_lines_bb) {
ds->line = r_anal_reflines_str (ds->core, ds->at, ds->linesopts);
free (ds->refline);
ds->refline = ds->line? strdup (ds->line): NULL;
Expand Down Expand Up @@ -2114,7 +2116,7 @@ static void ds_control_flow_comments(RDisasmState *ds) {
}

static void ds_print_lines_right(RDisasmState *ds){
if (ds->linesright && ds->show_lines && ds->line) {
if (ds->linesright && ds->show_lines_bb && ds->line) {
r_cons_printf ("%s%s%s", COLOR (ds, color_flow), ds->line, COLOR_RESET (ds));
}
}
Expand Down Expand Up @@ -2188,7 +2190,7 @@ static void ds_print_lines_left(RDisasmState *ds) {
}
if (ds->line) {
if (ds->show_color) {
if (!ds->linesright && ds->show_lines) {
if (!ds->linesright && ds->show_lines_bb) {
r_cons_printf ("%s%s%s", COLOR (ds, color_flow), ds->line, COLOR_RESET (ds));
}
} else {
Expand Down Expand Up @@ -3886,7 +3888,7 @@ static void ds_print_bbline(RDisasmState *ds, bool force) {
ds_begin_json_line (ds);
ds_setup_print_pre (ds, false, false);
ds_update_ref_lines (ds);
if (!ds->linesright && ds->show_lines && ds->line) {
if (!ds->linesright && ds->show_lines_bb && ds->line) {
r_cons_printf ("%s%s%s", COLOR (ds, color_flow),
ds->refline2, COLOR_RESET (ds));
}
Expand Down
3 changes: 1 addition & 2 deletions libr/core/graph.c
Expand Up @@ -1950,7 +1950,7 @@ static char *get_body(RCore *core, ut64 addr, int size, int opts) {
if (!hc) {
return NULL;
}
r_config_save_num (hc, "asm.lines.fcn", "asm.lines", "asm.bytes",
r_config_save_num (hc, "asm.lines", "asm.bytes",
"asm.cmt.col", "asm.marks", "asm.marks", "asm.offset",
"asm.comments", "asm.cmt.right", NULL);
const bool o_comments = r_config_get_i (core->config, "graph.comments");
Expand All @@ -1961,7 +1961,6 @@ static char *get_body(RCore *core, ut64 addr, int size, int opts) {
const char *cmd = (opts & BODY_SUMMARY)? "pds": "pD";

// configure options
r_config_set_i (core->config, "asm.lines.fcn", false);
r_config_set_i (core->config, "asm.lines", false);
r_config_set_i (core->config, "asm.cmt.col", 0);
r_config_set_i (core->config, "asm.marks", false);
Expand Down

0 comments on commit b119dad

Please sign in to comment.