Skip to content

Commit

Permalink
Added ag autocompletion + final ag* fixes (#10187)
Browse files Browse the repository at this point in the history
* Added ag autocompletion + shortcuts hidden when graph not interactive
* Renamed command 'agt' to 'abt'
  • Loading branch information
cyanpencil authored and XVilka committed May 28, 2018
1 parent 8a76561 commit 80c92bd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
31 changes: 15 additions & 16 deletions libr/core/cmd_anal.c
Expand Up @@ -9,6 +9,7 @@ static const char *help_msg_a[] = {
"a8", " [hexpairs]", "analyze bytes",
"ab", "[b] [addr]", "analyze block at given address",
"abb", " [len]", "analyze N basic blocks in [len] (section.size by default)",
"abt", " [addr]", "find paths in the bb function graph from current offset to given address",
"ac", " [cycles]", "analyze which op could be executed in [cycles]",
"ad", "[?]", "analyze data trampoline (wip)",
"ad", " [from] [to]", "analyze data pointers to (from-to)",
Expand Down Expand Up @@ -5800,7 +5801,6 @@ static void cmd_agraph_print(RCore *core, const char *input) {
}

static void cmd_anal_graph(RCore *core, const char *input) {
RList *list;
switch (input[0]) {
case 'f': // "agf"
switch (input[1]) {
Expand Down Expand Up @@ -5898,21 +5898,6 @@ static void cmd_anal_graph(RCore *core, const char *input) {
case 's': // "ags"
r_core_anal_graph (core, r_num_math (core->num, input + 1), 0);
break;
case 't': // "agt"
list = r_core_anal_graph_to (core, r_num_math (core->num, input + 1), 0);
if (list) {
RListIter *iter, *iter2;
RList *list2;
RAnalBlock *bb;
r_list_foreach (list, iter, list2) {
r_list_foreach (list2, iter2, bb) {
r_cons_printf ("-> 0x%08" PFMT64x "\n", bb->addr);
}
}
r_list_purge (list);
free (list);
}
break;
case 'C': // "agC"
switch (input[1]) {
case 'v':
Expand Down Expand Up @@ -6930,6 +6915,20 @@ static int cmd_anal(void *data, const char *input) {
core_anal_bbs (core, input + 2);
} else if (input[1] == 'r') { // "abr"
core_anal_bbs_range (core, input + 2);
} else if (input[1] == 't') {
RList* list = r_core_anal_graph_to (core, r_num_math (core->num, input + 2), 0);
if (list) {
RListIter *iter, *iter2;
RList *list2;
RAnalBlock *bb;
r_list_foreach (list, iter, list2) {
r_list_foreach (list2, iter2, bb) {
r_cons_printf ("-> 0x%08" PFMT64x "\n", bb->addr);
}
}
r_list_purge (list);
free (list);
}
} else if (input[1] == ' ' || !input[1]) {
// find block
ut64 addr = core->offset;
Expand Down
7 changes: 3 additions & 4 deletions libr/core/core.c
Expand Up @@ -1232,16 +1232,15 @@ static int autocomplete(RLine *line) {
|| !strncmp (line->buffer.data, "afc ", 4)
|| !strncmp (line->buffer.data, "axt ", 4)
|| !strncmp (line->buffer.data, "axf ", 4)
|| !strncmp (line->buffer.data, "aga ", 4)
|| !strncmp (line->buffer.data, "agc ", 4)
|| !strncmp (line->buffer.data, "agl ", 4)
|| !strncmp (line->buffer.data, "agd ", 4)
|| !strncmp (line->buffer.data, "dcu ", 4)
|| !strncmp (line->buffer.data, "/re ", 4)
|| !strncmp (line->buffer.data, "agfl ", 5)
|| !strncmp (line->buffer.data, "aecu ", 5)
|| !strncmp (line->buffer.data, "aesu ", 5)
|| !strncmp (line->buffer.data, "aeim ", 5)
|| (!strncmp (line->buffer.data, "ag", 2)
&& (strlen (line->buffer.data) > 4 && line->buffer.data[4] == ' '
|| strlen (line->buffer.data) > 3 && line->buffer.data[3] == ' '))
|| line->offset_prompt) {
int n, i = 0;
int sdelta = line->offset_prompt
Expand Down
3 changes: 2 additions & 1 deletion libr/core/graph.c
Expand Up @@ -2131,7 +2131,7 @@ static int get_bbnodes(RAGraph *g, RCore *core, RAnalFunction *fcn) {
char *title = get_title (bb->addr);

RANode *node = r_agraph_add_node (g, title, body);
shortcuts = r_config_get_i (core->config, "graph.nodejmps");
shortcuts = g->is_interactive ? r_config_get_i (core->config, "graph.nodejmps") : false;

if (shortcuts) {
shortcut = r_core_add_asmqjmp (core, bb->addr);
Expand Down Expand Up @@ -3709,6 +3709,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
g->on_curnode_change = (RANodeCallback) seek_to_node;
g->on_curnode_change_data = core;
g->edgemode = r_config_get_i (core->config, "graph.edges");
g->is_interactive = is_interactive;
bool asm_comments = r_config_get_i (core->config, "asm.comments");
r_config_set (core->config, "asm.comments",
r_str_bool (r_config_get_i (core->config, "graph.comments")));
Expand Down
1 change: 1 addition & 0 deletions libr/include/r_cons.h
Expand Up @@ -891,6 +891,7 @@ typedef struct r_ascii_graph_t {
int edgemode;
int mode;
bool is_callgraph;
bool is_interactive;
int zoom;
int movspeed;

Expand Down

0 comments on commit 80c92bd

Please sign in to comment.