Merge gblack@m5.eecs.umich.edu:/bk/multiarch
[gem5.git] / arch / alpha / stacktrace.hh
index 5a4741eba00a7f91ed39628cbfaec691d6c35eb4..1d8d97a79bf783849ffa3fb6afb0187be24a9c3b 100644 (file)
@@ -34,7 +34,6 @@
 
 class ExecContext;
 class StackTrace;
-class SymbolTable;
 
 class ProcessInfo
 {
@@ -57,6 +56,8 @@ class ProcessInfo
 
 class StackTrace
 {
+  protected:
+    typedef TheISA::MachInst MachInst;
   private:
     ExecContext *xc;
     std::vector<Addr> stack;
@@ -67,13 +68,28 @@ class StackTrace
     bool decodeSave(MachInst inst, int &reg, int &disp);
     bool decodeStack(MachInst inst, int &disp);
 
+    void trace(ExecContext *xc, bool is_call);
+
   public:
-    StackTrace(ExecContext *xc, bool is_call);
+    StackTrace();
+    StackTrace(ExecContext *xc, StaticInstPtr inst);
     ~StackTrace();
 
+    void clear()
+    {
+        xc = 0;
+        stack.clear();
+    }
+
+    bool valid() const { return xc != NULL; }
+    bool trace(ExecContext *xc, StaticInstPtr inst);
+
   public:
     const std::vector<Addr> &getstack() const { return stack; }
-    static StackTrace *create(ExecContext *xc, StaticInstPtr<TheISA> inst);
+
+    static const int user = 1;
+    static const int console = 2;
+    static const int unknown = 3;
 
 #if TRACING_ON
   private:
@@ -87,13 +103,17 @@ class StackTrace
 #endif
 };
 
-inline StackTrace *
-StackTrace::create(ExecContext *xc, StaticInstPtr<TheISA> inst)
+inline bool
+StackTrace::trace(ExecContext *xc, StaticInstPtr inst)
 {
     if (!inst->isCall() && !inst->isReturn())
-        return NULL;
+        return false;
+
+    if (valid())
+        clear();
 
-    return new StackTrace(xc, !inst->isReturn());
+    trace(xc, !inst->isReturn());
+    return true;
 }
 
 #endif // __ARCH_ALPHA_STACKTRACE_HH__