ROSE 0.11.145.272
|
State for unparsing.
This object stores the current state for unparsing. The state is kept separate from the unparser class so that (1) the unparser can be a const reference, and (2) multiple threads can be unparsing with the same unparser object.
Definition at line 278 of file Unparser/Base.h.
#include <Rose/BinaryAnalysis/Unparser/Base.h>
Public Types | |
typedef Sawyer::Container::Map< Address, std::string > | AddrString |
Map from address to string. | |
Public Member Functions | |
State (const Partitioner2::PartitionerConstPtr &, const Architecture::BaseConstPtr &, const Settings &, const Base &frontUnparser) | |
Partitioner2::PartitionerConstPtr | partitioner () const |
Property: Partitioner, which may be null. | |
const Partitioner2::FunctionCallGraph & | cg () const |
Property: Call grap, which may be empty. | |
Reachability::ReasonFlags | isCfgVertexReachable (size_t vertexId) const |
Returns reachability based on the cfgVertexReachability property. | |
void | thisIsBasicBlockFirstInstruction () |
Call this when you're about to output the first instruction of a basic block. | |
void | thisIsBasicBlockLastInstruction () |
Call this when you're about to output the last instruction of a basic block. | |
Partitioner2::FunctionPtr | currentFunction () const |
void | currentFunction (const Partitioner2::FunctionPtr &) |
void | rotateBasicBlocks (const Partitioner2::BasicBlockPtr ¤t, const Partitioner2::BasicBlockPtr &next) |
Rotate the basic block pointers. | |
SgAsmExpression * | currentExpression () const |
void | currentExpression (SgAsmExpression *) |
const std::string & | nextInsnLabel () const |
void | nextInsnLabel (const std::string &) |
const RegisterNames & | registerNames () const |
void | registerNames (const RegisterNames &r) |
const AddrString & | basicBlockLabels () const |
AddrString & | basicBlockLabels () |
bool | isPostInstruction () const |
void | isPostInstruction (bool) |
const Base & | frontUnparser () const |
First unparser in the chained list of unparsers. | |
const std::vector< Reachability::ReasonFlags > | cfgVertexReachability () const |
Property: Reachability analysis results. | |
void | cfgVertexReachability (const std::vector< Reachability::ReasonFlags > &) |
Property: Reachability analysis results. | |
const ArrowMargin & | intraFunctionCfgArrows () const |
Control flow graph arrows within a function. | |
ArrowMargin & | intraFunctionCfgArrows () |
Control flow graph arrows within a function. | |
const ArrowMargin & | intraFunctionBlockArrows () const |
User-defined intra-function margin arrows. | |
ArrowMargin & | intraFunctionBlockArrows () |
User-defined intra-function margin arrows. | |
const ArrowMargin & | globalBlockArrows () const |
User-defined arrows to basic blocks across entire output. | |
ArrowMargin & | globalBlockArrows () |
User-defined arrows to basic blocks across entire output. | |
const StyleStack & | styleStack () const |
Property: Stack of styles. | |
StyleStack & | styleStack () |
Property: Stack of styles. | |
void | reachabilityName (Reachability::Reason value, const std::string &name) |
Assign a reachability name to a reachability value. | |
std::string | reachabilityName (Reachability::ReasonFlags value) const |
Assign a reachability name to a reachability value. | |
Partitioner2::BasicBlockPtr | currentBasicBlock () const |
Points to a relevant basic block. | |
void | currentBasicBlock (const Partitioner2::BasicBlockPtr &) |
Points to a relevant basic block. | |
Partitioner2::BasicBlockPtr | previousBasicBlock () const |
Points to a relevant basic block. | |
void | previousBasicBlock (const Partitioner2::BasicBlockPtr &) |
Points to a relevant basic block. | |
Partitioner2::BasicBlockPtr | nextBasicBlock () const |
Points to a relevant basic block. | |
void | nextBasicBlock (const Partitioner2::BasicBlockPtr &) |
Points to a relevant basic block. | |
typedef Sawyer::Container::Map<Address, std::string> Rose::BinaryAnalysis::Unparser::State::AddrString |
Map from address to string.
Definition at line 280 of file Unparser/Base.h.
const std::vector< Reachability::ReasonFlags > Rose::BinaryAnalysis::Unparser::State::cfgVertexReachability | ( | ) | const |
Property: Reachability analysis results.
This property stores a vector indexed by CFG vertex IDs that holds information about whether the vertex is reachable and why.
void Rose::BinaryAnalysis::Unparser::State::cfgVertexReachability | ( | const std::vector< Reachability::ReasonFlags > & | ) |
Property: Reachability analysis results.
This property stores a vector indexed by CFG vertex IDs that holds information about whether the vertex is reachable and why.
Reachability::ReasonFlags Rose::BinaryAnalysis::Unparser::State::isCfgVertexReachable | ( | size_t | vertexId | ) | const |
Returns reachability based on the cfgVertexReachability property.
If the property has more elements than vertices in the CFG, then the extras are ignored; if the CFG is larger then the missing reachability values are assumed to be zero.
|
inline |
Control flow graph arrows within a function.
This property holds information about how and when to draw arrows in the left margin to represent the edges of a control flow graph whose endpoints are both within the same function. The object is initialized each time a function is entered (see Base::emitFunction) just before emitting the first basic block, but only if the unparser settings indicate that these margin arrows should be displayed. The object is reset just after printing the basic blocks. The object should be in a default state when printing the function prologue and epilogue information, otherwise those parts of the output would be unecessarily indented.
See also, intraFunctionBlockArrows, globalBlockArrows.
Definition at line 338 of file Unparser/Base.h.
|
inline |
Control flow graph arrows within a function.
This property holds information about how and when to draw arrows in the left margin to represent the edges of a control flow graph whose endpoints are both within the same function. The object is initialized each time a function is entered (see Base::emitFunction) just before emitting the first basic block, but only if the unparser settings indicate that these margin arrows should be displayed. The object is reset just after printing the basic blocks. The object should be in a default state when printing the function prologue and epilogue information, otherwise those parts of the output would be unecessarily indented.
See also, intraFunctionBlockArrows, globalBlockArrows.
Definition at line 339 of file Unparser/Base.h.
|
inline |
User-defined intra-function margin arrows.
This object holds information about user-defined arrows in the margin. These arrows point to/from basic blocks such that both basic blocks are in the same function.
To update these arrows during unparsing, the user should provide an unparser updateIntraFunctionArrows either by class derivation or chaining. The actual information about the arrows will be in that function's state
argument in state.intraFunctionBlockArrows()
.arrows. Although it will have already been computed, the state.intraFunctionCfgArrows
can be adjusted at the same time.
See also, intraFunctionCfgArrows, globalBlockArrows.
Definition at line 355 of file Unparser/Base.h.
|
inline |
User-defined intra-function margin arrows.
This object holds information about user-defined arrows in the margin. These arrows point to/from basic blocks such that both basic blocks are in the same function.
To update these arrows during unparsing, the user should provide an unparser updateIntraFunctionArrows either by class derivation or chaining. The actual information about the arrows will be in that function's state
argument in state.intraFunctionBlockArrows()
.arrows. Although it will have already been computed, the state.intraFunctionCfgArrows
can be adjusted at the same time.
See also, intraFunctionCfgArrows, globalBlockArrows.
Definition at line 356 of file Unparser/Base.h.
|
inline |
User-defined arrows to basic blocks across entire output.
This object holds information about user-defined arrows in the margin. These arrows point to/from basic blocks anywhere in the program (not just within functions as with intraFunctionBlockArrows).
See also, intraFunctionCfgArrows, intraFunctionBlockArrows.
Definition at line 367 of file Unparser/Base.h.
|
inline |
User-defined arrows to basic blocks across entire output.
This object holds information about user-defined arrows in the margin. These arrows point to/from basic blocks anywhere in the program (not just within functions as with intraFunctionBlockArrows).
See also, intraFunctionCfgArrows, intraFunctionBlockArrows.
Definition at line 368 of file Unparser/Base.h.
|
inline |
Property: Stack of styles.
Definition at line 380 of file Unparser/Base.h.
|
inline |
Property: Stack of styles.
Definition at line 381 of file Unparser/Base.h.
void Rose::BinaryAnalysis::Unparser::State::reachabilityName | ( | Reachability::Reason | value, |
const std::string & | name | ||
) |
Assign a reachability name to a reachability value.
The two-argument version of this function associates a name with a value. An empty name clears the association.
The one-argument version returns the name corresponding to the value, or generates a name on the fly. To generate a name, the value is first looked up in the mapping and that name is used if present. Otherwise, the value is broken down into individual bits and the resulting string is the comma-separated names for each of the bits. If the mapping has a name for a bit then it's used. Otherwise, if the bit is greater than or equal to BinaryAnalysis::Reachability::Reason USER_DEFINED_0
the string will be "user-defined-x" where x
is the number of bits to right shift the flag to make it equal to USER_DEFINED_0. Otherwise, the name of the bit is obtained by treating the value as an enum and obtaining the enum name. If that fails due to the fact that not all bits have corresponding enum constants, the name is the hexadecimal string for the bit.
std::string Rose::BinaryAnalysis::Unparser::State::reachabilityName | ( | Reachability::ReasonFlags | value | ) | const |
Assign a reachability name to a reachability value.
The two-argument version of this function associates a name with a value. An empty name clears the association.
The one-argument version returns the name corresponding to the value, or generates a name on the fly. To generate a name, the value is first looked up in the mapping and that name is used if present. Otherwise, the value is broken down into individual bits and the resulting string is the comma-separated names for each of the bits. If the mapping has a name for a bit then it's used. Otherwise, if the bit is greater than or equal to BinaryAnalysis::Reachability::Reason USER_DEFINED_0
the string will be "user-defined-x" where x
is the number of bits to right shift the flag to make it equal to USER_DEFINED_0. Otherwise, the name of the bit is obtained by treating the value as an enum and obtaining the enum name. If that fails due to the fact that not all bits have corresponding enum constants, the name is the hexadecimal string for the bit.
Partitioner2::BasicBlockPtr Rose::BinaryAnalysis::Unparser::State::currentBasicBlock | ( | ) | const |
Points to a relevant basic block.
Tracks the current basic block being emitted, the block that was previously emitted, and the block that we plan to emit next.
void Rose::BinaryAnalysis::Unparser::State::currentBasicBlock | ( | const Partitioner2::BasicBlockPtr & | ) |
Points to a relevant basic block.
Tracks the current basic block being emitted, the block that was previously emitted, and the block that we plan to emit next.
Partitioner2::BasicBlockPtr Rose::BinaryAnalysis::Unparser::State::previousBasicBlock | ( | ) | const |
Points to a relevant basic block.
Tracks the current basic block being emitted, the block that was previously emitted, and the block that we plan to emit next.
void Rose::BinaryAnalysis::Unparser::State::previousBasicBlock | ( | const Partitioner2::BasicBlockPtr & | ) |
Points to a relevant basic block.
Tracks the current basic block being emitted, the block that was previously emitted, and the block that we plan to emit next.
Partitioner2::BasicBlockPtr Rose::BinaryAnalysis::Unparser::State::nextBasicBlock | ( | ) | const |
Points to a relevant basic block.
Tracks the current basic block being emitted, the block that was previously emitted, and the block that we plan to emit next.
void Rose::BinaryAnalysis::Unparser::State::nextBasicBlock | ( | const Partitioner2::BasicBlockPtr & | ) |
Points to a relevant basic block.
Tracks the current basic block being emitted, the block that was previously emitted, and the block that we plan to emit next.
void Rose::BinaryAnalysis::Unparser::State::rotateBasicBlocks | ( | const Partitioner2::BasicBlockPtr & | current, |
const Partitioner2::BasicBlockPtr & | next | ||
) |
Rotate the basic block pointers.
The current and next basic blocks are set as specified. If the specified current block is equal to the existing next block then before assigning the new current block, the existing current block is assigned to the previous block, otherwise the previous block is set to null.