Skip to content

Commit

Permalink
Add "save to file" to ag*w commands + colorize comments like ";arg1" (#…
Browse files Browse the repository at this point in the history
…10860)

* Colorize comments like ';arg1' as var type comments

* Choose path for saving dot graph

* Fixed ag? help

* Remove addr argument from most of ag* commands

* Fix: gcc warnings in r_core_graph_cmd + use vartype comments in cmd_type

Refactor: Move r_core_graph_cmd from cconfig.c to cmd_anal.c and make it static

Refactor: moved getViewerPath() to cmd_anal.c too

* Refactor: rename r_core_graph_cmd to graph_cmd

* Refactor: many small refactors of ag* commands in cmd_anal.c

Refactor: solve merge conflict in cconfig.c

Refactor: other small refactorings in cmd_anal.c

* Fix: wrong merge in cconfig.c and updated ag? help
  • Loading branch information
cyanpencil authored and XVilka committed Aug 4, 2018
1 parent ac04e2d commit c076e12
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 116 deletions.
2 changes: 1 addition & 1 deletion libr/anal/var.c
Expand Up @@ -703,7 +703,7 @@ R_API void extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int *reg_s
r_anal_var_link (anal, op->addr, op->var);
}
r_anal_var_access (anal, fcn->addr, 'r', 1, delta, 0, op->addr);
r_meta_set_string (anal, R_META_TYPE_COMMENT, op->addr, vname);
r_meta_set_string (anal, R_META_TYPE_VARTYPE, op->addr, vname);
free (vname);
}
if (op->dst && opdreg && !strcmp (opdreg, regname)) {
Expand Down
54 changes: 1 addition & 53 deletions libr/core/cconfig.c
Expand Up @@ -2271,58 +2271,6 @@ static int cb_dbgsnap(void *user, void *data) {
return true;
}

static char *getViewerPath() {
int i;
const char *viewers[] = {
#if __WINDOWS__
"explorer",
#else
"open",
"geeqie",
"gqview",
"eog",
"xdg-open",
#endif
NULL
};
for (i = 0; viewers[i]; i++) {
char *viewerPath = r_file_path (viewers[i]);
if (viewerPath && strcmp (viewerPath, viewers[i])) {
return viewerPath;
}
free (viewerPath);
}
return NULL;
}

R_API char* r_core_graph_cmd(RCore *core, char *r2_cmd) {
char *cmd = NULL;
char *xdotPath = r_file_path ("xdot");
const char *ext = r_config_get (core->config, "graph.extension");
if (r_file_exists (xdotPath)) {
cmd = r_str_newf ("%s > a.dot;!xdot a.dot", r2_cmd);
} else {
char *dotPath = r_file_path ("dot");
if (r_file_exists (dotPath)) {
R_FREE (dotPath);
char *viewer = getViewerPath();
if (viewer) {
cmd = r_str_newf ("%s > a.dot;!dot -T%s -oa.%s a.dot;!%s a.%s", r2_cmd, ext, ext, viewer, ext);
free (viewer);
} else {
eprintf ("Cannot find a valid picture viewer");
}
} else {
cmd = r_str_new ("agf");
}
free (dotPath);
}
free (xdotPath);
return cmd;
}



#define SLURP_LIMIT (10*1024*1024)
R_API int r_core_config_init(RCore *core) {
int i;
Expand Down Expand Up @@ -2841,7 +2789,7 @@ R_API int r_core_config_init(RCore *core) {
/* graph */
SETPREF ("graph.comments", "true", "Show disasm comments in graph");
SETPREF ("graph.cmtright", "false", "Show comments at right");
SETCB ("graph.extension", "gif", &cb_graphformat, "Graph extension when using 'w' format (png, jpg, pdf, ps, svg, json)");
SETCB ("graph.gv.format", "gif", &cb_graphformat, "Graph image extension when using 'w' format (png, jpg, pdf, ps, svg, json)");
SETPREF ("graph.refs", "false", "Graph references in callgraphs (.agc*;aggi)");
SETI ("graph.edges", 2, "0=no edges, 1=simple edges, 2=avoid collisions");
SETI ("graph.layout", 0, "Graph layout (0=vertical, 1=horizontal)");
Expand Down

0 comments on commit c076e12

Please sign in to comment.