arch: Delete the unused ProcessInfo class.
[gem5.git] / src / arch / arm / stacktrace.hh
1 /*
2 * Copyright (c) 2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef __ARCH_ARM_STACKTRACE_HH__
30 #define __ARCH_ARM_STACKTRACE_HH__
31
32 #include "base/trace.hh"
33 #include "cpu/static_inst.hh"
34 #include "debug/Stack.hh"
35
36 class ThreadContext;
37 namespace ArmISA
38 {
39
40 class StackTrace
41 {
42 protected:
43 typedef ArmISA::MachInst MachInst;
44 private:
45 ThreadContext *tc;
46 std::vector<Addr> stack;
47
48 private:
49 bool isEntry(Addr addr);
50 bool decodePrologue(Addr sp, Addr callpc, Addr func, int &size, Addr &ra);
51 bool decodeSave(MachInst inst, int &reg, int &disp);
52 bool decodeStack(MachInst inst, int &disp);
53
54 void trace(ThreadContext *tc, bool is_call);
55
56 public:
57 StackTrace();
58 StackTrace(ThreadContext *tc, const StaticInstPtr &inst);
59 ~StackTrace();
60
61 void clear()
62 {
63 tc = 0;
64 stack.clear();
65 }
66
67 bool valid() const { return tc != NULL; }
68 bool trace(ThreadContext *tc, const StaticInstPtr &inst);
69
70 public:
71 const std::vector<Addr> &getstack() const { return stack; }
72
73 #if TRACING_ON
74 private:
75 void dump();
76
77 public:
78 void dprintf() { if (DTRACE(Stack)) dump(); }
79 #else
80 public:
81 void dprintf() {}
82 #endif
83 };
84
85 inline bool
86 StackTrace::trace(ThreadContext *tc, const StaticInstPtr &inst)
87 {
88 if (!inst->isCall() && !inst->isReturn())
89 return false;
90
91 if (valid())
92 clear();
93
94 trace(tc, !inst->isReturn());
95 return true;
96 }
97
98 } // Namespace ArmISA
99
100 #endif // __ARCH_ARM_STACKTRACE_HH__