1#ifndef ROSE_BinaryAnalysis_ControlFlow_H
2#define ROSE_BinaryAnalysis_ControlFlow_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/InstructionMap.h>
10#include "SageBuilderAsm.h"
11#include <AstSimpleProcessing.h>
13#include <boost/foreach.hpp>
14#include <boost/graph/adjacency_list.hpp>
15#include <boost/graph/reverse_graph.hpp>
16#include <boost/graph/depth_first_search.hpp>
17#include <Sawyer/GraphBoost.h>
23namespace BinaryAnalysis {
139 : vertex_filter(NULL), edge_filter(NULL)
161 typedef boost::adjacency_list<boost::setS,
163 boost::bidirectionalS,
164 boost::property<boost::vertex_name_t, SgAsmBlock*> >
BlockGraph;
184 typedef boost::adjacency_list<boost::setS,
186 boost::bidirectionalS,
187 boost::property<boost::vertex_name_t, SgAsmInstruction*> >
InsnGraph;
255 return filter && !(*filter)(
this, src, dst);
263 VertexFilter *vertex_filter;
264 EdgeFilter *edge_filter;
293 template<
class ControlFlowGraph>
309 template<
class ControlFlowGraph>
342 template<
class ControlFlowGraph>
345 template<
class ControlFlowGraph>
348 template<
class ControlFlowGraph>
351 template<
class ControlFlowGraph>
357 template<
class BlockCFG,
class InsnCFG>
364 template<
class InsnCFG>
376 template<
class ControlFlowGraph>
379 template<
class ControlFlowGraph>
393 template<
class ControlFlowGraph>
394 ControlFlowGraph
copy(
const ControlFlowGraph &src);
396 template<
class ControlFlowGraph>
397 void copy(
const ControlFlowGraph &src, ControlFlowGraph &dst);
407 std::vector<typename boost::graph_traits<CFG>::vertex_descriptor> vertices;
408 std::vector<typename boost::graph_traits<CFG>::edge_descriptor> edges;
414 void operator()(std::ostream &,
typename boost::graph_traits<CFG>::vertex_descriptor)
const {}
420 void operator()(std::ostream&,
typename boost::graph_traits<CFG>::edge_descriptor )
const {}
425 template<
typename CFG,
class VertexPropertyWriter,
class EdgePropertyWriter>
426 void write_graphviz(std::ostream&,
const CFG&,
const VertexPropertyWriter&,
const EdgePropertyWriter&);
428 template<
typename CFG>
433 template<
typename CFG,
class VertexPropertyWriter>
434 void write_graphviz(std::ostream &out,
const CFG &cfg,
const VertexPropertyWriter &vpw) {
445 template<
class ControlFlowGraph>
446 struct FlowOrder:
public boost::default_dfs_visitor {
447 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
448 typedef std::vector<Vertex> VertexList;
449 typedef std::vector<size_t> ReverseVertexList;
450 VertexList *forward_order;
451 FlowOrder(VertexList *forward_order): forward_order(forward_order) {}
452 void compute(
const ControlFlowGraph &g,
Vertex v0, ReverseVertexList *reverse_order);
453 void finish_vertex(
Vertex v, ControlFlowGraph g);
458 template<
class ControlFlowGraph>
461 ControlFlow *analyzer;
462 ControlFlowGraph &cfg;
463 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
465 BlockVertexMap &bv_map;
466 VertexInserter(ControlFlow *analyzer, ControlFlowGraph &cfg, BlockVertexMap &bv_map)
467 : analyzer(analyzer), cfg(cfg), bv_map(bv_map)
470 void conditionally_add_vertex(
SgAsmBlock *block);
472 void visit(
SgNode *node) {
473 if (isSgAsmFunction(node)) {
477 conditionally_add_vertex(isSgAsmFunction(node)->get_entryBlock());
479 conditionally_add_vertex(isSgAsmBlock(node));
517 template<
class ControlFlowGraph>
518 std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
520 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start,
521 std::vector<size_t> *reverse_order=NULL);
525 template<
class ControlFlowGraph>
526 struct ReturnBlocks:
public boost::default_dfs_visitor {
527 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
528 typedef std::vector<Vertex> Vector;
530 ReturnBlocks(Vector &blocks): blocks(blocks) {}
531 void finish_vertex(
Vertex v, ControlFlowGraph g);
542 template<
class ControlFlowGraph>
543 std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
545 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start);
555template<
class V,
class E>
559 typename CFG::ConstVertexValueIterator iter = cfg.findVertex(vertexId);
566template<
class V,
class E,
class AstNode>
570 typename CFG::VertexValueIterator iter = cfg.findVertex(vertexId);
576template<
class A,
class B,
class C,
class D,
class E,
class F,
class G>
577typename boost::property_traits<typename boost::property_map<boost::adjacency_list<A, B, C, D, E, F, G>,
578 boost::vertex_name_t>::type>::value_type
579get_ast_node(
const boost::adjacency_list<A, B, C, D, E, F, G> &cfg,
580 typename boost::graph_traits<boost::adjacency_list<A, B, C, D, E, F, G> >::vertex_descriptor vertex) {
581 return boost::get(boost::vertex_name, cfg, vertex);
585template<
class A,
class B,
class C,
class D,
class E,
class F,
class G>
587put_ast_node(boost::adjacency_list<A, B, C, D, E, F, G> &cfg,
588 typename boost::graph_traits<boost::adjacency_list<A, B, C, D, E, F, G> >::vertex_descriptor vertex,
589 typename boost::property_traits<
590 typename boost::property_map<boost::adjacency_list<A, B, C, D, E, F, G>, boost::vertex_name_t>::type
591 >::value_type ast_node) {
592 boost::put(boost::vertex_name, cfg, vertex, ast_node);
599template<
class ControlFlowGraph>
603 typename boost::graph_traits<ControlFlowGraph>::vertex_iterator vi, vi_end;
604 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
610 const SgAsmIntegerValuePtrList &targets = block->
get_successors();
611 for (SgAsmIntegerValuePtrList::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti)
617 typename boost::graph_traits<ControlFlowGraph>::out_edge_iterator ei, ei_end;
618 for (boost::tie(ei, ei_end)=boost::out_edges(*vi, cfg); ei!=ei_end; ++ei) {
622 target->makeRelativeTo(target_block);
623 target->set_parent(block);
630template<
class ControlFlowGraph>
634 typename boost::graph_traits<ControlFlowGraph>::vertex_iterator vi, vi_end;
635 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
642template<
class ControlFlowGraph>
644ControlFlow::VertexInserter<ControlFlowGraph>::conditionally_add_vertex(
SgAsmBlock *block)
646 if (block && block->
hasInstructions() && !analyzer->is_vertex_filtered(block) && !bv_map.exists(block)) {
647 Vertex vertex = boost::add_vertex(cfg);
648 bv_map[block] = vertex;
653template<
class ControlFlowGraph>
657 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
658 Vertex NO_VERTEX = boost::graph_traits<ControlFlowGraph>::null_vertex();
660 BlockVertexMap bv_map;
664 VertexInserter<ControlFlowGraph>(
this, cfg, bv_map).traverse(root, preorder);
668 for (
typename BlockVertexMap::iterator bvi=bv_map.begin(); bvi!=bv_map.end(); ++bvi)
669 addrToVertex[bvi->first->get_address()] = bvi->second;
672 BOOST_FOREACH (
Vertex sourceVertex, boost::vertices(cfg)) {
675 Vertex targetVertex = addrToVertex.
get_value_or(integerValue->get_absoluteValue(), NO_VERTEX);
676 if (targetVertex!=NO_VERTEX) {
678 assert(targetBlock!=NULL);
680 boost::add_edge(sourceVertex, targetVertex, cfg);
686template<
class ControlFlowGraph>
693 bool preserve_call_fallthrough_edges =
false;
697template<
class ControlFlowGraph>
705 SgAsmFunction *src_func = SageInterface::getEnclosingNode<SgAsmFunction>(src,
true);
706 SgAsmBlock *dst_block = SageInterface::getEnclosingNode<SgAsmBlock>(dst,
true);
707 SgAsmFunction *dst_func = SageInterface::getEnclosingNode<SgAsmFunction>(dst_block);
708 if (!src_func || !dst_func || dst_block!=dst_func->
get_entryBlock()) {
710 }
else if (src_func!=dst_func) {
715 return parent ? (*parent)(analyzer, src, dst) :
true;
720 T1 edge_filter(parent);
731template<
class ControlFlowGraph>
735 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
736 Vertex NO_VERTEX = boost::graph_traits<ControlFlowGraph>::null_vertex();
739 std::vector<Vertex> src_to_dst(boost::num_vertices(src), NO_VERTEX);
741 typename boost::graph_traits<const ControlFlowGraph>::vertex_iterator vi, vi_end;
742 for (boost::tie(vi, vi_end)=boost::vertices(src); vi!=vi_end; ++vi) {
745 src_to_dst[*vi] = boost::add_vertex(dst);
750 typename boost::graph_traits<const ControlFlowGraph>::edge_iterator ei, ei_end;
751 for (boost::tie(ei, ei_end)=boost::edges(src); ei!=ei_end; ++ei) {
752 if (NO_VERTEX!=src_to_dst[boost::source(*ei, src)] && NO_VERTEX!=src_to_dst[boost::target(*ei, src)]) {
756 boost::add_edge(src_to_dst[boost::source(*ei, src)], src_to_dst[boost::target(*ei, src)], dst);
761template<
class ControlFlowGraph>
765 ControlFlowGraph dst;
770template<
class BlockCFG,
class InsnCFG>
775 typedef typename boost::graph_traits<const BlockCFG>::vertex_descriptor BlockCFG_Vertex;
776 typedef typename boost::graph_traits<const BlockCFG>::vertex_iterator BlockCFG_VertexIterator;
777 typedef typename boost::graph_traits<const BlockCFG>::edge_iterator BlockCFG_EdgeIterator;
781 typedef typename boost::graph_traits<InsnCFG>::vertex_descriptor InsnCFG_Vertex;
782 typedef std::pair<InsnCFG_Vertex, InsnCFG_Vertex> InsnCFG_VertexPair;
788 BlockCFG_VertexIterator vi, vi_end;
789 for (boost::tie(vi, vi_end)=boost::vertices(cfgb); vi!=vi_end; ++vi) {
792 assert(!insns.empty());
793 InsnCFG_Vertex enter_vertex = boost::graph_traits<InsnCFG>::null_vertex();
794 InsnCFG_Vertex prev_vertex = boost::graph_traits<InsnCFG>::null_vertex();
795 for (SgAsmStatementPtrList::const_iterator ii=insns.begin(); ii!=insns.end(); ++ii) {
798 InsnCFG_Vertex vertex = boost::add_vertex(cfgi);
800 if (ii==insns.begin()) {
801 enter_vertex = vertex;
803 boost::add_edge(prev_vertex, vertex, cfgi);
805 prev_vertex = vertex;
807 assert(prev_vertex!=boost::graph_traits<InsnCFG>::null_vertex());
808 vertex_translation[*vi] = InsnCFG_VertexPair(enter_vertex, prev_vertex);
815 BlockCFG_EdgeIterator ei, ei_end;
816 for (boost::tie(ei, ei_end)=boost::edges(cfgb); ei!=ei_end; ++ei) {
817 InsnCFG_Vertex src_leave_vertex = vertex_translation.
get_one(boost::source(*ei, cfgb)).second;
818 InsnCFG_Vertex dst_enter_vertex = vertex_translation.
get_one(boost::target(*ei, cfgb)).first;
819 assert(src_leave_vertex!=boost::graph_traits<InsnCFG>::null_vertex());
820 assert(dst_enter_vertex!=boost::graph_traits<InsnCFG>::null_vertex());
821 boost::add_edge(src_leave_vertex, dst_enter_vertex, cfgi);
826template<
class InsnCFG>
830 typedef typename boost::graph_traits<InsnCFG>::vertex_descriptor CFG_Vertex;
831 typedef typename boost::graph_traits<InsnCFG>::vertex_iterator CFG_VertexIterator;
832 typedef typename boost::graph_traits<InsnCFG>::in_edge_iterator CFG_InEdgeIterator;
833 typedef std::pair<CFG_Vertex, CFG_Vertex> CFG_VertexPair;
835 CFG_Vertex NO_VERTEX = boost::graph_traits<InsnCFG>::null_vertex();
841 InsnToVertex insn_to_vertex;
842 std::vector<bool> isret(boost::num_vertices(cfg),
false);
844 CFG_VertexIterator vi, vi_end;
845 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
848 insn_to_vertex[insn] = *vi;
850 if (0==boost::out_degree(*vi, cfg)) {
853 isret[*vi] = x86_ret==insn_x86->get_kind();
860 struct FunctionEntryVertex {
861 const InsnToVertex &insn_to_vertex;
863 FunctionEntryVertex(
const InsnToVertex &insn_to_vertex,
const InstructionMap &imap)
864 : insn_to_vertex(insn_to_vertex), imap(imap) {}
866 SgAsmFunction *func = SageInterface::getEnclosingNode<SgAsmFunction>(insn,
true);
868 CFG_Vertex entry_vertex = insn_to_vertex.get_one(entry_insn);
871 } function_entry_vertex(insn_to_vertex, insns);
874 std::vector<CFG_VertexPair> edges_to_insert, edges_to_erase;
876 CFG_VertexIterator vi, vi_end;
877 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
878 CFG_Vertex returner_vertex = *vi;
879 if (!isret[returner_vertex])
887 std::vector<bool> seen(boost::num_vertices(cfg),
false);
889 worklist.
push(function_entry_vertex(returner_insn));
890 while (!worklist.
empty()) {
891 CFG_Vertex callee_vertex = worklist.
shift();
892 CFG_InEdgeIterator ei, ei_end;
893 for (boost::tie(ei, ei_end)=boost::in_edges(callee_vertex, cfg); ei!=ei_end; ++ei) {
894 CFG_Vertex caller_vertex = boost::source(*ei, cfg);
895 if (!seen[caller_vertex]) {
896 seen[caller_vertex] =
true;
898 SgAsmBlock *caller_block = SageInterface::getEnclosingNode<SgAsmBlock>(caller_insn);
899 assert(caller_block!=NULL);
900 rose_addr_t target_va, returnee_va;
905 CFG_Vertex returnee_vertex = insn_to_vertex.get_value_or(returnee_insn, NO_VERTEX);
906 if (returnee_vertex!=NO_VERTEX) {
907 edges_to_insert.push_back(CFG_VertexPair(returner_vertex, returnee_vertex));
908 edges_to_erase.push_back(CFG_VertexPair(caller_vertex, returnee_vertex));
914 worklist.
push(function_entry_vertex(caller_insn));
923 if (!preserve_call_fallthrough_edges) {
924 for (
size_t i=0; i<edges_to_erase.size(); ++i)
925 boost::remove_edge(edges_to_erase[i].first, edges_to_erase[i].second, cfg);
927 for (
size_t i=0; i<edges_to_insert.size(); ++i)
928 boost::add_edge(edges_to_insert[i].first, edges_to_insert[i].second, cfg);
931template<
class ControlFlowGraph>
933ControlFlow::FlowOrder<ControlFlowGraph>::compute(
const ControlFlowGraph &g,
Vertex v0,
934 ReverseVertexList *reverse_order) {
935 forward_order->clear();
936 std::vector<boost::default_color_type> colors(boost::num_vertices(g), boost::white_color);
937 boost::depth_first_visit(g, v0, *
this, &(colors[0]));
938 assert(!forward_order->empty());
939 std::reverse(forward_order->begin(), forward_order->end());
941 reverse_order->clear();
942 reverse_order->resize(boost::num_vertices(g),
INVALID_INDEX);
943 for (
size_t i=0; i<forward_order->size(); i++)
944 (*reverse_order)[(*forward_order)[i]] = i;
948template<
class ControlFlowGraph>
950ControlFlow::FlowOrder<ControlFlowGraph>::finish_vertex(
Vertex v, ControlFlowGraph) {
951 forward_order->push_back(v);
954template<
class ControlFlowGraph>
955std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
957 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start,
958 std::vector<size_t> *reverse_order)
960 std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor> forward_order;
961 FlowOrder<ControlFlowGraph>(&forward_order).compute(cfg, start, reverse_order);
962 return forward_order;
965template<
class ControlFlowGraph>
967ControlFlow::ReturnBlocks<ControlFlowGraph>::finish_vertex(
Vertex v, ControlFlowGraph g)
969 typename boost::graph_traits<ControlFlowGraph>::out_edge_iterator ei, ei_end;
970 boost::tie(ei, ei_end) = boost::out_edges(v, g);
975template<
class ControlFlowGraph>
976std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
978 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start)
980 typename ReturnBlocks<ControlFlowGraph>::Vector result;
981 ReturnBlocks<ControlFlowGraph> visitor(result);
982 std::vector<boost::default_color_type> colors(boost::num_vertices(cfg), boost::white_color);
983 boost::depth_first_visit(cfg, start, visitor, &(colors[0]));
987template<
class ControlFlowGraph>
991 ControlFlowGraph cfg;
996template<
class ControlFlowGraph>
1000 ControlFlowGraph cfg;
1005template<
class ControlFlowGraph>
1009 ControlFlowGraph cfg;
1015template<
typename CFG,
class VertexPropertyWriter,
class EdgePropertyWriter>
1018 const VertexPropertyWriter &vpw,
const EdgePropertyWriter &epw)
1021 typedef typename boost::graph_traits<CFG>::edge_descriptor CFG_Edge;
1022 typedef typename boost::graph_traits<CFG>::vertex_iterator CFG_VertexIterator;
1023 typedef typename boost::graph_traits<CFG>::out_edge_iterator CFG_OutEdgeIterator;
1028 std::vector<CFG_Edge> interfunc_edges;
1029 CFG_VertexIterator vi, vi_end;
1030 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
1033 f.vertices.push_back(*vi);
1034 CFG_OutEdgeIterator ei, ei_end;
1035 for (boost::tie(ei, ei_end)=boost::out_edges(*vi, cfg); ei!=ei_end; ++ei) {
1037 SgAsmFunction *tgt_func = SageInterface::getEnclosingNode<SgAsmFunction>(tgt_node,
true);
1038 if (tgt_func==func) {
1039 f.edges.push_back(*ei);
1041 interfunc_edges.push_back(*ei);
1047 out <<
"digraph G {\n";
1048 for (
typename Functions::iterator fi=funcs.begin(); fi!=funcs.end(); ++fi) {
1050 if (!f.vertices.empty() || !f.edges.empty()) {
1052 SgAsmFunction *func = SageInterface::getEnclosingNode<SgAsmFunction>(node,
true);
1053 const size_t maxNameSize = 63;
1054 char cluster_name[maxNameSize+1];
1055 snprintf(cluster_name, maxNameSize,
"cluster_F%" PRIx64, func->
get_entryVa());
1056 out <<
" subgraph " <<cluster_name <<
" {\n"
1057 <<
" style=filled;\n"
1058 <<
" color=lightgrey;\n"
1060 <<(func->
get_name().empty()?std::string(
""):(
" <"+func->
get_name()+
">")) <<
"\";\n";
1061 for (
size_t i=0; i<f.vertices.size(); ++i) {
1062 out <<
" " <<f.vertices[i];
1063 vpw(out, f.vertices[i]);
1066 for (
size_t i=0; i<f.edges.size(); ++i) {
1067 out <<
" " <<boost::source(f.edges[i], cfg) <<
"->" <<boost::target(f.edges[i], cfg);
1068 epw(out, f.edges[i]);
1076 for (
size_t i=0; i<interfunc_edges.size(); ++i) {
1077 out <<
" " <<boost::source(interfunc_edges[i], cfg) <<
"->" <<boost::target(interfunc_edges[i], cfg);
1078 epw(out, interfunc_edges[i]);
Class for traversing the AST.
Extends std::map with methods that return optional values.
const T & get_value_or(const Key &key, const T &dflt) const
Convenience for getting a value from an Option.
const T & get_one(const Key &key) const
Look up one value or throw an exception.
Binary control flow analysis.
void fixup_fcall_fret(InsnCFG &cfg, bool preserve_call_fallthrough_edges)
Fix up a CFG by changing function call and return edges.
void set_vertex_filter(VertexFilter *filter)
Manipulate the vertex filter.
ControlFlowGraph build_insn_cfg_from_ast(SgNode *root)
Builds a control flow graph for part of an AST.
void clear_ast(SgNode *ast)
Clears successor information from the AST.
void apply_to_ast(const ControlFlowGraph &)
Applies graph to AST.
bool is_edge_filtered(SgAsmNode *src, SgAsmNode *dst, EdgeFilter *filter)
Determines if an edge is filtered out.
std::vector< typename boost::graph_traits< ControlFlowGraph >::vertex_descriptor > flow_order(const ControlFlowGraph &, typename boost::graph_traits< ControlFlowGraph >::vertex_descriptor start, std::vector< size_t > *reverse_order=NULL)
Orders nodes by depth first search reverse post order.
ControlFlowGraph copy(const ControlFlowGraph &src)
Copies a graph while filtering.
void explode_blocks(const BlockCFG &cfgb, InsnCFG &cfgi)
Create an instruction control flow graph from a basic block control flow graph.
void set_edge_filter(EdgeFilter *filter)
Manipulate the edge filter.
void write_graphviz(std::ostream &, const CFG &, const VertexPropertyWriter &, const EdgePropertyWriter &)
Write a CFG to a graphviz file, creating a cluster subgraph for each function.
bool is_edge_filtered(SgAsmNode *src, SgAsmNode *dst)
Determines if an edge is filtered out.
VertexFilter * get_vertex_filter() const
Manipulate the vertex filter.
void write_graphviz(std::ostream &out, const CFG &cfg, const VertexPropertyWriter &vpw)
Write a CFG to a graphviz file, creating a cluster subgraph for each function.
boost::adjacency_list< boost::setS, boost::vecS, boost::bidirectionalS, boost::property< boost::vertex_name_t, SgAsmInstruction * > > InsnGraph
Default instruction-based control flow graph.
EdgeFilter * get_edge_filter() const
Manipulate the edge filter.
ControlFlowGraph build_block_cfg_from_ast(SgNode *root)
Builds a control flow graph for part of an AST.
bool is_vertex_filtered(SgAsmNode *bb_or_insn)
Determines if a vertex is filtered out.
boost::adjacency_list< boost::setS, boost::vecS, boost::bidirectionalS, boost::property< boost::vertex_name_t, SgAsmBlock * > > BlockGraph
Default basic block control flow graph type.
void cache_vertex_descriptors(const ControlFlowGraph &)
Cache basic block vertex descriptors in AST.
bool is_vertex_filtered(SgAsmNode *bb_or_insn, VertexFilter *filter)
Determines if a vertex is filtered out.
BlockGraph Graph
Default control flow graph.
ControlFlowGraph build_cg_from_ast(SgNode *root)
Builds a control flow graph with only function call edges.
void write_graphviz(std::ostream &out, const CFG &cfg)
Write a CFG to a graphviz file, creating a cluster subgraph for each function.
std::vector< typename boost::graph_traits< ControlFlowGraph >::vertex_descriptor > return_blocks(const ControlFlowGraph &cfg, typename boost::graph_traits< ControlFlowGraph >::vertex_descriptor start)
Returns list of function return blocks.
Graph containing user-defined vertices and edges.
V VertexValue
User-level data associated with vertices.
void set_cachedVertex(size_t const &)
Property: Cached vertex for control flow graphs.
bool isFunctionCall(rose_addr_t &target_va, rose_addr_t &return_va)
Returns true if basic block appears to be a function call.
SgAsmIntegerValuePtrList const & get_successors() const
Property: Control flow successors.
void set_successorsComplete(bool const &)
Property: Whether the successors list is complete.
SgAsmStatementPtrList const & get_statementList() const
Property: Statements of which this block is composed.
bool hasInstructions() const
Determins if a block contains instructions.
Represents a synthesized function.
rose_addr_t const & get_entryVa() const
Property: Primary entry address.
SgAsmBlock * get_entryBlock() const
Function entry basic block.
std::string const & get_name() const
Property: Name.
Base class for machine instructions.
Base class for integer values.
Base class for all binary analysis IR nodes.
rose_addr_t const & get_address() const
Property: Starting virtual address.
Represents one Intel x86 machine instruction.
This class represents the base class for all IR nodes within Sage III.
List of things to work on.
bool push(const T &, boost::tribool check_uniqueness=boost::logic::indeterminate)
Add an item to the back of the work list.
bool empty() const
Returns true if this work list is empty.
T shift()
Remove and return the item from the front of the work list.
Sawyer::Container::Graph< V, E >::VertexValue get_ast_node(const Sawyer::Container::Graph< V, E > &cfg, size_t vertexId)
Return the AST node associated with a vertex.
void put_ast_node(Sawyer::Container::Graph< V, E > &cfg, size_t vertexId, AstNode *astNode)
Set the AST node associated with a vertex.
ROSE_UTIL_API std::string addrToString(uint64_t value, size_t nbits=0)
Convert a virtual address to a string.
ROSE_UTIL_API std::string numberToString(long long)
Convert an integer to a string.
const size_t INVALID_INDEX
Invalid array index.
Default edge property writer is a no-op.
Default vertex property writer is a no-op.
List of vertices and intra-function edges for one function.