Skip to content

Commit

Permalink
Add and handle graph.from and graph.to (Useful for ag)
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Dec 22, 2014
1 parent 78ba70e commit 2a95a1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions libr/core/anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,8 @@ R_API RList* r_core_anal_graph_to(RCore *core, ut64 addr, int n) {
}

R_API int r_core_anal_graph(RCore *core, ut64 addr, int opts) {
ut64 from = r_config_get_i (core->config, "graph.from");
ut64 to = r_config_get_i (core->config, "graph.to");
const char *font = r_config_get (core->config, "graph.font");
int is_html = r_cons_singleton ()->is_html;
int is_json = opts & R_CORE_ANAL_JSON;
Expand Down Expand Up @@ -1370,6 +1372,11 @@ R_API int r_core_anal_graph(RCore *core, ut64 addr, int opts) {
r_list_foreach (core->anal->fcns, iter, fcni) {
if (fcni->type & (R_ANAL_FCN_TYPE_SYM | R_ANAL_FCN_TYPE_FCN)
&& (addr == 0 || inrange (addr, fcni))) {
if (!addr && (from != UT64_MAX && to != UT64_MAX)) {
if (fcni->addr < from || fcni->addr > to) {
continue;
}
}
if (is_json && count++>0) r_cons_printf (",");
r_core_anal_graph_nodes (core, fcni, opts);
if (addr != 0) break;
Expand Down
4 changes: 2 additions & 2 deletions libr/core/cmd_anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2110,10 +2110,10 @@ static int cmd_anal(void *data, const char *input) {
}
break;
case 'g':
cmd_anal_graph(core, input+1);
cmd_anal_graph (core, input+1);
break;
case 't':
cmd_anal_trace(core, input+1);
cmd_anal_trace (core, input+1);
break;
case 's': // "as"
cmd_anal_syscall(core, input+1);
Expand Down
2 changes: 2 additions & 0 deletions libr/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,8 @@ R_API int r_core_config_init(RCore *core) {
SETPREF("graph.font", "Courier", "Font to be used by the dot graphs");
SETPREF("graph.offset", "false", "Show offsets in graphs");
SETPREF("graph.web", "false", "Display graph in web browser (VV)");
SETI("graph.from", UT64_MAX, "");
SETI("graph.to", UT64_MAX, "");

/* hud */
SETPREF("hud.path", "", "Set a custom path for the HUD file");
Expand Down

0 comments on commit 2a95a1e

Please sign in to comment.