ROSE
0.9.6a
|
Callback to insert unreachable code fragments. More...
#include <Partitioner.h>
Public Member Functions | |
FindFunctionFragments () | |
virtual | ~FindFunctionFragments () |
virtual bool | operator() (bool enabled, const Args &args) |
The actual callback function. More... | |
Public Member Functions inherited from Partitioner::ByteRangeCallback | |
virtual | ~ByteRangeCallback () |
Public Attributes | |
bool | require_noninterleaved |
If set, then preceding function cannot be interleaved. More... | |
bool | require_intrafunction |
If set, range must be inside the preceding function. More... | |
double | threshold |
Threshold for determining whether range is code. More... | |
unsigned | excluded_reasons |
Functions for which callback should be skipped. More... | |
size_t | nfound |
Number of basic blocks added as code fragments. More... | |
FunctionRangeMap * | function_extents |
Cached function extents computed on first call. More... | |
CodeCriteria * | code_criteria |
Cached code criteria computed on first call. More... | |
Callback to insert unreachable code fragments.
This callback can be passed to the scan_unassigned_bytes() method's callback list. Whenever it detects a region of unassigned bytes that looks like it might be code, it generates basic blocks and attaches them to the immediately preceding function.
If the require_noninterleaved
property is set (the default) then the callback is triggered only if the preceding function's extent is not interleaved with other functions. Normally, if two or more functions are interleaved then we cannot assume that the range of instructions being analyzed by this callback belongs to the surrounding function or some other (possibly interleaved) function.
If the require_intrafunction
property is set (default is clear) then the region being analyzed must be immediately followed by something that belongs to the preceding function.
A fragment is added to the preceding function only if the fragment looks statistically like code. A CodeCriteria object is created on the first call if necessary and is initialized based on the statistics computed across all known functions (as returned by Partitioner::aggregate_statistics()) and the threshold
data member. The caller can supply its own CodeCriteria if desired, in which case FindFunctionFragments::threshold is unused. In either case, the CodeCriteria object is deleted when the FindFunctionFragments object is deleted.
This callback is skipped if the preceding function contains any of the SgAsmFunction::FunctionReason bits that are set in the excluded_reasons
data member. The default is to exclude functions created for padding or thunks.
This callback might create new basic blocks as a side effect even if those blocks are not added to any function.
Definition at line 1315 of file Partitioner.h.
|
inline |
Definition at line 1325 of file Partitioner.h.
|
inlinevirtual |
Definition at line 1330 of file Partitioner.h.
References code_criteria, and function_extents.
|
virtual |
The actual callback function.
This needs to be defined in subclasses.
Implements Partitioner::ByteRangeCallback.
Definition at line 2132 of file Partitioner.C.
References Partitioner::aggregate_statistics(), Partitioner::append(), SgAsmBlock::BLK_FRAGMENT, RangeMap< R, T >::contains(), RangeMap< R, T >::empty(), RangeMap< R, T >::erase(), Partitioner::find_bb_containing(), Partitioner::find_bb_starting(), Range< T >::first(), Partitioner::BasicBlock::function, Partitioner::function_extent(), Partitioner::get_aggregate_variance(), RangeMap< R, T >::insert(), Partitioner::BasicBlock::insns, Partitioner::is_contiguous(), Range< T >::last(), Range< rose_addr_t >::maximum(), RangeMap< R, T >::min(), Range< rose_addr_t >::minimum(), Partitioner::new_code_criteria(), Partitioner::ByteRangeCallback::Args::partitioner, Partitioner::ByteRangeCallback::Args::range, Partitioner::Function::reason, and Partitioner::region_statistics().
bool Partitioner::FindFunctionFragments::require_noninterleaved |
If set, then preceding function cannot be interleaved.
Definition at line 1316 of file Partitioner.h.
Referenced by Partitioner::post_cfg().
bool Partitioner::FindFunctionFragments::require_intrafunction |
If set, range must be inside the preceding function.
Definition at line 1317 of file Partitioner.h.
Referenced by Partitioner::post_cfg().
double Partitioner::FindFunctionFragments::threshold |
Threshold for determining whether range is code.
Definition at line 1318 of file Partitioner.h.
Referenced by Partitioner::post_cfg().
unsigned Partitioner::FindFunctionFragments::excluded_reasons |
Functions for which callback should be skipped.
Definition at line 1319 of file Partitioner.h.
size_t Partitioner::FindFunctionFragments::nfound |
Number of basic blocks added as code fragments.
Definition at line 1320 of file Partitioner.h.
FunctionRangeMap* Partitioner::FindFunctionFragments::function_extents |
Cached function extents computed on first call.
Definition at line 1322 of file Partitioner.h.
Referenced by ~FindFunctionFragments().
CodeCriteria* Partitioner::FindFunctionFragments::code_criteria |
Cached code criteria computed on first call.
Definition at line 1323 of file Partitioner.h.
Referenced by ~FindFunctionFragments().