ROSE 0.11.145.147
|
Analysis to generate arrows from one basic block to another.
Oftentimes there's a desire to print arrows from one basic block to another to represent control flow, dependencies, other other analysis results. This class is meant to be a general-purpose way to compute the start end end of arrows using a variety of layouts. The layout that's currently implemented assumes a line-oriented output where each basic block occupies at least two lines. The first line of the basic block is for edges going into the block (where the block is the target of an edge), and the last line is for edges leaving the block.
Definition at line 30 of file EdgeArrows.h.
#include <Rose/BinaryAnalysis/Unparser/EdgeArrows.h>
Classes | |
struct | ArrowStyle |
Arrow text. More... | |
Public Types | |
enum | OutputPart { FIRST_LINE , LAST_LINE , MIDDLE_LINE , INTER_LINE } |
Parts of the output. More... | |
enum | ArrowStylePreset { UNICODE_1 , UNICODE_2 , ASCII_1 , ASCII_2 , ASCII_3 } |
Arrow style presets. More... | |
enum | ArrowSide { LEFT , RIGHT } |
On which side of the listing do the errors appear. More... | |
typedef rose_addr_t | VertexId |
Vertex identification numbers. | |
typedef Sawyer::Container::Graph< VertexId, Sawyer::Nothing, VertexId > | Graph |
Graph relating vertices by their edges with vertex index. | |
Public Member Functions | |
void | computeLayout (const Graph &, const std::vector< VertexId > &order=std::vector< VertexId >()) |
Analyze connectivity in order to assign arrow locations. | |
void | computeCfgBlockLayout (const Partitioner2::PartitionerConstPtr &, const Partitioner2::FunctionPtr &) |
Compute arrow layout for a control flow graph for a function. | |
void | computeCfgEdgeLayout (const Partitioner2::PartitionerConstPtr &, const Partitioner2::FunctionPtr &) |
Compute arrow layout for a control flow graph for a function. | |
void | reset () |
Reset the analysis. | |
size_t | nArrowColumns () const |
Number of arrow columns. | |
void | arrowStyle (ArrowStylePreset, ArrowSide) |
Set the arrow style to a preset value. | |
std::string | renderBlank () const |
Render a field of blank characters for all the columns. | |
std::string | render (VertexId, OutputPart) const |
Render arrow columsn for a vertex. | |
size_t | nSources (VertexId) const |
Number of arrows that emanate from the given vertex. | |
size_t | nTargets (VertexId) const |
Number of arrows that point to the given vertex. | |
void | debug (std::ostream &) const |
Print implementation-defined debugging information. | |
const ArrowStyle & | arrowStyle () const |
Property: Information about how to render an arrow. | |
void | arrowStyle (const ArrowStyle &t) |
Property: Information about how to render an arrow. | |
Static Public Member Functions | |
static VertexId | cfgEdgeSourceEndpoint (size_t edgeId) |
Endpoint ID for CFG edge arrows. | |
static VertexId | cfgEdgeTargetEndpoint (size_t edgeId) |
Endpoint ID for CFG edge arrows. | |
static ArrowStyle | unicodeL1 () |
Arrow rendering styles. | |
static ArrowStyle | unicodeR1 () |
Arrow rendering styles. | |
static ArrowStyle | unicodeL2 () |
Arrow rendering styles. | |
static ArrowStyle | unicodeR2 () |
Arrow rendering styles. | |
static ArrowStyle | asciiL1 () |
Arrow rendering styles. | |
static ArrowStyle | asciiR1 () |
Arrow rendering styles. | |
static ArrowStyle | asciiL2 () |
Arrow rendering styles. | |
static ArrowStyle | asciiR2 () |
Arrow rendering styles. | |
static ArrowStyle | asciiL3 () |
Arrow rendering styles. | |
static ArrowStyle | asciiR3 () |
Arrow rendering styles. | |
static ArrowStyle | asciiL4 () |
Arrow rendering styles. | |
static ArrowStyle | asciiR4 () |
Arrow rendering styles. | |
typedef rose_addr_t Rose::BinaryAnalysis::Unparser::EdgeArrows::VertexId |
Vertex identification numbers.
Definition at line 41 of file EdgeArrows.h.
typedef Sawyer::Container::Graph<VertexId, Sawyer::Nothing, VertexId> Rose::BinaryAnalysis::Unparser::EdgeArrows::Graph |
Graph relating vertices by their edges with vertex index.
Definition at line 44 of file EdgeArrows.h.
Parts of the output.
Enumerator | |
---|---|
FIRST_LINE | First line of a vertex when printed. |
LAST_LINE | Last line of a vertex when printed. |
MIDDLE_LINE | Lines in the middle of a printed vertex. |
INTER_LINE | Lines output between vertices. |
Definition at line 33 of file EdgeArrows.h.
Arrow style presets.
Definition at line 61 of file EdgeArrows.h.
On which side of the listing do the errors appear.
Enumerator | |
---|---|
LEFT | Arrows appear left of the listing and point to the right. |
RIGHT | Arrows appear right of the listing and point to the left. |
Definition at line 70 of file EdgeArrows.h.
|
inline |
Definition at line 113 of file EdgeArrows.h.
void Rose::BinaryAnalysis::Unparser::EdgeArrows::computeLayout | ( | const Graph & | , |
const std::vector< VertexId > & | order = std::vector< VertexId >() |
||
) |
Analyze connectivity in order to assign arrow locations.
Analyzes the connectivity of the vertices specified in the graph
, and the optional vertex order
in order to calculate the locations of the margin arrows. The vertices of the graph are assumed to be output in the order listed in the order
argument. Any vertices that are present in the graph
but not in the order
specification are sorted by ID and then appended to the order
.
This does not clear previous layout information, and so it can be used to append to previous output. To discard previous layout information first, call reset.
void Rose::BinaryAnalysis::Unparser::EdgeArrows::computeCfgBlockLayout | ( | const Partitioner2::PartitionerConstPtr & | , |
const Partitioner2::FunctionPtr & | |||
) |
Compute arrow layout for a control flow graph for a function.
This produces arrows for intra-function CFG edges such that the arrows' sources and targets are basic blocks. That is, in the unparser output, arrows will point to the first instruction of a basic block and emanate from the last instruction. This method assumes that the unparser emits a function's basic blocks in order of their starting address.
See also, computeCfgEdgeLayout
void Rose::BinaryAnalysis::Unparser::EdgeArrows::computeCfgEdgeLayout | ( | const Partitioner2::PartitionerConstPtr & | , |
const Partitioner2::FunctionPtr & | |||
) |
Compute arrow layout for a control flow graph for a function.
This produces arrows for intra-function CFG edges such that the arrows' sources and targets are the "predecessor" and "successor" lines emitted by the unparser before and after each basic block. That is, each arrow points to its corresponding "predecessor" line, and emanates from its corresponding "successor" line. This method assumes that the unparser emits a function's basic blocks in order of their starting address, and emits the "predecessor" and "successor" lines in the order they appear in the partitioner control flow graph (from vertex.inEdges
and vertex.outEdges
, respectively). It also assumes that "predecessors" are listed before "successors".
See also, computeCfgBlockLayout
|
static |
Endpoint ID for CFG edge arrows.
Returns the endpoint ID for the specified CFG edge. These are the IDs that correspond to those used by computeCfgEdgeLayout. The edge must be a valid edge, not an end iterator.
|
static |
Endpoint ID for CFG edge arrows.
Returns the endpoint ID for the specified CFG edge. These are the IDs that correspond to those used by computeCfgEdgeLayout. The edge must be a valid edge, not an end iterator.
void Rose::BinaryAnalysis::Unparser::EdgeArrows::reset | ( | ) |
Reset the analysis.
This clears previous layout information but not rendering information. I.e., the arrows are all erased, but the arrow style and other properties are not affected.
Referenced by Rose::BinaryAnalysis::Unparser::ArrowMargin::reset().
size_t Rose::BinaryAnalysis::Unparser::EdgeArrows::nArrowColumns | ( | ) | const |
Number of arrow columns.
This is the number of columns needed for the arrows measured in terms of arrows.
If you want the number of columns of characters (rather than arrows) you should multiply the return value of this function by arrowStyle.charactersPerColumn
.
|
inline |
Property: Information about how to render an arrow.
Definition at line 176 of file EdgeArrows.h.
|
inline |
Property: Information about how to render an arrow.
Definition at line 177 of file EdgeArrows.h.
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
|
static |
Arrow rendering styles.
These functions have names that follow a regular pattern. The first part of the name describes the character set used for the arrows. The letters "R" and "L" indicate whether the arrows are to the left or right of the vertices to which they refer (opposite the direction the arrows point). The number indicates the number of characters per column of arrows. The wider formats are easier to read but take up more output space.
To set the arrow style, use code like this:
std::string Rose::BinaryAnalysis::Unparser::EdgeArrows::renderBlank | ( | ) | const |
Render a field of blank characters for all the columns.
Use this to keep tabular output aligned when you're only reserving space for the arrow columns and not actually printing any arrows.
size_t Rose::BinaryAnalysis::Unparser::EdgeArrows::nSources | ( | VertexId | ) | const |
Number of arrows that emanate from the given vertex.
Normally you'd use the original graph to answer this question, but sometimes that graph is long gone. In those cases, you can use this slower function to find the number of arrows that originate from the specified vertex.
size_t Rose::BinaryAnalysis::Unparser::EdgeArrows::nTargets | ( | VertexId | ) | const |
Number of arrows that point to the given vertex.
Normally you'd use the original graph to answer this question, but sometimes that graph is long gone. In those cases, you can use this slower function to find the number of arrows that point to the specified vertex.