stacktrace.hh (5568:d14250d688d2) | stacktrace.hh (5569:baeee670d4ce) |
---|---|
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; --- 22 unchanged lines hidden (view full) --- 31#ifndef __ARCH_ALPHA_STACKTRACE_HH__ 32#define __ARCH_ALPHA_STACKTRACE_HH__ 33 34#include "base/trace.hh" 35#include "cpu/static_inst.hh" 36 37class ThreadContext; 38 | 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; --- 22 unchanged lines hidden (view full) --- 31#ifndef __ARCH_ALPHA_STACKTRACE_HH__ 32#define __ARCH_ALPHA_STACKTRACE_HH__ 33 34#include "base/trace.hh" 35#include "cpu/static_inst.hh" 36 37class ThreadContext; 38 |
39namespace AlphaISA 40{ 41 class StackTrace; | 39namespace AlphaISA { |
42 | 40 |
43 class ProcessInfo 44 { 45 private: 46 ThreadContext *tc; | 41class StackTrace; |
47 | 42 |
48 int thread_info_size; 49 int task_struct_size; 50 int task_off; 51 int pid_off; 52 int name_off; | 43class ProcessInfo 44{ 45 private: 46 ThreadContext *tc; |
53 | 47 |
54 public: 55 ProcessInfo(ThreadContext *_tc); | 48 int thread_info_size; 49 int task_struct_size; 50 int task_off; 51 int pid_off; 52 int name_off; |
56 | 53 |
57 Addr task(Addr ksp) const; 58 int pid(Addr ksp) const; 59 std::string name(Addr ksp) const; 60 }; | 54 public: 55 ProcessInfo(ThreadContext *_tc); |
61 | 56 |
62 class StackTrace 63 { 64 private: 65 ThreadContext *tc; 66 std::vector<Addr> stack; | 57 Addr task(Addr ksp) const; 58 int pid(Addr ksp) const; 59 std::string name(Addr ksp) const; 60}; |
67 | 61 |
68 private: 69 bool isEntry(Addr addr); 70 bool decodePrologue(Addr sp, Addr callpc, Addr func, int &size, Addr &ra); 71 bool decodeSave(MachInst inst, int ®, int &disp); 72 bool decodeStack(MachInst inst, int &disp); | 62class StackTrace 63{ 64 private: 65 ThreadContext *tc; 66 std::vector<Addr> stack; |
73 | 67 |
74 void trace(ThreadContext *tc, bool is_call); | 68 private: 69 bool isEntry(Addr addr); 70 bool decodePrologue(Addr sp, Addr callpc, Addr func, int &size, Addr &ra); 71 bool decodeSave(MachInst inst, int ®, int &disp); 72 bool decodeStack(MachInst inst, int &disp); |
75 | 73 |
76 public: 77 StackTrace(); 78 StackTrace(ThreadContext *tc, StaticInstPtr inst); 79 ~StackTrace(); | 74 void trace(ThreadContext *tc, bool is_call); |
80 | 75 |
81 void clear() 82 { 83 tc = 0; 84 stack.clear(); 85 } | 76 public: 77 StackTrace(); 78 StackTrace(ThreadContext *tc, StaticInstPtr inst); 79 ~StackTrace(); |
86 | 80 |
87 bool valid() const { return tc != NULL; } 88 bool trace(ThreadContext *tc, StaticInstPtr inst); | 81 void 82 clear() 83 { 84 tc = 0; 85 stack.clear(); 86 } |
89 | 87 |
90 public: 91 const std::vector<Addr> &getstack() const { return stack; } | 88 bool valid() const { return tc != NULL; } 89 bool trace(ThreadContext *tc, StaticInstPtr inst); |
92 | 90 |
93 static const int user = 1; 94 static const int console = 2; 95 static const int unknown = 3; | 91 public: 92 const std::vector<Addr> &getstack() const { return stack; } |
96 | 93 |
94 static const int user = 1; 95 static const int console = 2; 96 static const int unknown = 3; 97 |
|
97#if TRACING_ON | 98#if TRACING_ON |
98 private: 99 void dump(); | 99 private: 100 void dump(); |
100 | 101 |
101 public: 102 void dprintf() { if (DTRACE(Stack)) dump(); } | 102 public: 103 void dprintf() { if (DTRACE(Stack)) dump(); } |
103#else | 104#else |
104 public: 105 void dprintf() {} | 105 public: 106 void dprintf() {} |
106#endif | 107#endif |
107 }; | 108}; |
108 | 109 |
109 inline bool 110 StackTrace::trace(ThreadContext *tc, StaticInstPtr inst) 111 { 112 if (!inst->isCall() && !inst->isReturn()) 113 return false; | 110inline bool 111StackTrace::trace(ThreadContext *tc, StaticInstPtr inst) 112{ 113 if (!inst->isCall() && !inst->isReturn()) 114 return false; |
114 | 115 |
115 if (valid()) 116 clear(); | 116 if (valid()) 117 clear(); |
117 | 118 |
118 trace(tc, !inst->isReturn()); 119 return true; 120 } | 119 trace(tc, !inst->isReturn()); 120 return true; |
121} 122 | 121} 122 |
123} // namespace AlphaISA 124 |
|
123#endif // __ARCH_ALPHA_STACKTRACE_HH__ | 125#endif // __ARCH_ALPHA_STACKTRACE_HH__ |