ROSE  0.11.145.0
Classes | Public Types | Public Member Functions | List of all members
Rose::BinaryAnalysis::Unparser::EdgeArrows Class Reference

Description

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. More...
 
typedef Sawyer::Container::Graph< VertexId, Sawyer::Nothing, VertexIdGraph
 Graph relating vertices by their edges with vertex index. More...
 

Public Member Functions

void computeLayout (const Graph &, const std::vector< VertexId > &order=std::vector< VertexId >())
 Analyze connectivity in order to assign arrow locations. More...
 
void computeCfgBlockLayout (const Partitioner2::PartitionerConstPtr &, const Partitioner2::FunctionPtr &)
 Compute arrow layout for a control flow graph for a function. More...
 
void computeCfgEdgeLayout (const Partitioner2::PartitionerConstPtr &, const Partitioner2::FunctionPtr &)
 Compute arrow layout for a control flow graph for a function. More...
 
void reset ()
 Reset the analysis. More...
 
size_t nArrowColumns () const
 Number of arrow columns. More...
 
void arrowStyle (ArrowStylePreset, ArrowSide)
 Set the arrow style to a preset value. More...
 
std::string renderBlank () const
 Render a field of blank characters for all the columns. More...
 
std::string render (VertexId, OutputPart) const
 Render arrow columsn for a vertex. More...
 
size_t nSources (VertexId) const
 Number of arrows that emanate from the given vertex. More...
 
size_t nTargets (VertexId) const
 Number of arrows that point to the given vertex. More...
 
void debug (std::ostream &) const
 Print implementation-defined debugging information. More...
 
const ArrowStylearrowStyle () 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. More...
 
static VertexId cfgEdgeTargetEndpoint (size_t edgeId)
 Endpoint ID for CFG edge arrows. More...
 
static ArrowStyle unicodeL1 ()
 Arrow rendering styles. More...
 
static ArrowStyle unicodeR1 ()
 Arrow rendering styles. More...
 
static ArrowStyle unicodeL2 ()
 Arrow rendering styles. More...
 
static ArrowStyle unicodeR2 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiL1 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiR1 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiL2 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiR2 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiL3 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiR3 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiL4 ()
 Arrow rendering styles. More...
 
static ArrowStyle asciiR4 ()
 Arrow rendering styles. More...
 

Member Typedef Documentation

Vertex identification numbers.

Definition at line 41 of file EdgeArrows.h.

Graph relating vertices by their edges with vertex index.

Definition at line 44 of file EdgeArrows.h.

Member Enumeration Documentation

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.

Enumerator
UNICODE_1 

Single-character Unicode arrows.

UNICODE_2 

Two-character Unicode arrows.

Best readability vs. size.

ASCII_1 

Single-character ASCII-art arrows.

Not very readable.

ASCII_2 

Two-character ASCII-art arrows.

Somewhat readable.

ASCII_3 

Threee-character ASCII-art arrows.

Best readability for ASCII.

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.

Member Function Documentation

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 VertexId Rose::BinaryAnalysis::Unparser::EdgeArrows::cfgEdgeSourceEndpoint ( size_t  edgeId)
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 VertexId Rose::BinaryAnalysis::Unparser::EdgeArrows::cfgEdgeTargetEndpoint ( size_t  edgeId)
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.

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.

void Rose::BinaryAnalysis::Unparser::EdgeArrows::arrowStyle ( ArrowStylePreset  ,
ArrowSide   
)

Set the arrow style to a preset value.

static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::unicodeL1 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::unicodeR1 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::unicodeL2 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::unicodeR2 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiL1 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiR1 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiL2 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiR2 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiL3 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiR3 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiL4 ( )
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:

arrows.arrowStyle(unicodeL2());
static ArrowStyle Rose::BinaryAnalysis::Unparser::EdgeArrows::asciiR4 ( )
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:

arrows.arrowStyle(unicodeL2());
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.

std::string Rose::BinaryAnalysis::Unparser::EdgeArrows::render ( VertexId  ,
OutputPart   
) const

Render arrow columsn for a vertex.

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.

void Rose::BinaryAnalysis::Unparser::EdgeArrows::debug ( std::ostream &  ) const

Print implementation-defined debugging information.


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