Added the ability to go/seek in Visual Ascii Graph

Fix #2906 - Added the ability tu undo and redo in Visual Ascii Graph

updated agraph_refresh
This commit is contained in:
Álvaro Felipe Melchor 2015-07-25 17:22:43 +02:00 committed by Riccardo Schirone
parent af5d430396
commit c06dee984e
2 changed files with 40 additions and 9 deletions

View File

@ -1990,16 +1990,16 @@ static int agraph_refresh(struct agraph_refresh_data *grd) {
RCore *core = grd->core;
RAGraph *g = grd->g;
RAnalFunction **fcn = grd->fcn;
RAnalFunction *f;
/* allow to change the current function only during debugging */
if (g->is_instep && core->io->debug) {
RAnalFunction *f;
/* allow to change the current function during debugging */
if (g->is_instep && core->io->debug)
r_core_cmd0 (core, "sr pc");
f = r_anal_get_fcn_in (core->anal, core->offset, 0);
if (f && f != *fcn) {
*fcn = f;
g->need_reload_nodes = R_TRUE;
}
f = r_anal_get_fcn_in (core->anal, core->offset, 0);
if (f && f != *fcn) {
*fcn = f;
g->need_reload_nodes = R_TRUE;
}
return agraph_print (g, grd->fs, core, *fcn);
@ -2218,6 +2218,16 @@ R_API RAGraph *r_agraph_new(RConsCanvas *can) {
return g;
}
static void visual_offset (RCore *core) {
char buf[256];
r_line_set_prompt ("[offset]> ");
strcpy (buf, "s ");
if (r_cons_fgets (buf+2, sizeof (buf)-3, 0, NULL) >0) {
if (buf[2]=='.')buf[1]='.';
r_core_cmd0 (core, buf);
}
}
R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn, int is_interactive) {
int exit_graph = R_FALSE, is_error = R_FALSE;
struct agraph_refresh_data *grd;
@ -2368,6 +2378,8 @@ R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn, int is_interacti
" O - toggle disasm mode\n"
" r - relayout\n"
" R - randomize colors\n"
" o - go/seek to given offset\n"
" U/b - undo/redo seek\n"
" p - toggle mini-graph\n"
" u - select previous node\n"
" V - toggle basicblock / call graphs\n"
@ -2378,6 +2390,25 @@ R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn, int is_interacti
r_cons_flush ();
r_cons_any_key (NULL);
break;
case 'o':
visual_offset (core);
break;
case 'U':
{
ut64 off = r_io_sundo (core->io, core->offset);
if (off != UT64_MAX){
r_core_seek (core, off, 1);
} else eprintf ("Can not undo\n");
}
break;
case 'b':
{
ut64 off = r_io_sundo_redo (core->io);
if (off != UT64_MAX){
r_core_seek (core,off, 1);
} else eprintf ("Can not redo\n");
break;
}
case 'R':
r_core_cmd0 (core, "ecr");
g->color_box = core->cons->pal.graph_box;

View File

@ -1,6 +1,6 @@
/* radare - LGPL - Copyright 2009-2015 - pancake */
#include "r_core.h"
#include <r_core.h>
#define NPF 7
static int blocksize = 0;