Skip to content
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 "save to file" to ag*w commands + colorize comments like ";arg1" #10860

Merged
merged 8 commits into from Aug 4, 2018
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 @@ -2840,7 +2788,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