Skip to content

Commit

Permalink
Add asm.xrefs.fold to avoid gigantic graph nodes (#10243)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanpencil authored and radare committed Jun 2, 2018
1 parent e55d8ef commit 12cbb24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion libr/core/cconfig.c
Expand Up @@ -2425,7 +2425,8 @@ R_API int r_core_config_init(RCore *core) {
n = NODECB ("asm.os", R_SYS_OS, &cb_asmos);
SETDESC (n, "Select operating system (kernel)");
SETOPTIONS (n, "ios", "dos", "darwin", "linux", "freebsd", "openbsd", "netbsd", "windows", NULL);
SETI ("asm.maxrefs", 5, "Maximum number of xrefs to be displayed as list (use columns above)");
SETI ("asm.xrefs.fold", 5, "Maximum number of xrefs to be displayed as list (use columns above)");
SETI ("asm.xrefs.max", 20, "Maximum number of xrefs to be displayed without folding");
SETCB ("asm.invhex", "false", &cb_asm_invhex, "Show invalid instructions as hexadecimal numbers");
SETPREF ("asm.meta", "true", "Display the code/data/format conversions in disasm");
SETPREF ("asm.bytes", "true", "Display the bytes of each instruction");
Expand Down
10 changes: 6 additions & 4 deletions libr/core/disasm.c
Expand Up @@ -240,6 +240,7 @@ typedef struct {
const ut8 *buf;
int len;
int maxrefs;
int foldxrefs;
char *prev_ins;
bool prev_ins_eq;
int prev_ins_count;
Expand Down Expand Up @@ -596,7 +597,8 @@ static RDisasmState * ds_init(RCore *core) {
ds->show_vars = r_config_get_i (core->config, "asm.var");
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.maxrefs");
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->linesright = r_config_get_i (core->config, "asm.lines.right");
ds->show_indent = r_config_get_i (core->config, "asm.indent");
Expand Down Expand Up @@ -1147,18 +1149,18 @@ static void ds_show_xrefs(RDisasmState *ds) {
if (!xrefs) {
return;
}
if (ds->maxrefs < 1) {
if (r_list_length (xrefs) > ds->maxrefs) {
ds_pre_xrefs (ds, false);
ds_comment (ds, false, "%s; XREFS(%d)\n",
ds->show_color? ds->pal_comment: "",
r_list_length (xrefs));
r_list_free (xrefs);
return;
}
if (r_list_length (xrefs) > ds->maxrefs) {
} else if (r_list_length (xrefs) > ds->foldxrefs) {
int cols = r_cons_get_size (NULL);
cols -= 15;
cols /= 23;
cols = cols > 5 ? 5 : cols;
ds_pre_xrefs (ds, false);
ds_comment (ds, false, "%s; XREFS: ", ds->show_color? ds->pal_comment: "");
r_list_foreach (xrefs, iter, refi) {
Expand Down

0 comments on commit 12cbb24

Please sign in to comment.