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

WIP: Do not iterate over function bbs, when we can iterate over bb's functions ##analysis #23443

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions libr/anal/fcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2243,9 +2243,33 @@ R_API RAnalBlock *r_anal_function_bbget_in(RAnal *anal, RAnalFunction *fcn, ut64
if (addr == UT64_MAX) {
return NULL;
}
RListIter *iter;
RAnalBlock *bb;
const bool aligned = r_anal_is_aligned (anal, addr);
RAnalBlock *bb;
RListIter *iter;
#if 0
// returns nothinig
bb = r_anal_get_block_at (anal, addr);
if (bb) {
return bb;
}
#endif
#if 1
// works fine
RList *bbs = r_anal_get_blocks_in (anal, addr);
r_list_foreach (bbs, iter, bb) {
RListIter *iter2;
RAnalFunction *f;
r_list_foreach (bb->fcns, iter2, f) {
if (f == fcn) {
if ((!anal->opt.jmpmid || !aligned || r_anal_block_op_starts_at (bb, addr))) {
return bb;
}
}
}
}
#endif
#if 0
// original implementation -- fallback
r_list_foreach (fcn->bbs, iter, bb) {
if (r_anal_block_contains (bb, addr)) {
if ((!anal->opt.jmpmid || !aligned || r_anal_block_op_starts_at (bb, addr))) {
Expand All @@ -2255,6 +2279,7 @@ R_API RAnalBlock *r_anal_function_bbget_in(RAnal *anal, RAnalFunction *fcn, ut64
// return bb;
}
}
#endif
return NULL;
}

Expand Down
Loading