ROSE 0.11.145.147
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 198 of file Unparser/Base.h.

#include <Rose/BinaryAnalysis/Unparser/Base.h>

Public Types

typedef Sawyer::Container::Map< rose_addr_t, 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 &)
 
Partitioner2::BasicBlockPtr currentBasicBlock () const
 
void currentBasicBlock (const Partitioner2::BasicBlockPtr &)
 
const std::string & nextInsnLabel () const
 
void nextInsnLabel (const std::string &)
 
const RegisterNamesregisterNames () const
 
void registerNames (const RegisterNames &r)
 
const AddrStringbasicBlockLabels () const
 
AddrStringbasicBlockLabels ()
 
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.
 
Sawyer::Optional< EdgeArrows::VertexIdcurrentPredSuccId () const
 Property: ID for CFG edge arrow endpoint.
 
void currentPredSuccId (Sawyer::Optional< EdgeArrows::VertexId > id)
 Property: ID for CFG edge arrow endpoint.
 
bool cfgArrowsPointToInsns () const
 Property: Whether CFG margin arrows point to instructions.
 
void cfgArrowsPointToInsns (bool b)
 Property: Whether CFG margin arrows point to instructions.
 
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.
 

Member Typedef Documentation

◆ AddrString

Map from address to string.

Definition at line 200 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 258 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 259 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 275 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 276 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 287 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 288 of file Unparser/Base.h.

◆ currentPredSuccId() [1/2]

Sawyer::Optional< EdgeArrows::VertexId > Rose::BinaryAnalysis::Unparser::State::currentPredSuccId ( ) const
inline

Property: ID for CFG edge arrow endpoint.

When generating margin arrows that point to the "predecessor:" and "successor:" lines of the output (instead of arrows that point to the basic block instructions), this property holds the ID number for the arrow endpoint. See EdgeArrows::computeCfgEdgeLayout.

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

◆ currentPredSuccId() [2/2]

void Rose::BinaryAnalysis::Unparser::State::currentPredSuccId ( Sawyer::Optional< EdgeArrows::VertexId id)
inline

Property: ID for CFG edge arrow endpoint.

When generating margin arrows that point to the "predecessor:" and "successor:" lines of the output (instead of arrows that point to the basic block instructions), this property holds the ID number for the arrow endpoint. See EdgeArrows::computeCfgEdgeLayout.

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

◆ cfgArrowsPointToInsns() [1/2]

bool Rose::BinaryAnalysis::Unparser::State::cfgArrowsPointToInsns ( ) const
inline

Property: Whether CFG margin arrows point to instructions.

If set, then the CFG arrows in the left margin origin from and point to instructions of basic blocks. If false, they originate from "successor:" lines and point to "predecessor:" lines. If there are no CFG margin arrows then the value of this property doesn't matter.

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

◆ cfgArrowsPointToInsns() [2/2]

void Rose::BinaryAnalysis::Unparser::State::cfgArrowsPointToInsns ( bool  b)
inline

Property: Whether CFG margin arrows point to instructions.

If set, then the CFG arrows in the left margin origin from and point to instructions of basic blocks. If false, they originate from "successor:" lines and point to "predecessor:" lines. If there are no CFG margin arrows then the value of this property doesn't matter.

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

◆ styleStack() [1/2]

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

Property: Stack of styles.

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

◆ styleStack() [2/2]

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

Property: Stack of styles.

Definition at line 323 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.


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