forked from SameerDalal/backtrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContextNode.cpp
124 lines (97 loc) · 2.67 KB
/
ContextNode.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <iostream>
#include "ContextNode.h"
#include <string>
#include <vector>
#include <libunwind.h>
ContextNode::ContextNode(void* frame_addr,
void* return_addr,
std::string funcName,
unw_word_t start_ip,
unw_word_t end_ip,
unw_word_t lsda,
unw_word_t handler,
unw_word_t global_pointer,
unw_word_t flags,
std::vector<std::string> parameters) {
this->frame_addr = frame_addr;
this->return_addr = return_addr;
this->start_ip = start_ip;
this->end_ip = end_ip;
this->lsda = lsda;
this->handler = handler;
this->global_pointer = global_pointer;
this->flags = flags;
this->funcName = funcName;
this->parameters = parameters;
this->arguments = {};
callCount = 0;
}
ContextNode::ContextNode(std::string funcName, void* return_addr) {
this->return_addr = return_addr;
this->funcName = funcName;
this->arguments = {};
callCount = 0;
}
ContextNode::~ContextNode() {
//delete this;
}
void ContextNode::addChild(ContextNode* child) {
children.push_back(child);
}
void ContextNode::setParentNode(ContextNode* node){
parent = node;
}
void ContextNode::setArguments(std::vector<std::string> args) {
for(auto arg : args) {
arguments.push_back(arg);
}
}
// getters
std::vector<std::string> &ContextNode::getArguments() {
return arguments;
}
void ContextNode::addArgument(std::string arg) {
arguments.push_back(arg);
}
std::string ContextNode::getFunctionName() {
return funcName;
};
ContextNode* ContextNode::getParentNode() {
return parent;
}
std::vector<std::string> & ContextNode::getParameters() {
return parameters;
}
std::vector<ContextNode*> ContextNode::getChildren() {
return children;
}
void* ContextNode::getFrameAddress() {
return frame_addr;
}
void* ContextNode::getReturnAddress() {
return return_addr;
}
unw_word_t ContextNode::getStartIP() const {
return start_ip;
}
unw_word_t ContextNode::getEndIP() const {
return end_ip;
}
unw_word_t ContextNode::getLsda() const {
return lsda;
}
unw_word_t ContextNode::getHandler() const {
return handler;
}
unw_word_t ContextNode::getGlobalPointer() const {
return global_pointer;
}
unw_word_t ContextNode::getFlags() const {
return flags;
}
void ContextNode::addCallCount(long val) {
callCount+=val;
}
long ContextNode::getCallCount(){
return callCount;
}