Micro block array (internal representation of the decompiled code). More...
Public Member Functions | |
bool | precise_defeas (void) const |
bool | optimized (void) const |
bool | short_display (void) const |
bool | show_reduction (void) const |
bool | graph_insns (void) const |
bool | loaded_gdl (void) const |
bool | should_beautify (void) const |
bool | rtype_refined (void) const |
bool | may_refine_rettype (void) const |
bool | use_wingraph32 (void) const |
bool | display_numaddrs (void) const |
bool | display_valnums (void) const |
bool | is_pattern (void) const |
bool | is_thunk (void) const |
bool | saverest_done (void) const |
bool | callinfo_built (void) const |
bool | really_alloc (void) const |
bool | lvars_allocated (void) const |
bool | chain_varnums_ok (void) const |
bool | returns_fpval (void) const |
bool | has_passregs (void) const |
bool | generated_asserts (void) const |
bool | propagated_asserts (void) const |
bool | deleted_pairs (void) const |
bool | common_stkvars_stkargs (void) const |
bool | lvar_names_ok (void) const |
bool | lvars_renamed (void) const |
bool | has_over_chains (void) const |
bool | valranges_done (void) const |
bool | argidx_ok (void) const |
bool | argidx_sorted (void) const |
bool | is_ctr (void) const |
bool | is_dtr (void) const |
bool | is_cdtr (void) const |
int | get_mba_flags (void) const |
int | get_mba_flags2 (void) const |
void | set_mba_flags (int f) |
void | clr_mba_flags (int f) |
void | set_mba_flags2 (int f) |
void | clr_mba_flags2 (int f) |
void | clr_cdtr (void) |
int | calc_shins_flags (void) const |
sval_t | stkoff_vd2ida (sval_t off) const |
sval_t | stkoff_ida2vd (sval_t off) const |
sval_t | argbase () const |
vdloc_t | idaloc2vd (const argloc_t &loc, int width) const |
argloc_t | vd2idaloc (const vdloc_t &loc, int width) const |
bool | is_stkarg (const lvar_t &v) const |
member_t * | get_stkvar (sval_t vd_stkoff, uval_t *poff) const |
argloc_t | get_ida_argloc (const lvar_t &v) const |
bool | write_to_const_detected (void) const |
bool | bad_call_sp_detected (void) const |
bool | regargs_is_not_aligned (void) const |
bool | has_bad_sp (void) const |
void | term (void) |
func_t * | get_curfunc (void) const |
bool | use_frame (void) const |
bool | range_contains (ea_t ea) const |
bool | is_snippet (void) const |
int | optimize_local (int locopt_bits) |
Optimize each basic block locally. More... | |
merror_t | build_graph (void) |
Build control flow graph. More... | |
mbl_graph_t * | get_graph (void) |
Get control graph. More... | |
int | analyze_calls (int acflags) |
Analyze calls and determine calling conventions. More... | |
merror_t | optimize_global (void) |
Optimize microcode globally. More... | |
void | alloc_lvars (void) |
Allocate local variables. More... | |
void | dump (void) const |
Dump microcode to a file. More... | |
void | vdump_mba (bool _verify, const char *title, va_list va) const |
void | dump_mba (bool _verify, const char *title,...) const |
void | print (vd_printer_t &vp) const |
Print microcode to any destination. More... | |
void | verify (bool always) const |
Verify microcode consistency. More... | |
void | mark_chains_dirty (void) |
Mark the microcode use-def chains dirty. More... | |
const mblock_t * | get_mblock (int n) const |
Get basic block by its serial number. | |
mblock_t * | get_mblock (int n) |
mblock_t * | insert_block (int bblk) |
Insert a block in the middle of the mbl array. More... | |
bool | remove_block (mblock_t *blk) |
Delete a block. More... | |
mblock_t * | copy_block (mblock_t *blk, int new_serial, int cpblk_flags=3) |
Make a copy of a block. More... | |
bool | remove_empty_blocks (void) |
Delete all empty blocks. | |
bool | combine_blocks (void) |
Combine blocks. More... | |
int | for_all_ops (mop_visitor_t &mv) |
Visit all operands of all instructions. More... | |
int | for_all_insns (minsn_visitor_t &mv) |
Visit all instructions. More... | |
int | for_all_topinsns (minsn_visitor_t &mv) |
Visit all top level instructions. More... | |
mop_t * | find_mop (op_parent_info_t *ctx, ea_t ea, bool is_dest, const mlist_t &list) |
Find an operand in the microcode. More... | |
lvar_t & | arg (int n) |
Get input argument of the decompiled function. More... | |
const lvar_t & | arg (int n) const |
const ivl_t & | get_std_region (memreg_index_t idx) const |
Get information about various memory regions. More... | |
const ivl_t & | get_lvars_region (void) const |
const ivl_t & | get_shadow_region (void) const |
const ivl_t & | get_args_region (void) const |
ivl_t | get_stack_region (void) const |
void | serialize (bytevec_t &vout) const |
Serialize mbl array into a sequence of bytes. | |
Static Public Member Functions | |
static vdloc_t | idaloc2vd (const argloc_t &loc, int width, sval_t spd) |
static argloc_t | vd2idaloc (const vdloc_t &loc, int width, sval_t spd) |
static mbl_array_t * | deserialize (const uchar *bytes, size_t nbytes) |
Deserialize a byte sequence into mbl array. More... | |
Public Attributes | |
mba_ranges_t | mbr |
ea_t | entry_ea |
ea_t | last_prolog_ea |
ea_t | first_epilog_ea |
int | qty |
number of basic blocks | |
int | npurged |
-1 - unknown | |
cm_t | cc |
calling convention | |
sval_t | tmpstk_size |
size of the temporary stack part (which dynamically changes with push/pops) | |
sval_t | frsize |
size of local stkvars range in the stack frame | |
sval_t | frregs |
size of saved registers range in the stack frame | |
sval_t | fpd |
frame pointer delta | |
int | pfn_flags |
copy of func_t::flags | |
int | retsize |
size of return address in the stack frame | |
int | shadow_args |
size of shadow argument area | |
sval_t | fullsize |
Full stack size including incoming args. | |
sval_t | stacksize |
The maximal size of the function stack including bytes allocated for outgoing call arguments (up to retaddr) | |
sval_t | inargoff |
offset of the first stack argument; after fix_scattered_movs() INARGOFF may be less than STACKSIZE | |
sval_t | minstkref |
The lowest stack location whose address was taken. | |
ea_t | minstkref_ea |
address with lowest minstkref (for debugging) | |
sval_t | minargref |
The lowest stack argument location whose address was taken This location and locations above it can be aliased It controls locations >= inargoff-shadow_args. | |
sval_t | spd_adjust |
If sp>0, the max positive sp value. | |
ivl_t | aliased_vars |
Aliased stkvar locations. | |
ivl_t | aliased_args |
Aliased stkarg locations. | |
ivlset_t | gotoff_stkvars |
stkvars that hold .got offsets. considered to be unaliasable | |
ivlset_t | restricted_memory |
ivlset_t | aliased_memory |
aliased_memory+restricted_memory=ALLMEM | |
mlist_t | nodel_memory |
global dead elimination may not delete references to this area | |
rlist_t | consumed_argregs |
registers converted into stack arguments, should not be used as arguments | |
mba_maturity_t | maturity |
current maturity level | |
mba_maturity_t | reqmat |
required maturity level | |
bool | final_type |
is the function type final? (specified by the user) | |
tinfo_t | idb_type |
function type as retrieved from the database | |
reginfovec_t | idb_spoiled |
MBA_SPLINFO && final_type: info in ida format. | |
mlist_t | spoiled_list |
MBA_SPLINFO && !final_type: info in vd format. | |
int | fti_flags |
FTI_... constants for the current function. | |
netnode | idb_node |
qstring | label |
name of the function or pattern (colored) | |
lvars_t | vars |
local variables | |
intvec_t | argidx |
input arguments (indexes into 'vars') | |
int | retvaridx |
index of variable holding the return value -1 means none | |
ea_t | error_ea |
during microcode generation holds ins.ea | |
qstring | error_strarg |
mblock_t * | blocks |
double linked list of blocks | |
mblock_t ** | natural |
natural order of blocks | |
ivl_with_name_t | std_ivls [6] |
we treat memory as consisting of 6 parts see memreg_index_t | |
hexwarns_t | notes |
uchar | occurred_warns [32] |
char | reserved [] |
Detailed Description
Micro block array (internal representation of the decompiled code).
Array of micro blocks representing microcode for a decompiled function.
Intermediate representation of the decompiled function. The details of this class are not public yet because it will be modified in the near future. We plan to disclose them after porting the decompiler to ARM.
The first micro block is the entry point, the last one is the exit point. The entry and exit blocks are always empty. The exit block is generated at MMAT_LOCOPT maturity level.
- Examples
- hexrays_sample11.cpp, hexrays_sample12.cpp, hexrays_sample13.cpp, hexrays_sample15.cpp, hexrays_sample18.cpp, and hexrays_sample9.cpp.
Definition at line 62 of file hexrays.dox.
Member Function Documentation
◆ alloc_lvars()
void mbl_array_t::alloc_lvars | ( | void | ) |
Allocate local variables.
Must be called only immediately after optimize_global(), with no modifications to the microcode. Converts registers, stack variables, and similar operands into mop_l. This call will not fail because all necessary checks were performed in optimize_global(). After this call the microcode reaches its final state.
Definition at line 10750 of file hexrays.hpp.
References hexdsp.
◆ analyze_calls()
int mbl_array_t::analyze_calls | ( | int | acflags | ) |
Analyze calls and determine calling conventions.
- Parameters
-
acflags permitted actions that are necessary for successful detection of calling conventions. See Bits for analyze_calls()
- Returns
- number of calls. -1 means error.
- Examples
- hexrays_sample12.cpp.
Definition at line 10738 of file hexrays.hpp.
References hexdsp.
◆ arg()
lvar_t & mbl_array_t::arg | ( | int | n | ) |
Get input argument of the decompiled function.
- Parameters
-
n argument number (0..nargs-1)
Definition at line 10840 of file hexrays.hpp.
References hexdsp.
◆ build_graph()
merror_t mbl_array_t::build_graph | ( | void | ) |
Build control flow graph.
This function may be called only once. It calculates the type of each basic block and the adjacency list. optimize_local() calls this function if necessary. You need to call this function only before MMAT_LOCOPT.
- Returns
- error code
- Examples
- hexrays_sample12.cpp.
Definition at line 10726 of file hexrays.hpp.
References hexdsp.
◆ combine_blocks()
bool mbl_array_t::combine_blocks | ( | void | ) |
Combine blocks.
This function merges blocks constituting linear flow. It calls remove_empty_blocks() as well.
- Returns
- true if changed any blocks
Definition at line 10810 of file hexrays.hpp.
References hexdsp.
◆ copy_block()
Make a copy of a block.
This function makes a simple copy of the block. It does not fix the predecessor and successor lists, they must be fixed if necessary.
- Parameters
-
blk block to copy new_serial position of the copied block cpblk_flags combination of Batch decompilation bits... bits
- Returns
- pointer to the new copy
Definition at line 10798 of file hexrays.hpp.
References hexdsp.
◆ deserialize()
|
static |
Deserialize a byte sequence into mbl array.
- Parameters
-
bytes pointer to the beginning of the byte sequence. nbytes number of bytes in the byte sequence.
- Returns
- new mbl array
Definition at line 10852 of file hexrays.hpp.
References hexdsp.
◆ dump()
void mbl_array_t::dump | ( | void | ) | const |
Dump microcode to a file.
The file will be created in the directory pointed by IDA_DUMPDIR envvar. Dump will be created only if IDA is run under debugger.
- Examples
- hexrays_sample18.cpp.
Definition at line 10756 of file hexrays.hpp.
References hexdsp.
◆ find_mop()
mop_t * mbl_array_t::find_mop | ( | op_parent_info_t * | ctx, |
ea_t | ea, | ||
bool | is_dest, | ||
const mlist_t & | list | ||
) |
Find an operand in the microcode.
This function tries to find the operand that matches LIST. Any operand that overlaps with LIST is considered as a match.
- Parameters
-
[out] ctx context information for the result ea desired address of the operand is_dest search for destination operand? this argument may be ignored if the exact match could not be found list list of locations the correspond to the operand
- Returns
- pointer to the operand or NULL.
- Examples
- hexrays_sample12.cpp, and hexrays_sample15.cpp.
Definition at line 10834 of file hexrays.hpp.
References hexdsp.
◆ for_all_insns()
int mbl_array_t::for_all_insns | ( | minsn_visitor_t & | mv | ) |
Visit all instructions.
This function visits all instruction and subinstructions.
- Parameters
-
mv instruction visitor
- Returns
- non-zero value returned by mv.visit_mop() or zero
Definition at line 10822 of file hexrays.hpp.
References hexdsp.
◆ for_all_ops()
int mbl_array_t::for_all_ops | ( | mop_visitor_t & | mv | ) |
Visit all operands of all instructions.
- Parameters
-
mv operand visitor
- Returns
- non-zero value returned by mv.visit_mop() or zero
Definition at line 10816 of file hexrays.hpp.
References hexdsp.
◆ for_all_topinsns()
int mbl_array_t::for_all_topinsns | ( | minsn_visitor_t & | mv | ) |
Visit all top level instructions.
- Parameters
-
mv instruction visitor
- Returns
- non-zero value returned by mv.visit_mop() or zero
- Examples
- hexrays_sample18.cpp.
Definition at line 10828 of file hexrays.hpp.
References hexdsp.
◆ get_graph()
mbl_graph_t * mbl_array_t::get_graph | ( | void | ) |
Get control graph.
Call build_graph() if you need the graph before MMAT_LOCOPT.
- Examples
- hexrays_sample12.cpp.
Definition at line 10732 of file hexrays.hpp.
References hexdsp.
◆ get_std_region()
const ivl_t & mbl_array_t::get_std_region | ( | memreg_index_t | idx | ) | const |
Get information about various memory regions.
We map the stack frame to the global memory, to some unused range.
Definition at line 5017 of file hexrays.hpp.
References std_ivls.
◆ insert_block()
mblock_t * mbl_array_t::insert_block | ( | int | bblk | ) |
Insert a block in the middle of the mbl array.
The very first block of microcode must be empty, it is the entry block. The very last block of microcode must be BLT_STOP, it is the exit block. Therefore inserting a new block before the entry point or after the exit block is not a good idea.
- Parameters
-
bblk the new block will be inserted before BBLK
- Returns
- ptr to the new block
Definition at line 10786 of file hexrays.hpp.
References hexdsp.
◆ mark_chains_dirty()
void mbl_array_t::mark_chains_dirty | ( | void | ) |
Mark the microcode use-def chains dirty.
Call this function is any inter-block data dependencies got changed because of your modifications to the microcode. Failing to do so may cause an internal error.
- Examples
- hexrays_sample11.cpp.
Definition at line 10780 of file hexrays.hpp.
References hexdsp.
◆ optimize_global()
merror_t mbl_array_t::optimize_global | ( | void | ) |
Optimize microcode globally.
This function applies various optimization methods until we reach the fixed point. After that it preallocates lvars unless reqmat forbids it.
- Returns
- error code
Definition at line 10744 of file hexrays.hpp.
References hexdsp.
◆ optimize_local()
int mbl_array_t::optimize_local | ( | int | locopt_bits | ) |
Optimize each basic block locally.
- Parameters
-
locopt_bits combination of Bits for optimize_local() bits
- Returns
- number of changes. 0 means nothing changed This function is called by the decompiler, usually there is no need to call it explicitly.
Definition at line 10720 of file hexrays.hpp.
References hexdsp.
◆ print()
void mbl_array_t::print | ( | vd_printer_t & | vp | ) | const |
Print microcode to any destination.
- Parameters
-
vp print sink
- Examples
- hexrays_sample13.cpp, and hexrays_sample9.cpp.
Definition at line 10768 of file hexrays.hpp.
References hexdsp.
◆ remove_block()
bool mbl_array_t::remove_block | ( | mblock_t * | blk | ) |
Delete a block.
- Parameters
-
blk block to delete
- Returns
- true if at least one of the other blocks became empty or unreachable
Definition at line 10792 of file hexrays.hpp.
References hexdsp.
◆ verify()
void mbl_array_t::verify | ( | bool | always | ) | const |
Verify microcode consistency.
- Parameters
-
always if false, the check will be performed only if ida runs under debugger If any inconsistency is discovered, an internal error will be generated. We strongly recommend you to call this function before returing control to the decompiler from your callbacks, in the case if you modified the microcode.
- Examples
- hexrays_sample11.cpp, and hexrays_sample18.cpp.
Definition at line 10774 of file hexrays.hpp.
References hexdsp.