1. Add a callback interface to slicing code. It triggers when a new node is added...
[dyninst.git] / parseAPI / src / JumpTablePred.h
1 #ifndef JUMP_TABLE_PRED_H
2 #define JUMP_TABLE_PRED_H
3
4 #include "CFG.h"
5 #include "slicing.h"
6 #include "Edge.h"
7 #include "ThunkData.h"
8 #include "Graph.h"
9 #include "BoundFactCalculator.h"
10 using namespace Dyninst;
11
12 class JumpTablePred : public Slicer::Predicates {
13  
14     std::set<Assignment::Ptr> currentAssigns;
15     ParseAPI::Function *func;
16     ParseAPI::Block *block;
17     ReachFact &rf;
18     ThunkData &thunks;
19     std::vector<std::pair< Address, Dyninst::ParseAPI::EdgeTypeEnum > >& outEdges;
20     GraphPtr BuildAnalysisGraph();
21     bool IsJumpTable(GraphPtr slice, BoundFactsCalculator &bfc, BoundValue &target);
22     bool FillInOutEdges(BoundValue &target, std::vector<std::pair< Address, Dyninst::ParseAPI::EdgeTypeEnum > >& outEdges);
23
24 public:
25     virtual bool endAtPoint(AssignmentPtr ap);  
26     virtual bool addNodeCallback(AssignmentPtr ap);
27
28     JumpTablePred(ParseAPI::Function *f,
29                   ParseAPI::Block *b,
30                   ReachFact &r,
31                   ThunkData &t,
32                   std::vector<std::pair< Address, Dyninst::ParseAPI::EdgeTypeEnum > >& out):
33             func(f), block(b), rf(r), thunks(t), outEdges(out) {}
34 };
35
36
37 class TypedSliceEdge: public Dyninst::Edge {
38     ParseAPI::EdgeTypeEnum type_; 
39     
40     TypedSliceEdge(const SliceNode::Ptr source,
41               const SliceNode::Ptr target,
42               ParseAPI::EdgeTypeEnum t) 
43               : Dyninst::Edge(source, target), type_(t) {};
44   public:             
45    typedef boost::shared_ptr<TypedSliceEdge> Ptr; 
46    static TypedSliceEdge::Ptr create(SliceNode::Ptr source,
47                                      SliceNode::Ptr target,
48                                      ParseAPI::EdgeTypeEnum t) {
49         return Ptr(new TypedSliceEdge(source, target, t));       
50    }                                                
51
52   public:
53     ParseAPI::EdgeTypeEnum type() { return type_;}
54
55 };
56
57 #endif