Enhance Vx - visual xrefs browser, with more highlight and less glitches

This commit is contained in:
pancake 2017-02-08 12:14:52 +01:00
parent 5f6bb5c531
commit b7396fffa5
2 changed files with 73 additions and 63 deletions

View File

@ -2450,7 +2450,7 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
break;
}
break;
case ' ':
case ' ': // "db"
for (p = input + 1; *p == ' '; p++);
if (*p == '-') {
r_bp_del (core->dbg->bp, r_num_math (core->num, p + 1));

View File

@ -734,34 +734,22 @@ repeat:
r_cons_any_key (NULL);
r_cons_clear00 ();
} else {
int maxcount = 9;
int rows, cols = r_cons_get_size (&rows);
idx = 0;
count = 0;
char *dis = NULL;
rows -= 3;
// int maxcount = rows > 20 ? 9: 4;
int maxcount = cols < 90 ? 4: 9;
if (cols > 90) {
r_list_foreach (xrefs, iter, refi) {
if (idx == skip) {
char *dis = r_core_cmd_strf (core, "pd $r-10 @ 0x%08"PFMT64x, refi->addr);
char *d = r_str_ansi_crop (dis, 0, 0, cols - 50, rows - 3);
r_cons_printf ("%s", d);
r_cons_column (50);
free (d);
free (dis);
r_cons_gotoxy (1, 1);
r_cons_printf ("[GOTO XREF]> 0x%08"PFMT64x"\n", addr);
break;
}
idx ++;
}
}
idx = 0;
ut64 curat = UT64_MAX;
r_list_foreach (xrefs, iter, refi) {
if (idx - skip > maxcount) {
r_cons_printf ("...\n");
r_cons_printf ("...");
break;
}
if (!iter->n && idx < skip) {
skip = idx;
}
if (idx >= skip) {
if (count > maxcount) {
strcpy (cstr, "?");
@ -787,21 +775,43 @@ repeat:
name);
free (name);
if (idx == skip) {
if (cols <= 90) {
char *dis = r_core_cmd_strf (core, "pd $r-5 @ 0x%08"PFMT64x, refi->addr);
char *d = r_str_ansi_crop (dis, 0, 0, cols, rows - 5);
r_cons_printf ("%s", d);
free (d);
free (dis);
}
curat = refi->addr;
// TODO: show disasm with context. not seek addr
// dis = r_core_cmd_strf (core, "pd $r-4 @ 0x%08"PFMT64x, refi->addr);
dis = r_core_cmd_strf (core, "pd $r-4 @ 0x%08"PFMT64x, refi->addr - 32);
}
if (++count >= rows) {
r_cons_printf ("...\n");
r_cons_printf ("...");
break;
}
}
idx++;
}
if (dis) {
if (count < rows) {
r_cons_newline ();
}
int i = count;
for (; i < 10; i++) {
r_cons_newline ();
}
/* prepare highlight */
char *cmd = strdup (r_config_get (core->config, "scr.highlight"));
char *ats = r_str_newf ("%"PFMT64x, curat);
r_config_set (core->config, "scr.highlight", ats);
/* print disasm */
char *d = r_str_ansi_crop (dis, 0, 0, cols, rows - 9);
r_cons_printf ("%s", d);
free (d);
/* flush and restore highlight */
r_cons_flush ();
r_config_set (core->config, "scr.highlight", cmd);
free (ats);
free (cmd);
free (dis);
dis = NULL;
}
}
r_config_set_i (core->config, "asm.bytes", asm_bytes);
} else {