mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-20 20:55:32 +00:00
Enhance ax, axk lists and axq is the old ax
This commit is contained in:
parent
47b20c3d5f
commit
637543c541
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2016 - pancake, nibble */
|
||||
/* radare - LGPL - Copyright 2009-2017 - pancake, nibble */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_cons.h>
|
||||
@ -196,8 +196,7 @@ static int xrefs_list_cb_quiet(RAnal *anal, const char *k, const char *v) {
|
||||
dst = r_num_get (NULL, p + 1);
|
||||
char * type = strchr (k, '.');
|
||||
if (type) {
|
||||
type ++;
|
||||
type = strdup (type);
|
||||
type = strdup (type + 1);
|
||||
char *t = strchr (type, '.');
|
||||
if (t) {
|
||||
*t = ' ';
|
||||
@ -212,7 +211,44 @@ static int xrefs_list_cb_quiet(RAnal *anal, const char *k, const char *v) {
|
||||
}
|
||||
free (type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int xrefs_list_cb_normal(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 = strdup (type + 1);
|
||||
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;
|
||||
char *name = anal->coreb.getNameDelta (anal->coreb.core, src);
|
||||
anal->cb_printf ("%40s", name? name: "");
|
||||
free (name);
|
||||
anal->cb_printf (" 0x%"PFMT64x" -> %9s -> 0x%"PFMT64x, src, type, dst);
|
||||
name = anal->coreb.getNameDelta (anal->coreb.core, dst);
|
||||
if (name && *name) {
|
||||
anal->cb_printf (" %s\n", name? name: "");
|
||||
} else {
|
||||
anal->cb_printf ("\n");
|
||||
}
|
||||
free (name);
|
||||
}
|
||||
}
|
||||
free (type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -247,6 +283,9 @@ R_API void r_anal_xrefs_list(RAnal *anal, int rad) {
|
||||
case '*':
|
||||
sdb_foreach (DB, (SdbForeachCallback)xrefs_list_cb_rad, anal);
|
||||
break;
|
||||
case '\0':
|
||||
sdb_foreach (DB, (SdbForeachCallback)xrefs_list_cb_normal, anal);
|
||||
break;
|
||||
case 'q':
|
||||
sdb_foreach (DB, (SdbForeachCallback)xrefs_list_cb_quiet, anal);
|
||||
break;
|
||||
|
@ -4680,10 +4680,12 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'k': // "axk"
|
||||
if (input[1] == ' ') {
|
||||
if (input[1] == '?') {
|
||||
eprintf ("Usage: axk [query]\n");
|
||||
} else if (input[1] == ' ') {
|
||||
sdb_query (core->anal->sdb_xrefs, input + 2);
|
||||
} else {
|
||||
eprintf ("|ERROR| Usage: axk [query]\n");
|
||||
r_core_anal_ref_list (core, 0);
|
||||
}
|
||||
break;
|
||||
case '\0': // "ax"
|
||||
|
@ -220,6 +220,17 @@ static const char *getName(RCore *core, ut64 addr) {
|
||||
return item ? item->name : NULL;
|
||||
}
|
||||
|
||||
static char *getNameDelta(RCore *core, ut64 addr) {
|
||||
RFlagItem *item = r_flag_get_at (core->flags, addr, true);
|
||||
if (item) {
|
||||
if (item->offset != addr) {
|
||||
return r_str_newf ("%s + %d", item->name, (int)(addr - item->offset));
|
||||
}
|
||||
return strdup (item->name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void archbits(RCore *core, ut64 addr) {
|
||||
r_anal_build_range_on_hints (core->anal);
|
||||
r_core_seek_archbits (core, addr);
|
||||
@ -239,6 +250,7 @@ R_API int r_core_bind(RCore *core, RCoreBind *bnd) {
|
||||
bnd->puts = (RCorePuts)r_cons_strcat;
|
||||
bnd->setab = (RCoreSetArchBits)setab;
|
||||
bnd->getName = (RCoreGetName)getName;
|
||||
bnd->getNameDelta = (RCoreGetNameDelta)getNameDelta;
|
||||
bnd->archbits = (RCoreSeekArchBits)archbits;
|
||||
bnd->cfggeti = (RCoreConfigGetI)cfggeti;
|
||||
return true;
|
||||
|
@ -12,7 +12,8 @@ typedef char* (*RCoreCmdStr)(void *core, const char *cmd);
|
||||
typedef char* (*RCoreCmdStrF)(void *core, const char *cmd, ...);
|
||||
typedef void (*RCorePuts)(const char *cmd);
|
||||
typedef void (*RCoreSetArchBits)(void *core, const char *arch, int bits);
|
||||
typedef char *(*RCoreGetName)(void *core, ut64 off);
|
||||
typedef const char *(*RCoreGetName)(void *core, ut64 off);
|
||||
typedef char *(*RCoreGetNameDelta)(void *core, ut64 off);
|
||||
typedef void (*RCoreSeekArchBits)(void *core, ut64 addr);
|
||||
typedef int (*RCoreConfigGetI)(void *core, const char *key);
|
||||
|
||||
@ -26,6 +27,7 @@ typedef struct r_core_bind_t {
|
||||
RCoreDebugBpHit bphit;
|
||||
RCoreSetArchBits setab;
|
||||
RCoreGetName getName;
|
||||
RCoreGetNameDelta getNameDelta;
|
||||
RCoreSeekArchBits archbits;
|
||||
RCoreConfigGetI cfggeti;
|
||||
} RCoreBind;
|
||||
|
Loading…
x
Reference in New Issue
Block a user