ROSE  0.9.10.44
BinaryReachability.h
1 #ifndef ROSE_BinaryAnalysis_Reachability_H
2 #define ROSE_BinaryAnalysis_Reachability_H
3 
4 #include <boost/serialization/access.hpp>
5 #include <Partitioner2/ControlFlowGraph.h>
6 #include <set>
7 #include <vector>
8 
9 namespace Rose {
10 namespace BinaryAnalysis {
11 
16 class Reachability {
17 public:
19  enum Reason {
21  ENTRY_POINT = 0x00000001,
22  EXPORTED_FUNCTION = 0x00000002,
23  SIGNAL_HANDLER = 0x00000004,
24  PREDEFINED = 0x000000ff,
25  USER_DEFINED = 0xffffff00,
26  USER_DEFINED_0 = 0x00000100
27  };
28 
29 private:
30  Partitioner2::ControlFlowGraph cfg_; // CFG upon which we're operating
31  std::vector<unsigned> intrinsicReachability_; // intrinsic reachability of each vertex in the CFG
32  std::vector<unsigned> reachability_; // computed reachability of each vertex in the CFG
33  bool savingCfg_; // whether to save the CFG when serializing.
34 
35 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
36 private:
37  friend class boost::serialization::access;
38 
39  template<class S>
40  void serialize(S &s, const unsigned /*version*/) {
41  s & BOOST_SERIALIZATION_NVP(savingCfg_);
42  if (savingCfg_)
43  s & BOOST_SERIALIZATION_NVP(cfg_);
44  s & BOOST_SERIALIZATION_NVP(intrinsicReachability_);
45  s & BOOST_SERIALIZATION_NVP(reachability_);
46  }
47 #endif
48 
49 public:
50  Reachability()
51  : savingCfg_(true) {}
52 
59  const Partitioner2::ControlFlowGraph& cfg() const /*final*/ { return cfg_; }
69 
73  void clear();
74 
78  bool savingCfg() const { return savingCfg_; }
79  void savingCfg(bool b) { savingCfg_ = b; }
85  void clearReachability();
86 
91  unsigned isIntrinsicallyReachable(size_t vertexId) const;
92 
99  void intrinsicallyReachable(size_t vertexId, unsigned how, bool doPropagate = true);
100 
105  unsigned isReachable(size_t vertexId) const;
106 
110  const std::vector<unsigned>& reachability() const;
111 
118 
123  void propagate();
124 };
125 
126 } // namespace
127 } // namespace
128 
129 #endif
ROSE-defined reachability reasons.
const Partitioner2::ControlFlowGraph & cfg() const
Property: Control flow graph.
void clear()
Clear previous results.
Main namespace for the ROSE library.
Reason
Predefined bit flags for why something is reachable.
void clearReachability()
Clear all reachability.
void savingCfg(bool b)
Property: Whether to save the CFG when serializing.
void propagate()
Propagate intrinsic reachability through the graph.
void intrinsicallyReachable(size_t vertexId, unsigned how, bool doPropagate=true)
Change intrinsic reachability.
const std::vector< unsigned > & reachability() const
Computed reachability for all vertices.
bool savingCfg() const
Property: Whether to save the CFG when serializing.
Analysis that computes reachability of CFG vertices.
void markSpecialFunctions(const Partitioner2::Partitioner &)
Mark special vertices for containers.
unsigned isIntrinsicallyReachable(size_t vertexId) const
Query intrinsic reachability.
unsigned isReachable(size_t vertexId) const
Query computed reachability.
void replaceCfg(const Partitioner2::ControlFlowGraph &)
Replace CFG without adjusting other data.
Partitions instructions into basic blocks and functions.
Definition: Partitioner.h:292