-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStackHeightAnalyzer.cpp
50 lines (45 loc) · 1.24 KB
/
StackHeightAnalyzer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "FeatureAnalyzer.h"
#include "Instruction.h"
#include "InstructionDecoder.h"
#include "Operand.h"
#include "Visitor.h"
#include "Expression.h"
#include "BinaryFunction.h"
#include "Register.h"
#include "stackanalysis.h"
#include "Immediate.h"
#include "Result.h"
#include "liveness.h"
#include "bitArray.h"
#include "Location.h"
#include "slicing.h"
#include "Absloc.h"
#include "AbslocInterface.h"
#include "Graph.h"
#include "Node.h"
using namespace std;
using namespace Dyninst;
using namespace Dyninst::ParseAPI;
using namespace Dyninst::InstructionAPI;
using namespace Dyninst::DataflowAPI;
void StackHeightAnalyzer::ProduceAFunction(InstanceDataType* idt) {
ParseAPI::Function *f = idt->f;
StackAnalysis sa(f);
int maxHeight = 0;
for (auto b : f->blocks()) {
Block::Insns insns;
b->getInsns(insns);
for (auto iit : insns) {
try{
StackAnalysis::Height h = sa.findSP(b, iit.first);
if (!h.isTop() && !h.isBottom()) {
int height = -h.height();
if (height > maxHeight) maxHeight = height;
}
}catch (exception &e)
{
}
}
}
idt->featPair["STACK_HEIGHT_MAX"] = maxHeight;
}