Some more improvements for the visual xrefs (fix undo seek and more)

This commit is contained in:
pancake 2018-12-03 16:36:26 +01:00
parent df90a3c462
commit 30c26ec104
2 changed files with 22 additions and 21 deletions

View File

@ -2710,12 +2710,12 @@ R_API int r_core_block_size(RCore *core, int bsize) {
}
R_API int r_core_seek_align(RCore *core, ut64 align, int times) {
int diff, inc = (times >= 0)? 1: -1;
int inc = (times >= 0)? 1: -1;
ut64 seek = core->offset;
if (!align) {
return false;
}
diff = core->offset%align;
int diff = core->offset % align;
if (!times) {
diff = -diff;
} else if (diff) {
@ -2730,12 +2730,12 @@ R_API int r_core_seek_align(RCore *core, ut64 align, int times) {
}
while ((times*inc) > 0) {
times -= inc;
diff += align*inc;
diff += (align * inc);
}
if (diff < 0 && -diff > seek) {
seek = diff = 0;
}
return r_core_seek (core, seek+diff, 1);
return r_core_seek (core, seek + diff, 1);
}
R_API char *r_core_op_str(RCore *core, ut64 addr) {

View File

@ -1028,14 +1028,15 @@ static int prevopsz(RCore *core, ut64 addr) {
return addr - prev_addr;
}
static int follow_ref(RCore *core, RList *xrefs, int choice) {
static int follow_ref(RCore *core, RList *xrefs, int choice, int xref) {
RAnalRef *refi = r_list_get_n (xrefs, choice);
if (refi) {
if (core->print->cur_enabled) {
core->print->cur = 0;
}
r_io_sundo_push (core->io, refi->addr, r_print_get_cursor (core->print));
r_core_seek (core, refi->addr, 1);
r_io_sundo_push (core->io, core->offset, -1);
ut64 addr = xref? refi->at: refi->addr;
r_core_seek (core, addr, true);
return 1;
}
return 0;
@ -1064,18 +1065,18 @@ repeat:
if (xrefsMode) {
RAnalFunction *fun = r_anal_get_fcn_in (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
if (fun) {
if (xref) {
if (xref) { // function xrefs
xrefs = r_anal_fcn_get_xrefs (core->anal, fun);
} else {
} else { // functon refs
xrefs = r_anal_fcn_get_refs (core->anal, fun);
}
} else {
xrefs = NULL;
}
} else {
if (xref) {
if (xref) { // address xrefs
xrefs = r_anal_xrefs_get (core->anal, addr);
} else {
} else { // address refs
xrefs = r_anal_refs_get (core->anal, addr);
}
}
@ -1214,6 +1215,7 @@ repeat:
ch = r_cons_arrow_to_hjkl (ch);
if (ch == ':') {
r_core_visual_prompt_input (core);
goto repeat;
} else if (ch == '?') {
r_cons_clear00 ();
r_cons_printf ("Usage: Visual Xrefs\n"
@ -1230,12 +1232,6 @@ repeat:
r_cons_flush ();
r_cons_any_key (NULL);
goto repeat;
} else if (ch == '<') {
xrefsMode = false;
goto repeat;
} else if (ch == '>') {
xrefsMode = true;
goto repeat;
} else if (ch == 9) { // TAB
xrefsMode = !xrefsMode;
goto repeat;
@ -1251,11 +1247,13 @@ repeat:
printMode = lastPrintMode;
}
goto repeat;
} else if (ch == 'x') {
} else if (ch == 'x' || ch == '<') {
xrefsMode = !xrefsMode;
xref = true;
goto repeat;
} else if (ch == 'X') {
} else if (ch == 'X' || ch == '>') {
xref = false;
xrefsMode = !xrefsMode;
goto repeat;
} else if (ch == 'J') {
skip += 10;
@ -1266,6 +1264,9 @@ repeat:
} else if (ch == 'G') {
skip = 9999;
goto repeat;
} else if (ch == '.') {
skip = 0;
goto repeat;
} else if (ch == 'j') {
skip++;
goto repeat;
@ -1279,9 +1280,9 @@ repeat:
}
goto repeat;
} else if (ch == ' ' || ch == '\n' || ch == '\r' || ch == 'l') {
ret = follow_ref (core, xrefs, skip);
ret = follow_ref (core, xrefs, skip, xref);
} else if (IS_DIGIT (ch)) {
ret = follow_ref (core, xrefs, ch - 0x30);
ret = follow_ref (core, xrefs, ch - 0x30, xref);
} else if (ch != 'q' && ch != 'Q' && ch != 'h') {
goto repeat;
}