ROSE  0.9.10.89
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  ASSUMED = 0x00000080,
25  PREDEFINED = 0x000000ff,
26  USER_DEFINED = 0xffffff00,
27  USER_DEFINED_0 = 0x00000100,
28  ALL_REASONS = 0xffffffff
29  };
30 
31 private:
32  Partitioner2::ControlFlowGraph cfg_; // CFG upon which we're operating
33  std::vector<unsigned> intrinsicReachability_; // intrinsic reachability of each vertex in the CFG
34  std::vector<unsigned> reachability_; // computed reachability of each vertex in the CFG
35  bool savingCfg_; // whether to save the CFG when serializing.
36 
37 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
38 private:
39  friend class boost::serialization::access;
40 
41  template<class S>
42  void serialize(S &s, const unsigned /*version*/) {
43  s & BOOST_SERIALIZATION_NVP(savingCfg_);
44  if (savingCfg_)
45  s & BOOST_SERIALIZATION_NVP(cfg_);
46  s & BOOST_SERIALIZATION_NVP(intrinsicReachability_);
47  s & BOOST_SERIALIZATION_NVP(reachability_);
48  }
49 #endif
50 
51 public:
52  Reachability()
53  : savingCfg_(true) {}
54 
61  const Partitioner2::ControlFlowGraph& cfg() const /*final*/ { return cfg_; }
71 
75  void clear();
76 
80  bool savingCfg() const { return savingCfg_; }
81  void savingCfg(bool b) { savingCfg_ = b; }
87  void clearReachability();
88 
93  unsigned isIntrinsicallyReachable(size_t vertexId) const;
94 
96  struct Propagate {
97  enum Boolean {
98  NO,
99  YES
100  };
101  };
102 
109  void intrinsicallyReachable(size_t vertexId, unsigned how, Propagate::Boolean propagate = Propagate::YES);
110 
115  unsigned isReachable(size_t vertexId) const;
116 
120  const std::vector<unsigned>& reachability() const;
121 
128 
133  void propagate();
134 };
135 
136 } // namespace
137 } // namespace
138 
139 #endif
ROSE-defined reachability reasons.
const Partitioner2::ControlFlowGraph & cfg() const
Property: Control flow graph.
void clear()
Clear previous results.
Assumed reachable for cases when the analysis wasn't run.
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 intrinsicallyReachable(size_t vertexId, unsigned how, Propagate::Boolean propagate=Propagate::YES)
Change intrinsic reachability.
void propagate()
Propagate intrinsic reachability through the graph.
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:293