Implement axq

This commit is contained in:
pancake 2017-06-17 02:48:25 +02:00
parent 1163e2518f
commit 33aab674f7
2 changed files with 35 additions and 0 deletions

View file

@ -188,6 +188,36 @@ static int xrefs_list_cb_rad(RAnal *anal, const char *k, const char *v) {
return 1;
}
static int xrefs_list_cb_quiet(RAnal *anal, const char *k, const char *v) {
ut64 dst, src = r_num_get (NULL, v);
if (!strncmp (k, "ref.", 4)) {
const char *p = r_str_rchr (k, NULL, '.');
if (p) {
dst = r_num_get (NULL, p + 1);
char * type = strchr (k, '.');
if (type) {
type ++;
type = strdup (type);
char *t = strchr (type, '.');
if (t) {
*t = ' ';
}
t = (char *)r_str_rchr (type, NULL, '.');
if (t) {
t = (char *)r_str_rchr (t, NULL, '.');
if (t) {
*t = 0;
anal->cb_printf ("0x%"PFMT64x" -> 0x%"PFMT64x" %s\n", src, dst, type);
}
}
free (type);
}
}
}
return 1;
}
static bool xrefs_list_cb_json(RAnal *anal, bool is_first, const char *k, const char *v) {
ut64 dst, src = r_num_get (NULL, v);
if (strlen (k) > 8) {
@ -217,6 +247,9 @@ R_API void r_anal_xrefs_list(RAnal *anal, int rad) {
case '*':
sdb_foreach (DB, (SdbForeachCallback)xrefs_list_cb_rad, anal);
break;
case 'q':
sdb_foreach (DB, (SdbForeachCallback)xrefs_list_cb_quiet, anal);
break;
case 'j':
{
anal->cb_printf ("{");

View file

@ -4004,6 +4004,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
"axC", " addr [at]", "add code call ref",
"axg", " addr", "show xrefs graph to reach current function",
"axd", " addr [at]", "add data ref",
"axq", "", "list refs in quiet/human-readable format",
"axj", "", "list refs in json format",
"axF", " [flg-glob]", "find data/code references of flags",
"axt", " [addr]", "find data/code references to this address",
@ -4067,6 +4068,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
break;
case '\0': // "ax"
case 'j': // "axj"
case 'q': // "axq"
case '*': // "ax*"
r_core_anal_ref_list (core, input[0]);
break;