Start to split jump table analysis to two different slices.
[dyninst.git] / parseAPI / src / JumpTableFormatPred.h
1 #ifndef JUMP_TABLE_FORMAT_PRED_H
2 #define JUMP_TABLE_FORMAT_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 "SymbolicExpression.h"
10 //#include "BoundFactCalculator.h"
11 using namespace Dyninst;
12
13 class JumpTableFormatPred : public Slicer::Predicates {
14
15     ParseAPI::Function *func;
16     ParseAPI::Block *block;
17     ReachFact &rf;
18     ThunkData &thunks;
19     SymbolicExpression &se;
20
21     std::pair<AST::Ptr, bool> ExpandAssignment(Assignment::Ptr);
22
23     Address targetBase;    
24     // If tableReadSize == 0, this does not represent a memory access
25     // Otherwise, tableReadSize reprenents the number bytes of the access
26     int tableReadSize;
27     int tableStride;
28
29     // On ARM, the table content is often multiplied by 4 before adding with targetBase
30     int tcMultiply;
31     bool isInverted;
32     bool isSubReadContent;
33     bool isZeroExtend;
34
35     bool jumpTableFormat;
36     bool unknownInstruction;
37     bool findIndex;
38
39     AbsRegion index;
40     AST::Ptr jumpTargetExpr;
41
42
43 public:
44
45     JumpTableFormatPred(ParseAPI::Function *f,
46                         ParseAPI::Block *b,
47                         ReachFact &r,
48                         ThunkData &t,
49                         SymbolicExpression &sym):
50             func(f), block(b), rf(r), thunks(t), se(sym) {
51                 targetBase = 0;
52                 tableReadSize = 0;
53                 tcMultiply = 1;
54                 isInverted = false;
55                 isSubReadContent = false;
56                 isZeroExtend = false;
57                 jumpTableFormat = true;
58                 unknownInstruction = false;
59                 findIndex = false;
60             }
61
62     virtual bool modifyCurrentFrame(Slicer::SliceFrame &frame, Graph::Ptr g);
63     std::string format();
64     bool isJumpTableFormat() { return jumpTableFormat; }
65
66 };
67
68 #endif