Remove prev, jumpbb and failbb from RAnalBlock ##anal (#15969)

This commit is contained in:
Florian Märkl 2020-02-13 20:40:37 +01:00 committed by GitHub
parent 51020062bc
commit 19ee4b2df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 52 deletions

View File

@ -43,44 +43,6 @@ R_API RAnalBlock *r_anal_bb_from_offset(RAnal *anal, ut64 off) {
return ret;
}
R_API RAnalBlock *r_anal_bb_get_jumpbb(RAnalFunction *fcn, RAnalBlock *bb) {
if (bb->jump == UT64_MAX) {
return NULL;
}
if (bb->jumpbb) {
return bb->jumpbb;
}
RListIter *iter;
RAnalBlock *b;
r_list_foreach (fcn->bbs, iter, b) {
if (b->addr == bb->jump) {
bb->jumpbb = b;
b->prev = bb;
return b;
}
}
return NULL;
}
R_API RAnalBlock *r_anal_bb_get_failbb(RAnalFunction *fcn, RAnalBlock *bb) {
RListIter *iter;
RAnalBlock *b;
if (bb->fail == UT64_MAX) {
return NULL;
}
if (bb->failbb) {
return bb->failbb;
}
r_list_foreach (fcn->bbs, iter, b) {
if (b->addr == bb->fail) {
bb->failbb = b;
b->prev = bb;
return b;
}
}
return NULL;
}
/* return the offset of the i-th instruction in the basicblock bb.
* If the index of the instruction is not valid, it returns UT16_MAX */
R_API ut16 r_anal_bb_offset_inst(RAnalBlock *bb, int i) {

View File

@ -2155,8 +2155,8 @@ static char *get_bb_body(RCore *core, RAnalBlock *b, int opts, RAnalFunction *fc
char *body = get_body (core, b->addr, b->size, opts);
if (b->jump != UT64_MAX) {
if (b->jump > b->addr) {
RAnalBlock *jumpbb = r_anal_bb_get_jumpbb (fcn, b);
if (jumpbb) {
RAnalBlock *jumpbb = r_anal_get_block_at (b->anal, b->jump);
if (jumpbb && r_list_contains (jumpbb->fcns, fcn)) {
if (emu && core->anal->last_disasm_reg != NULL && !jumpbb->parent_reg_arena) {
jumpbb->parent_reg_arena = r_reg_arena_dup (core->anal->reg, core->anal->last_disasm_reg);
}
@ -2168,8 +2168,8 @@ static char *get_bb_body(RCore *core, RAnalBlock *b, int opts, RAnalFunction *fc
}
if (b->fail != UT64_MAX) {
if (b->fail > b->addr) {
RAnalBlock *failbb = r_anal_bb_get_failbb (fcn, b);
if (failbb) {
RAnalBlock *failbb = r_anal_get_block_at (b->anal, b->fail);
if (failbb && r_list_contains (failbb->fcns, fcn)) {
if (emu && core->anal->last_disasm_reg != NULL && !failbb->parent_reg_arena) {
failbb->parent_reg_arena = r_reg_arena_dup (core->anal->reg, core->anal->last_disasm_reg);
}

View File

@ -4086,8 +4086,8 @@ static void pr_bb(RCore *core, RAnalFunction *fcn, RAnalBlock *b, bool emu, ut64
if (b->jump != UT64_MAX) {
if (b->jump > b->addr) {
RAnalBlock *jumpbb = r_anal_bb_get_jumpbb (fcn, b);
if (jumpbb) {
RAnalBlock *jumpbb = r_anal_get_block_at (b->anal, b->jump);
if (jumpbb && r_list_contains (jumpbb->fcns, fcn)) {
if (emu && core->anal->last_disasm_reg && !jumpbb->parent_reg_arena) {
jumpbb->parent_reg_arena = r_reg_arena_dup (core->anal->reg, core->anal->last_disasm_reg);
}
@ -4102,8 +4102,8 @@ static void pr_bb(RCore *core, RAnalFunction *fcn, RAnalBlock *b, bool emu, ut64
}
if (b->fail != UT64_MAX) {
if (b->fail > b->addr) {
RAnalBlock *failbb = r_anal_bb_get_failbb (fcn, b);
if (failbb) {
RAnalBlock *failbb = r_anal_get_block_at (b->anal, b->fail);
if (failbb && r_list_contains (failbb->fcns, fcn)) {
if (emu && core->anal->last_disasm_reg && !failbb->parent_reg_arena) {
failbb->parent_reg_arena = r_reg_arena_dup (core->anal->reg, core->anal->last_disasm_reg);
}

View File

@ -909,10 +909,6 @@ typedef struct r_anal_bb_t {
// size of the op_pos array
int op_pos_size;
ut8 *op_bytes;
/* these are used also in pdr: */
RAnalBlock *prev;
RAnalBlock *failbb;
RAnalBlock *jumpbb;
RList /*struct r_anal_bb_t*/ *cases;
ut8 *parent_reg_arena;
int stackptr;
@ -1489,8 +1485,6 @@ R_API ut16 r_anal_bb_offset_inst(RAnalBlock *bb, int i);
R_API ut64 r_anal_bb_opaddr_i(RAnalBlock *bb, int i);
R_API ut64 r_anal_bb_opaddr_at(RAnalBlock *bb, ut64 addr);
R_API bool r_anal_bb_op_starts_at(RAnalBlock *bb, ut64 addr);
R_API RAnalBlock *r_anal_bb_get_failbb(RAnalFunction *fcn, RAnalBlock *bb);
R_API RAnalBlock *r_anal_bb_get_jumpbb(RAnalFunction *fcn, RAnalBlock *bb);
/* op.c */
R_API const char *r_anal_stackop_tostring(int s);