mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-26 00:55:59 +00:00
Add all-xrefs listings in 'afi' and 'afij' ##analysis
* This will make some tools/scripts run slower if they use those commands ideally we may want to move this info to `afix` or something, but then we will break the tools too. So that needs discussion before merging.
This commit is contained in:
parent
1d6ccf8a11
commit
c42adcf1d5
@ -1,9 +1,7 @@
|
||||
/* radare - LGPL - Copyright 2019-2022 - pancake, thestr4ng3r */
|
||||
/* radare - LGPL - Copyright 2019-2023 - pancake, thestr4ng3r */
|
||||
|
||||
#include <r_anal.h>
|
||||
|
||||
#define D if (anal->verbose)
|
||||
|
||||
static bool get_functions_block_cb(RAnalBlock *block, void *user) {
|
||||
RList *list = user;
|
||||
RListIter *iter;
|
||||
|
@ -2993,6 +2993,25 @@ static int fcn_print_json(RCore *core, RAnalFunction *fcn, PJ *pj) {
|
||||
pj_end (pj);
|
||||
}
|
||||
r_list_free (xrefs);
|
||||
xrefs = r_anal_function_get_all_xrefs (fcn);
|
||||
if (!r_list_empty (xrefs)) {
|
||||
pj_k (pj, "allxrefs");
|
||||
pj_a (pj);
|
||||
r_list_foreach (xrefs, iter, refi) {
|
||||
int rt = R_ANAL_REF_TYPE_MASK (refi->type);
|
||||
if (rt == R_ANAL_REF_TYPE_CODE || rt == R_ANAL_REF_TYPE_CALL) {
|
||||
indegree++;
|
||||
pj_o (pj);
|
||||
pj_kn (pj, "addr", refi->addr);
|
||||
pj_ks (pj, "type", r_anal_ref_type_tostring (refi->type));
|
||||
pj_kn (pj, "at", refi->at);
|
||||
pj_end (pj);
|
||||
}
|
||||
}
|
||||
|
||||
pj_end (pj);
|
||||
}
|
||||
r_list_free (xrefs);
|
||||
|
||||
pj_ki (pj, "indegree", indegree);
|
||||
pj_ki (pj, "outdegree", outdegree);
|
||||
@ -3192,7 +3211,6 @@ static int fcn_print_legacy(RCore *core, RAnalFunction *fcn) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#if R2_590
|
||||
xrefs = r_anal_function_get_all_xrefs (fcn);
|
||||
r_cons_printf ("\nall-code-xrefs:");
|
||||
if (!r_list_empty (xrefs)) {
|
||||
@ -3204,7 +3222,6 @@ static int fcn_print_legacy(RCore *core, RAnalFunction *fcn) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
r_cons_printf ("\nnoreturn: %s", r_str_bool (fcn->is_noreturn));
|
||||
r_cons_printf ("\nin-degree: %d", indegree);
|
||||
r_cons_printf ("\nout-degree: %d", outdegree);
|
||||
@ -3255,7 +3272,7 @@ static int fcn_list_detail(RCore *core, RList *fcns) {
|
||||
}
|
||||
|
||||
static int fcn_list_table(RCore *core, const char *q, int fmt) {
|
||||
char xref[128], refs[128], ccstr[128], castr[128];
|
||||
char xref[128], axref[128], refs[128], ccstr[128], castr[128];
|
||||
RAnalFunction *fcn;
|
||||
RListIter *iter;
|
||||
RTable *t = r_core_table (core, "fcns");
|
||||
@ -3269,6 +3286,7 @@ static int fcn_list_table(RCore *core, const char *q, int fmt) {
|
||||
r_table_add_column (t, typeNumber, "nins", 0);
|
||||
r_table_add_column (t, typeNumber, "refs", 0);
|
||||
r_table_add_column (t, typeNumber, "xref", 0);
|
||||
r_table_add_column (t, typeNumber, "axref", 0);
|
||||
r_table_add_column (t, typeNumber, "calls", 0);
|
||||
r_table_add_column (t, typeNumber, "cc", 0);
|
||||
r_list_foreach (core->anal->fcns, iter, fcn) {
|
||||
@ -3286,6 +3304,10 @@ static int fcn_list_table(RCore *core, const char *q, int fmt) {
|
||||
snprintf (xref, sizeof (xref), "%d", r_list_length (xrefs));
|
||||
r_list_free (xrefs);
|
||||
|
||||
xrefs = r_anal_function_get_all_xrefs (fcn);
|
||||
snprintf (axref, sizeof (axref), "%d", r_list_length (xrefs));
|
||||
r_list_free (xrefs);
|
||||
|
||||
RList *calls = r_core_anal_fcn_get_calls (core, fcn);
|
||||
r_list_uniq_inplace (calls, (RListComparatorItem)RAnalRef_val);
|
||||
snprintf (castr, sizeof (castr), "%d", r_list_length (calls));
|
||||
|
@ -1129,6 +1129,7 @@ R_API RList *r_anal_xrefs_get_from(RAnal *anal, ut64 from);
|
||||
R_API void r_anal_xrefs_list(RAnal *anal, int rad, const char *arg);
|
||||
R_API RList *r_anal_function_get_refs(RAnalFunction *fcn);
|
||||
R_API RList *r_anal_function_get_xrefs(RAnalFunction *fcn);
|
||||
R_API RList *r_anal_function_get_all_xrefs(RAnalFunction *fcn);
|
||||
R_API bool r_anal_xrefs_from(RAnal *anal, RList *list, const char *kind, const RAnalRefType type, ut64 addr);
|
||||
R_API bool r_anal_xrefs_set(RAnal *anal, ut64 from, ut64 to, const RAnalRefType type);
|
||||
R_API bool r_anal_xrefs_deln(RAnal *anal, ut64 from, ut64 to, const RAnalRefType type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user