Skip to content

Commit

Permalink
more improvements in aa
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jun 5, 2024
1 parent 755ae64 commit 23baead
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
52 changes: 33 additions & 19 deletions libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6760,7 +6760,8 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
if (re < 1) {
ret = 0;
} else {
ret = r_anal_op (core->anal, &op, addr, code, sizeof (code), R_ARCH_OP_MASK_BASIC | R_ARCH_OP_MASK_ESIL | R_ARCH_OP_MASK_HINT);
ret = r_anal_op (core->anal, &op, addr, code, sizeof (code),
R_ARCH_OP_MASK_BASIC | R_ARCH_OP_MASK_ESIL | R_ARCH_OP_MASK_HINT);
}
// if type is JMP then we execute the next N instructions
// update the esil pointer because RAnal.op() can change it
Expand Down Expand Up @@ -13373,7 +13374,7 @@ static bool isSkippable(RBinSymbol *s) {
return false;
}

R_API int r_core_anal_all(RCore *core) {
static bool cmd_aa(RCore *core, bool aaa) {
const RList *list;
RListIter *iter;
RAnalFunction *fcni;
Expand Down Expand Up @@ -13449,28 +13450,39 @@ R_API int r_core_anal_all(RCore *core) {
}
}
r_core_task_yield (&core->tasks);
// R2_600 - drop this code? we already recover vars later in aaa. should be fine to if 0
if (anal_vars) {
logline (core, 22, "Recovering variables (afva@@@F)");
/* Set fcn type to R_ANAL_FCN_TYPE_SYM for symbols */
r_list_foreach_prev (core->anal->fcns, iter, fcni) {
if (r_cons_is_breaked ()) {
break;
}
r_core_recover_vars (core, fcni, true);
const char *fname = fcni->name;
if (r_str_startswith (fname, "dbg.")
|| r_str_startswith (fname, "rsym.")
|| r_str_startswith (fname, "sym.")
|| r_str_startswith (fname, "main")) {
fcni->type = R_ANAL_FCN_TYPE_SYM;
if (!aaa) {
// R2_600 - drop this code? we already recover vars later in aaa. should be fine to if 0
if (anal_vars) {
logline (core, 22, "Recovering variables (afva@@@F)");
/* Set fcn type to R_ANAL_FCN_TYPE_SYM for symbols */
r_list_foreach_prev (core->anal->fcns, iter, fcni) {
if (r_cons_is_breaked ()) {
break;
}
r_core_recover_vars (core, fcni, true);
const char *fname = fcni->name;
if (r_str_startswith (fname, "dbg.")
|| r_str_startswith (fname, "rsym.")
|| r_str_startswith (fname, "sym.")
|| r_str_startswith (fname, "main")) {
fcni->type = R_ANAL_FCN_TYPE_SYM;
}
}
}
}
r_cons_break_pop ();
return true;
}

#if R2_USE_NEW_ABI
// deprecated call
#else
R_API int r_core_anal_all(RCore *core) {
cmd_aa (core, true);
return true;
}
#endif

static int cmd_anal_all(RCore *core, const char *input) {
switch (*input) {
case '?':
Expand Down Expand Up @@ -13673,18 +13685,20 @@ static int cmd_anal_all(RCore *core, const char *input) {
anal_imports = true;
}
r_config_set_b (core->config, "anal.imports", false);
r_core_anal_all (core);
cmd_aa (core, input[0] == 'a');
r_config_set_b (core->config, "anal.imports", anal_imports);
r_core_task_yield (&core->tasks);
if (r_cons_is_breaked ()) {
goto jacuzzi;
}
#if 0
// Run afvn in all fcns
if (r_config_get_b (core->config, "anal.vars")) {
logline (core, 25, "Analyze all functions arguments/locals (afva@@@F)");
// r_core_cmd0 (core, "afva@@f");
r_core_cmd0 (core, "afva@@@F");
}
#endif

// Run pending analysis immediately after analysis
// Usefull when running commands with ";" or via r2 -c,-i
Expand Down Expand Up @@ -13754,7 +13768,7 @@ static int cmd_anal_all(RCore *core, const char *input) {
r_core_task_yield (&core->tasks);
logline (core, 60, "Finding and parsing C++ vtables (avrr)");
r_core_cmd_call (core, "avrr");
logline (core, 65, "Analyzing methods");
logline (core, 65, "Analyzing methods (af @@ method.*)");
r_core_cmd0 (core, "af @@ method.*");
r_core_task_yield (&core->tasks);
// r_config_set_b (core->config, "anal.calls", c);
Expand Down
2 changes: 2 additions & 0 deletions libr/include/r_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,9 @@ R_API int r_core_anal_graph(RCore *core, ut64 addr, int opts);
R_API int r_core_anal_graph_fcn(RCore *core, char *input, int opts);
R_API RList* r_core_anal_graph_to(RCore *core, ut64 addr, int n);
R_API int r_core_anal_ref_list(RCore *core, int rad);
#if !R2_USE_NEW_ABI
R_API int r_core_anal_all(RCore *core);
#endif
R_API RList* r_core_anal_cycles(RCore *core, int ccl);
typedef struct r_vec_RVecAnalRef_t RVecAnalRef;
R_API RVecAnalRef *r_core_anal_fcn_get_calls(RCore *core, RAnalFunction *fcn); // get all calls from a function
Expand Down

0 comments on commit 23baead

Please sign in to comment.