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