-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcallstack.h
More file actions
105 lines (94 loc) · 2.65 KB
/
callstack.h
File metadata and controls
105 lines (94 loc) · 2.65 KB
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
/*
__ __ ______ _______ _______ ______ ________
/ \ / | / \ / \ / \ / \ / |
$$ \ /$$ |/$$$$$$ |$$$$$$$ |$$$$$$$ |/$$$$$$ |$$$$$$$$/
$$$ \ /$$$ |$$ | $$/ $$ |__$$ |$$ |__$$ |$$ | $$ |$$ |__
$$$$ /$$$$ |$$ | $$ $$/ $$ $$< $$ | $$ |$$ |
$$ $$ $$/$$ |$$ | __ $$$$$$$/ $$$$$$$ |$$ | $$ |$$$$$/
$$ |$$$/ $$ |$$ \__/ |$$ | $$ | $$ |$$ \__$$ |$$ |
$$ | $/ $$ |$$ $$/ $$ | $$ | $$ |$$ $$/ $$ |
$$/ $$/ $$$$$$/ $$/ $$/ $$/ $$$$$$/ $$/
A Memory and Communication Profiler
* This file is a part of MCPROF.
* https://bitbucket.org/imranashraf/mcprof
*
* Copyright (c) 2014-2016 TU Delft, The Netherlands.
* All rights reserved.
*
* MCPROF is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MCPROF is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MCPROF. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Imran Ashraf
*
*/
#ifndef CALLSTACK_H
#define CALLSTACK_H
#include "globals.h"
#include <vector>
#include <cstddef>
#include <iomanip>
#include <iostream>
using namespace std;
class CallStackType
{
private:
vector<u16> stack; // vector containing func ids of functions on call stack
public:
CallStackType() {}
u16 Top()
{
return stack.back();
}
bool Empty()
{
return stack.empty();
}
void Push(u16 f)
{
stack.push_back(f);
}
void Pop()
{
stack.pop_back();
}
void Print();
void Print(ofstream& fout);
};
class CallSiteStackType
{
private:
vector<u32> sites; // vector containing location indexes of call sites
public:
CallSiteStackType() {} // TODO Do we need to insert the first call site as for main()
bool Empty()
{
return sites.empty();
}
void Push(u32 locidx)
{
sites.push_back(locidx);
}
void Pop()
{
sites.pop_back();
}
u16 Top()
{
return sites.back();
}
void GetCallSites(u32 lastCallLocIndex, string& callsites);
string GetCallSitesString();
void Print();
void Print(ofstream& fout);
};
#endif