ROSE 0.11.145.272
Public Types | Public Member Functions | List of all members
Rose::BinaryAnalysis::Unparser::State Class Reference

Description

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::FunctionCallGraphcg () 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 &current, const Partitioner2::BasicBlockPtr &next)
 Rotate the basic block pointers.
 
SgAsmExpressioncurrentExpression () const
 
void currentExpression (SgAsmExpression *)
 
const std::string & nextInsnLabel () const
 
void nextInsnLabel (const std::string &)
 
const RegisterNamesregisterNames () const
 
void registerNames (const RegisterNames &r)
 
const AddrStringbasicBlockLabels () const
 
AddrStringbasicBlockLabels ()
 
bool isPostInstruction () const
 
void isPostInstruction (bool)
 
const BasefrontUnparser () const
 First unparser in the chained list of unparsers.
 
const std::vector< Reachability::ReasonFlagscfgVertexReachability () const
 Property: Reachability analysis results.
 
void cfgVertexReachability (const std::vector< Reachability::ReasonFlags > &)
 Property: Reachability analysis results.
 
const ArrowMarginintraFunctionCfgArrows () const
 Control flow graph arrows within a function.
 
ArrowMarginintraFunctionCfgArrows ()
 Control flow graph arrows within a function.
 
const ArrowMarginintraFunctionBlockArrows () const
 User-defined intra-function margin arrows.
 
ArrowMarginintraFunctionBlockArrows ()
 User-defined intra-function margin arrows.
 
const ArrowMarginglobalBlockArrows () const
 User-defined arrows to basic blocks across entire output.
 
ArrowMarginglobalBlockArrows ()
 User-defined arrows to basic blocks across entire output.
 
const StyleStackstyleStack () const
 Property: Stack of styles.
 
StyleStackstyleStack ()
 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.
 

Member Typedef Documentation

◆ AddrString

Map from address to string.

Definition at line 280 of file Unparser/Base.h.

Member Function Documentation

◆ cfgVertexReachability() [1/2]

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.

◆ cfgVertexReachability() [2/2]

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.

◆ isCfgVertexReachable()

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.

◆ intraFunctionCfgArrows() [1/2]

const ArrowMargin & Rose::BinaryAnalysis::Unparser::State::intraFunctionCfgArrows ( ) const
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.

◆ intraFunctionCfgArrows() [2/2]

ArrowMargin & Rose::BinaryAnalysis::Unparser::State::intraFunctionCfgArrows ( )
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.

◆ intraFunctionBlockArrows() [1/2]

const ArrowMargin & Rose::BinaryAnalysis::Unparser::State::intraFunctionBlockArrows ( ) const
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.

◆ intraFunctionBlockArrows() [2/2]

ArrowMargin & Rose::BinaryAnalysis::Unparser::State::intraFunctionBlockArrows ( )
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.

◆ globalBlockArrows() [1/2]

const ArrowMargin & Rose::BinaryAnalysis::Unparser::State::globalBlockArrows ( ) const
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.

◆ globalBlockArrows() [2/2]

ArrowMargin & Rose::BinaryAnalysis::Unparser::State::globalBlockArrows ( )
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.

◆ styleStack() [1/2]

const StyleStack & Rose::BinaryAnalysis::Unparser::State::styleStack ( ) const
inline

Property: Stack of styles.

Definition at line 380 of file Unparser/Base.h.

◆ styleStack() [2/2]

StyleStack & Rose::BinaryAnalysis::Unparser::State::styleStack ( )
inline

Property: Stack of styles.

Definition at line 381 of file Unparser/Base.h.

◆ reachabilityName() [1/2]

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.

◆ reachabilityName() [2/2]

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.

◆ currentBasicBlock() [1/2]

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.

◆ currentBasicBlock() [2/2]

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.

◆ previousBasicBlock() [1/2]

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.

◆ previousBasicBlock() [2/2]

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.

◆ nextBasicBlock() [1/2]

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.

◆ nextBasicBlock() [2/2]

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.

◆ rotateBasicBlocks()

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.


The documentation for this class was generated from the following file: