Added asm.cmtoff to control showing of offset comment (#7609)

This commit is contained in:
Khairul Azhar Kasmiran 2017-05-29 08:44:45 +08:00 committed by radare
parent a5a6b25d27
commit 40f2126da6
2 changed files with 8 additions and 1 deletions

View File

@ -2037,6 +2037,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("asm.marks", "true", "Show marks before the disassembly");
SETPREF ("asm.cmtrefs", "false", "Show flag and comments from refs in disasm");
SETPREF ("asm.cmtpatch", "false", "Show patch comments in disasm");
SETPREF ("asm.cmtoff", "nodup", "Show offset comment in disasm (true, false, nodup)");
SETPREF ("asm.payloads", "false", "Show payload bytes in disasm");
SETCB ("bin.strpurge", "false", &cb_strpurge, "Try to purge false positive strings");
SETPREF ("bin.libs", "false", "Try to load libraries after loading main binary");

View File

@ -108,6 +108,7 @@ typedef struct r_disam_options_t {
bool show_stackptr;
bool show_xrefs;
bool show_cmtrefs;
const char *show_cmtoff;
bool show_functions;
bool show_fcncalls;
bool show_hints;
@ -481,6 +482,7 @@ static RDisasmState * ds_init(RCore *core) {
ds->show_xrefs = r_config_get_i (core->config, "asm.xrefs");
ds->show_cmtrefs = r_config_get_i (core->config, "asm.cmtrefs");
ds->cmtfold = r_config_get_i (core->config, "asm.cmtfold");
ds->show_cmtoff = r_config_get (core->config, "asm.cmtoff");
ds->show_functions = r_config_get_i (core->config, "asm.functions");
ds->show_fcncalls = r_config_get_i (core->config, "asm.fcncalls");
ds->nbytes = r_config_get_i (core->config, "asm.nbytes");
@ -2758,7 +2760,11 @@ static void ds_print_ptr(RDisasmState *ds, int len, int idx) {
refaddr_printed = true;
}
}
if (!refaddr_printed) {
if (!strcmp (ds->show_cmtoff, "true")) {
ALIGN;
ds_comment (ds, true, "; 0x%" PFMT64x "%s", refaddr, nl);
refaddr_printed = true;
} else if (!refaddr_printed && strcmp (ds->show_cmtoff, "false")) {
char addrstr[sizeof (refaddr) * 2 + 3];
snprintf (addrstr, sizeof (addrstr), "0x%" PFMT64x, refaddr);
if (!ds->opstr || !strstr (ds->opstr, addrstr)) {