New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add import graph (agi) + new ag? help #10132
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ static const char *help_msg_a[] = { | |
"ae", "[?] [expr]", "analyze opcode eval expression (see ao)", | ||
"af", "[?]", "analyze Functions", | ||
"aF", "", "same as above, but using anal.depth=1", | ||
"ag", "[?] [options]", "output Graphviz code", | ||
"ag", "[?] [options]", "draw graphs in various formats", | ||
"ah", "[?]", "analysis hints (force opcode size, ...)", | ||
"ai", " [addr]", "address information (show perms, stack, heap, ...)", | ||
"an"," [name] [@addr]","show/rename/create whatever flag/function is used at addr", | ||
|
@@ -379,26 +379,32 @@ static const char *help_msg_afvs[] = { | |
}; | ||
|
||
static const char *help_msg_ag[] = { | ||
"Usage:", "ag[?f]", " Graphviz/graph code", | ||
"ag", " [addr]", "output graphviz code (bb at addr and children)", | ||
"ag-", "", "Reset the current ASCII art graph (see agn, age, agg?)", | ||
"aga", " [addr]", "idem, but only addresses", | ||
"agr", "[j] [addr]", "output graphviz call graph of function", | ||
"agg", "", "display current graph created with agn and age (see also ag-)", | ||
"agc", "[*j] [addr]", "output graphviz call graph of function", | ||
"agC", "[j]", "Same as agc -1. full program callgraph", | ||
"agd", " [fcn name]", "output graphviz code of diffed function", | ||
"age", "[?] title1 title2", "Add an edge to the current graph", | ||
"agf", " [addr]", "Show ASCII art graph of given function", | ||
"agg", "[?] [kdi*]", "Print graph in ASCII-Art, graphviz, k=v, r2 or visual", | ||
"agj", " [addr]", "idem, but in JSON format", | ||
"agJ", " [addr]", "idem, but in JSON format with formatted disassembly (like pdJ)", | ||
"agk", " [addr]", "idem, but in SDB key-value format", | ||
"agl", " [fcn name]", "output graphviz code using meta-data", | ||
"agn", "[?] title body", "Add a node to the current graph", | ||
"ags", " [addr]", "output simple graphviz call graph of function (only bb offset)", | ||
"agt", " [addr]", "find paths from current offset to given address", | ||
"agv", "", "Show function graph in web/png (see graph.web and cmd.graph) or agf for asciiart", | ||
"Usage:", "ag<graphtype><format> [addr]", "", | ||
"Graph types:", "", "", | ||
"c", " [fcn addr]", "Function callgraph", | ||
"f", " [fcn addr]", "Basic blocks function graph", | ||
"x", " [addr]", "Cross references graph", | ||
"r", " [fcn addr]", "References graph", | ||
"a", " [fcn addr]", "Data references graph", | ||
"d", " [fcn addr]", "Diff graph", | ||
"i", "", "Imports graph", | ||
"g", "", "Custom graph", | ||
"","","", | ||
"Output formats:", "", "", | ||
"<blank>", "", "Ascii art", | ||
"v", "", "Interactive ascii art", | ||
"t", "", "Tiny ascii art", | ||
"d", "", "Graphviz dot", | ||
"j", "", "json ('J' for formatted disassembly)", | ||
"g", "", "Graph Modelling Language (gml)", | ||
"k", "", "SDB key-value", | ||
"*", "", "r2 commands", | ||
"w", "", "Web/image (see graph.extension and graph.web)", | ||
"","","", | ||
"Custom graph commands:", "", "", | ||
"ag-", "", "Clear the custom graph", | ||
"agn", "[?] title body", "Add a node to the custom graph", | ||
"age", "[?] title1 title2", "Add an edge to the custom graph", | ||
NULL | ||
}; | ||
|
||
|
@@ -412,17 +418,6 @@ static const char *help_msg_age[] = { | |
NULL | ||
}; | ||
|
||
static const char *help_msg_agg[] = { | ||
"Usage:", "agg[kid?*]", "print graph", | ||
"agg", "", "show current graph in ascii art", | ||
"aggk", "", "show graph in key=value form", | ||
"aggi", "", "enter interactive mode for the current graph", | ||
"aggd", "", "print the current graph in GRAPHVIZ dot format", | ||
"aggv", "", "run graphviz + viewer (see 'e cmd.graph')", | ||
"agg*", "", "in r2 commands, to save in projects, etc", | ||
NULL | ||
}; | ||
|
||
static const char *help_msg_agn[] = { | ||
"Usage:", "agn [title] [body]", "", | ||
"Examples:", "", "", | ||
|
@@ -595,7 +590,6 @@ static void cmd_anal_init(RCore *core) { | |
DEFINE_CMD_DESCRIPTOR (core, afvs); | ||
DEFINE_CMD_DESCRIPTOR (core, ag); | ||
DEFINE_CMD_DESCRIPTOR (core, age); | ||
DEFINE_CMD_DESCRIPTOR (core, agg); | ||
DEFINE_CMD_DESCRIPTOR (core, agn); | ||
DEFINE_CMD_DESCRIPTOR (core, ah); | ||
DEFINE_CMD_DESCRIPTOR (core, ahi); | ||
|
@@ -5792,17 +5786,13 @@ static void cmd_agraph_print(RCore *core, const char *input) { | |
} | ||
break; | ||
} | ||
case '?': | ||
r_core_cmd_help (core, help_msg_agg); | ||
break; | ||
default: | ||
eprintf ("Usage: see ag?\n"); | ||
} | ||
} | ||
|
||
static void cmd_anal_graph(RCore *core, const char *input) { | ||
RList *list; | ||
const char *arg; | ||
switch (input[0]) { | ||
case 'f': // "agf" | ||
switch (input[1]) { | ||
|
@@ -5992,6 +5982,28 @@ static void cmd_anal_graph(RCore *core, const char *input) { | |
break; | ||
} | ||
break; | ||
case 'i': // agi "import graph" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put quotes around "agi", we use this to find where the commands are implemented by greeping for this expresssion which have very few false positives |
||
switch (input[1]) { | ||
case 'v': | ||
case 't': | ||
case 'd': | ||
case 'J': | ||
case 'j': | ||
case 'g': | ||
case 'k': | ||
case 'w': | ||
case ' ': | ||
case 0: | ||
r_core_cmdf (core, "ag-; .agi*; agg%c;", input[1]); | ||
break; | ||
case '*': | ||
r_core_anal_importxrefs (core); | ||
break; | ||
default: | ||
eprintf ("Usage: see ag?\n"); | ||
break; | ||
} | ||
break; | ||
case 'c': // "agc" | ||
switch (input[1]) { | ||
case 'v': | ||
|
@@ -6013,12 +6025,12 @@ static void cmd_anal_graph(RCore *core, const char *input) { | |
r_core_cmd0 (core, "ag-; .agc* $$; agg;"); | ||
break; | ||
case 'g': { | ||
ut64 addr = input[2]? r_num_math (core->num, input + 1): core->offset; | ||
ut64 addr = input[2] ? r_num_math (core->num, input + 2): core->offset; | ||
r_core_anal_callgraph (core, addr, R_GRAPH_FORMAT_GMLFCN); | ||
break; | ||
} | ||
case 'd': { | ||
ut64 addr = input[2]? r_num_math (core->num, input + 1): core->offset; | ||
ut64 addr = input[2] ? r_num_math (core->num, input + 2): core->offset; | ||
r_core_anal_callgraph (core, addr, R_GRAPH_FORMAT_DOT); | ||
break; | ||
} | ||
|
@@ -6114,23 +6126,14 @@ static void cmd_anal_graph(RCore *core, const char *input) { | |
} | ||
} | ||
break; | ||
case 'v': // "agv" | ||
if (r_config_get_i (core->config, "graph.web")) { | ||
r_core_cmd0 (core, "=H /graph/"); | ||
} else { | ||
const char *cmd = r_config_get (core->config, "cmd.graph"); | ||
if (cmd && *cmd) { | ||
r_core_cmd0 (core, cmd); | ||
} else { | ||
r_core_cmd0 (core, "agf"); | ||
} | ||
} | ||
case 'v': // "agv" alias for "agfv" | ||
r_core_cmdf (core, "agfv%s", input + 1); | ||
break; | ||
case 'w':// "agw" | ||
if (r_config_get_i (core->config, "graph.web")) { | ||
r_core_cmd0 (core, "=H /graph/"); | ||
} else { | ||
char *cmdargs = r_str_newf ("agfd %lld", r_num_math (core->num, input + 2)); | ||
char *cmdargs = r_str_newf ("agfd %lld", r_num_math (core->num, input + 1)); | ||
char *cmd = r_core_graph_cmd (core, cmdargs); | ||
if (cmd && *cmd) { | ||
r_core_cmd0 (core, cmd); | ||
|
@@ -6139,19 +6142,8 @@ static void cmd_anal_graph(RCore *core, const char *input) { | |
free (cmdargs); | ||
} | ||
break; | ||
case '?': // "ag?" | ||
r_core_cmd_help (core, help_msg_ag); | ||
break; | ||
case ' ': // "ag" | ||
arg = strchr (input, ' '); | ||
r_core_anal_graph (core, r_num_math (core->num, arg? arg + 1: NULL), | ||
R_CORE_ANAL_GRAPHBODY); | ||
break; | ||
case 0: | ||
eprintf ("|ERROR| Usage: ag [addr]\n"); | ||
break; | ||
default: | ||
eprintf ("See ag?\n"); | ||
r_core_cmd_help (core, help_msg_ag); | ||
break; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shuold put the whole command in here, otherwise it will break ?* to enumerate all recursive commands