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 {
138 : vertex_filter(NULL), edge_filter(NULL)
160 typedef boost::adjacency_list<boost::setS,
162 boost::bidirectionalS,
163 boost::property<boost::vertex_name_t, SgAsmBlock*> >
BlockGraph;
183 typedef boost::adjacency_list<boost::setS,
185 boost::bidirectionalS,
186 boost::property<boost::vertex_name_t, SgAsmInstruction*> >
InsnGraph;
254 return filter && !(*filter)(
this, src, dst);
262 VertexFilter *vertex_filter;
263 EdgeFilter *edge_filter;
292 template<
class ControlFlowGraph>
308 template<
class ControlFlowGraph>
341 template<
class ControlFlowGraph>
344 template<
class ControlFlowGraph>
347 template<
class ControlFlowGraph>
350 template<
class ControlFlowGraph>
356 template<
class BlockCFG,
class InsnCFG>
363 template<
class InsnCFG>
375 template<
class ControlFlowGraph>
378 template<
class ControlFlowGraph>
392 template<
class ControlFlowGraph>
393 ControlFlowGraph
copy(
const ControlFlowGraph &src);
395 template<
class ControlFlowGraph>
396 void copy(
const ControlFlowGraph &src, ControlFlowGraph &dst);
406 std::vector<typename boost::graph_traits<CFG>::vertex_descriptor> vertices;
407 std::vector<typename boost::graph_traits<CFG>::edge_descriptor> edges;
413 void operator()(std::ostream &,
typename boost::graph_traits<CFG>::vertex_descriptor)
const {}
419 void operator()(std::ostream&,
typename boost::graph_traits<CFG>::edge_descriptor )
const {}
424 template<
typename CFG,
class VertexPropertyWriter,
class EdgePropertyWriter>
425 void write_graphviz(std::ostream&,
const CFG&,
const VertexPropertyWriter&,
const EdgePropertyWriter&);
427 template<
typename CFG>
432 template<
typename CFG,
class VertexPropertyWriter>
433 void write_graphviz(std::ostream &out,
const CFG &cfg,
const VertexPropertyWriter &vpw) {
444 template<
class ControlFlowGraph>
445 struct FlowOrder:
public boost::default_dfs_visitor {
446 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
447 typedef std::vector<Vertex> VertexList;
448 typedef std::vector<size_t> ReverseVertexList;
449 VertexList *forward_order;
450 FlowOrder(VertexList *forward_order): forward_order(forward_order) {}
451 void compute(
const ControlFlowGraph &g,
Vertex v0, ReverseVertexList *reverse_order);
452 void finish_vertex(
Vertex v, ControlFlowGraph g);
457 template<
class ControlFlowGraph>
460 ControlFlow *analyzer;
461 ControlFlowGraph &cfg;
462 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
464 BlockVertexMap &bv_map;
465 VertexInserter(ControlFlow *analyzer, ControlFlowGraph &cfg, BlockVertexMap &bv_map)
466 : analyzer(analyzer), cfg(cfg), bv_map(bv_map)
469 void conditionally_add_vertex(
SgAsmBlock *block);
471 void visit(
SgNode *node) {
472 if (isSgAsmFunction(node)) {
476 conditionally_add_vertex(isSgAsmFunction(node)->get_entryBlock());
478 conditionally_add_vertex(isSgAsmBlock(node));
516 template<
class ControlFlowGraph>
517 std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
519 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start,
520 std::vector<size_t> *reverse_order=NULL);
524 template<
class ControlFlowGraph>
525 struct ReturnBlocks:
public boost::default_dfs_visitor {
526 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
527 typedef std::vector<Vertex> Vector;
529 ReturnBlocks(Vector &blocks): blocks(blocks) {}
530 void finish_vertex(
Vertex v, ControlFlowGraph g);
541 template<
class ControlFlowGraph>
542 std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
544 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start);
554template<
class V,
class E>
558 typename CFG::ConstVertexValueIterator iter = cfg.findVertex(vertexId);
565template<
class V,
class E,
class AstNode>
569 typename CFG::VertexValueIterator iter = cfg.findVertex(vertexId);
575template<
class A,
class B,
class C,
class D,
class E,
class F,
class G>
576typename boost::property_traits<typename boost::property_map<boost::adjacency_list<A, B, C, D, E, F, G>,
577 boost::vertex_name_t>::type>::value_type
578get_ast_node(
const boost::adjacency_list<A, B, C, D, E, F, G> &cfg,
579 typename boost::graph_traits<boost::adjacency_list<A, B, C, D, E, F, G> >::vertex_descriptor vertex) {
580 return boost::get(boost::vertex_name, cfg, vertex);
584template<
class A,
class B,
class C,
class D,
class E,
class F,
class G>
586put_ast_node(boost::adjacency_list<A, B, C, D, E, F, G> &cfg,
587 typename boost::graph_traits<boost::adjacency_list<A, B, C, D, E, F, G> >::vertex_descriptor vertex,
588 typename boost::property_traits<
589 typename boost::property_map<boost::adjacency_list<A, B, C, D, E, F, G>, boost::vertex_name_t>::type
590 >::value_type ast_node) {
591 boost::put(boost::vertex_name, cfg, vertex, ast_node);
598template<
class ControlFlowGraph>
602 typename boost::graph_traits<ControlFlowGraph>::vertex_iterator vi, vi_end;
603 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
609 const SgAsmIntegerValuePtrList &targets = block->
get_successors();
610 for (SgAsmIntegerValuePtrList::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti)
616 typename boost::graph_traits<ControlFlowGraph>::out_edge_iterator ei, ei_end;
617 for (boost::tie(ei, ei_end)=boost::out_edges(*vi, cfg); ei!=ei_end; ++ei) {
621 target->makeRelativeTo(target_block);
622 target->set_parent(block);
629template<
class ControlFlowGraph>
633 typename boost::graph_traits<ControlFlowGraph>::vertex_iterator vi, vi_end;
634 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
641template<
class ControlFlowGraph>
643ControlFlow::VertexInserter<ControlFlowGraph>::conditionally_add_vertex(
SgAsmBlock *block)
645 if (block && block->
hasInstructions() && !analyzer->is_vertex_filtered(block) && !bv_map.exists(block)) {
646 Vertex vertex = boost::add_vertex(cfg);
647 bv_map[block] = vertex;
652template<
class ControlFlowGraph>
656 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
657 Vertex NO_VERTEX = boost::graph_traits<ControlFlowGraph>::null_vertex();
659 BlockVertexMap bv_map;
663 VertexInserter<ControlFlowGraph>(
this, cfg, bv_map).traverse(root, preorder);
667 for (
typename BlockVertexMap::iterator bvi=bv_map.begin(); bvi!=bv_map.end(); ++bvi)
668 addrToVertex[bvi->first->get_address()] = bvi->second;
671 BOOST_FOREACH (
Vertex sourceVertex, boost::vertices(cfg)) {
674 Vertex targetVertex = addrToVertex.
get_value_or(integerValue->get_absoluteValue(), NO_VERTEX);
675 if (targetVertex!=NO_VERTEX) {
677 assert(targetBlock!=NULL);
679 boost::add_edge(sourceVertex, targetVertex, cfg);
685template<
class ControlFlowGraph>
692 bool preserve_call_fallthrough_edges =
false;
696template<
class ControlFlowGraph>
704 SgAsmFunction *src_func = SageInterface::getEnclosingNode<SgAsmFunction>(src,
true);
705 SgAsmBlock *dst_block = SageInterface::getEnclosingNode<SgAsmBlock>(dst,
true);
706 SgAsmFunction *dst_func = SageInterface::getEnclosingNode<SgAsmFunction>(dst_block);
707 if (!src_func || !dst_func || dst_block!=dst_func->
get_entryBlock()) {
709 }
else if (src_func!=dst_func) {
714 return parent ? (*parent)(analyzer, src, dst) :
true;
719 T1 edge_filter(parent);
730template<
class ControlFlowGraph>
734 typedef typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor
Vertex;
735 Vertex NO_VERTEX = boost::graph_traits<ControlFlowGraph>::null_vertex();
738 std::vector<Vertex> src_to_dst(boost::num_vertices(src), NO_VERTEX);
740 typename boost::graph_traits<const ControlFlowGraph>::vertex_iterator vi, vi_end;
741 for (boost::tie(vi, vi_end)=boost::vertices(src); vi!=vi_end; ++vi) {
744 src_to_dst[*vi] = boost::add_vertex(dst);
749 typename boost::graph_traits<const ControlFlowGraph>::edge_iterator ei, ei_end;
750 for (boost::tie(ei, ei_end)=boost::edges(src); ei!=ei_end; ++ei) {
751 if (NO_VERTEX!=src_to_dst[boost::source(*ei, src)] && NO_VERTEX!=src_to_dst[boost::target(*ei, src)]) {
755 boost::add_edge(src_to_dst[boost::source(*ei, src)], src_to_dst[boost::target(*ei, src)], dst);
760template<
class ControlFlowGraph>
764 ControlFlowGraph dst;
769template<
class BlockCFG,
class InsnCFG>
774 typedef typename boost::graph_traits<const BlockCFG>::vertex_descriptor BlockCFG_Vertex;
775 typedef typename boost::graph_traits<const BlockCFG>::vertex_iterator BlockCFG_VertexIterator;
776 typedef typename boost::graph_traits<const BlockCFG>::edge_iterator BlockCFG_EdgeIterator;
780 typedef typename boost::graph_traits<InsnCFG>::vertex_descriptor InsnCFG_Vertex;
781 typedef std::pair<InsnCFG_Vertex, InsnCFG_Vertex> InsnCFG_VertexPair;
787 BlockCFG_VertexIterator vi, vi_end;
788 for (boost::tie(vi, vi_end)=boost::vertices(cfgb); vi!=vi_end; ++vi) {
791 assert(!insns.empty());
792 InsnCFG_Vertex enter_vertex = boost::graph_traits<InsnCFG>::null_vertex();
793 InsnCFG_Vertex prev_vertex = boost::graph_traits<InsnCFG>::null_vertex();
794 for (SgAsmStatementPtrList::const_iterator ii=insns.begin(); ii!=insns.end(); ++ii) {
797 InsnCFG_Vertex vertex = boost::add_vertex(cfgi);
799 if (ii==insns.begin()) {
800 enter_vertex = vertex;
802 boost::add_edge(prev_vertex, vertex, cfgi);
804 prev_vertex = vertex;
806 assert(prev_vertex!=boost::graph_traits<InsnCFG>::null_vertex());
807 vertex_translation[*vi] = InsnCFG_VertexPair(enter_vertex, prev_vertex);
814 BlockCFG_EdgeIterator ei, ei_end;
815 for (boost::tie(ei, ei_end)=boost::edges(cfgb); ei!=ei_end; ++ei) {
816 InsnCFG_Vertex src_leave_vertex = vertex_translation.
get_one(boost::source(*ei, cfgb)).second;
817 InsnCFG_Vertex dst_enter_vertex = vertex_translation.
get_one(boost::target(*ei, cfgb)).first;
818 assert(src_leave_vertex!=boost::graph_traits<InsnCFG>::null_vertex());
819 assert(dst_enter_vertex!=boost::graph_traits<InsnCFG>::null_vertex());
820 boost::add_edge(src_leave_vertex, dst_enter_vertex, cfgi);
825template<
class InsnCFG>
829 typedef typename boost::graph_traits<InsnCFG>::vertex_descriptor CFG_Vertex;
830 typedef typename boost::graph_traits<InsnCFG>::vertex_iterator CFG_VertexIterator;
831 typedef typename boost::graph_traits<InsnCFG>::in_edge_iterator CFG_InEdgeIterator;
832 typedef std::pair<CFG_Vertex, CFG_Vertex> CFG_VertexPair;
834 CFG_Vertex NO_VERTEX = boost::graph_traits<InsnCFG>::null_vertex();
840 InsnToVertex insn_to_vertex;
841 std::vector<bool> isret(boost::num_vertices(cfg),
false);
843 CFG_VertexIterator vi, vi_end;
844 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
847 insn_to_vertex[insn] = *vi;
849 if (0==boost::out_degree(*vi, cfg)) {
852 isret[*vi] = x86_ret==insn_x86->get_kind();
859 struct FunctionEntryVertex {
860 const InsnToVertex &insn_to_vertex;
862 FunctionEntryVertex(
const InsnToVertex &insn_to_vertex,
const InstructionMap &imap)
863 : insn_to_vertex(insn_to_vertex), imap(imap) {}
865 SgAsmFunction *func = SageInterface::getEnclosingNode<SgAsmFunction>(insn,
true);
867 CFG_Vertex entry_vertex = insn_to_vertex.get_one(entry_insn);
870 } function_entry_vertex(insn_to_vertex, insns);
873 std::vector<CFG_VertexPair> edges_to_insert, edges_to_erase;
875 CFG_VertexIterator vi, vi_end;
876 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
877 CFG_Vertex returner_vertex = *vi;
878 if (!isret[returner_vertex])
886 std::vector<bool> seen(boost::num_vertices(cfg),
false);
888 worklist.
push(function_entry_vertex(returner_insn));
889 while (!worklist.
empty()) {
890 CFG_Vertex callee_vertex = worklist.
shift();
891 CFG_InEdgeIterator ei, ei_end;
892 for (boost::tie(ei, ei_end)=boost::in_edges(callee_vertex, cfg); ei!=ei_end; ++ei) {
893 CFG_Vertex caller_vertex = boost::source(*ei, cfg);
894 if (!seen[caller_vertex]) {
895 seen[caller_vertex] =
true;
897 SgAsmBlock *caller_block = SageInterface::getEnclosingNode<SgAsmBlock>(caller_insn);
898 assert(caller_block!=NULL);
899 rose_addr_t target_va, returnee_va;
904 CFG_Vertex returnee_vertex = insn_to_vertex.get_value_or(returnee_insn, NO_VERTEX);
905 if (returnee_vertex!=NO_VERTEX) {
906 edges_to_insert.push_back(CFG_VertexPair(returner_vertex, returnee_vertex));
907 edges_to_erase.push_back(CFG_VertexPair(caller_vertex, returnee_vertex));
913 worklist.
push(function_entry_vertex(caller_insn));
922 if (!preserve_call_fallthrough_edges) {
923 for (
size_t i=0; i<edges_to_erase.size(); ++i)
924 boost::remove_edge(edges_to_erase[i].first, edges_to_erase[i].second, cfg);
926 for (
size_t i=0; i<edges_to_insert.size(); ++i)
927 boost::add_edge(edges_to_insert[i].first, edges_to_insert[i].second, cfg);
930template<
class ControlFlowGraph>
932ControlFlow::FlowOrder<ControlFlowGraph>::compute(
const ControlFlowGraph &g,
Vertex v0,
933 ReverseVertexList *reverse_order) {
934 forward_order->clear();
935 std::vector<boost::default_color_type> colors(boost::num_vertices(g), boost::white_color);
936 boost::depth_first_visit(g, v0, *
this, &(colors[0]));
937 assert(!forward_order->empty());
938 std::reverse(forward_order->begin(), forward_order->end());
940 reverse_order->clear();
941 reverse_order->resize(boost::num_vertices(g),
INVALID_INDEX);
942 for (
size_t i=0; i<forward_order->size(); i++)
943 (*reverse_order)[(*forward_order)[i]] = i;
947template<
class ControlFlowGraph>
949ControlFlow::FlowOrder<ControlFlowGraph>::finish_vertex(
Vertex v, ControlFlowGraph) {
950 forward_order->push_back(v);
953template<
class ControlFlowGraph>
954std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
956 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start,
957 std::vector<size_t> *reverse_order)
959 std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor> forward_order;
960 FlowOrder<ControlFlowGraph>(&forward_order).compute(cfg, start, reverse_order);
961 return forward_order;
964template<
class ControlFlowGraph>
966ControlFlow::ReturnBlocks<ControlFlowGraph>::finish_vertex(
Vertex v, ControlFlowGraph g)
968 typename boost::graph_traits<ControlFlowGraph>::out_edge_iterator ei, ei_end;
969 boost::tie(ei, ei_end) = boost::out_edges(v, g);
974template<
class ControlFlowGraph>
975std::vector<typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor>
977 typename boost::graph_traits<ControlFlowGraph>::vertex_descriptor start)
979 typename ReturnBlocks<ControlFlowGraph>::Vector result;
980 ReturnBlocks<ControlFlowGraph> visitor(result);
981 std::vector<boost::default_color_type> colors(boost::num_vertices(cfg), boost::white_color);
982 boost::depth_first_visit(cfg, start, visitor, &(colors[0]));
986template<
class ControlFlowGraph>
990 ControlFlowGraph cfg;
995template<
class ControlFlowGraph>
999 ControlFlowGraph cfg;
1004template<
class ControlFlowGraph>
1008 ControlFlowGraph cfg;
1014template<
typename CFG,
class VertexPropertyWriter,
class EdgePropertyWriter>
1017 const VertexPropertyWriter &vpw,
const EdgePropertyWriter &epw)
1020 typedef typename boost::graph_traits<CFG>::edge_descriptor CFG_Edge;
1021 typedef typename boost::graph_traits<CFG>::vertex_iterator CFG_VertexIterator;
1022 typedef typename boost::graph_traits<CFG>::out_edge_iterator CFG_OutEdgeIterator;
1027 std::vector<CFG_Edge> interfunc_edges;
1028 CFG_VertexIterator vi, vi_end;
1029 for (boost::tie(vi, vi_end)=boost::vertices(cfg); vi!=vi_end; ++vi) {
1032 f.vertices.push_back(*vi);
1033 CFG_OutEdgeIterator ei, ei_end;
1034 for (boost::tie(ei, ei_end)=boost::out_edges(*vi, cfg); ei!=ei_end; ++ei) {
1036 SgAsmFunction *tgt_func = SageInterface::getEnclosingNode<SgAsmFunction>(tgt_node,
true);
1037 if (tgt_func==func) {
1038 f.edges.push_back(*ei);
1040 interfunc_edges.push_back(*ei);
1046 out <<
"digraph G {\n";
1047 for (
typename Functions::iterator fi=funcs.begin(); fi!=funcs.end(); ++fi) {
1049 if (!f.vertices.empty() || !f.edges.empty()) {
1051 SgAsmFunction *func = SageInterface::getEnclosingNode<SgAsmFunction>(node,
true);
1052 const size_t maxNameSize = 63;
1053 char cluster_name[maxNameSize+1];
1054 snprintf(cluster_name, maxNameSize,
"cluster_F%" PRIx64, func->
get_entryVa());
1055 out <<
" subgraph " <<cluster_name <<
" {\n"
1056 <<
" style=filled;\n"
1057 <<
" color=lightgrey;\n"
1059 <<(func->
get_name().empty()?std::string(
""):(
" <"+func->
get_name()+
">")) <<
"\";\n";
1060 for (
size_t i=0; i<f.vertices.size(); ++i) {
1061 out <<
" " <<f.vertices[i];
1062 vpw(out, f.vertices[i]);
1065 for (
size_t i=0; i<f.edges.size(); ++i) {
1066 out <<
" " <<boost::source(f.edges[i], cfg) <<
"->" <<boost::target(f.edges[i], cfg);
1067 epw(out, f.edges[i]);
1075 for (
size_t i=0; i<interfunc_edges.size(); ++i) {
1076 out <<
" " <<boost::source(interfunc_edges[i], cfg) <<
"->" <<boost::target(interfunc_edges[i], cfg);
1077 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.