base: Transition CP annotate to use shared_ptr
[gem5.git] / src / base / cp_annotate.cc
index 4e138a6dd9f8d2dc82c4b1e626ab22be3d296978..4904949b4d4fb5f81416b1abb128f8b6352962e2 100644 (file)
  * Authors: Ali Saidi
  */
 
+#include "arch/generic/linux/threadinfo.hh"
 #include "arch/utility.hh"
-#include "arch/alpha/linux/threadinfo.hh"
-#include "base/cp_annotate.hh"
-#include "base/callback.hh"
 #include "base/loader/object_file.hh"
+#include "base/callback.hh"
+#include "base/cp_annotate.hh"
 #include "base/output.hh"
 #include "base/trace.hh"
 #include "config/the_isa.hh"
 #include "cpu/thread_context.hh"
+#include "debug/Annotate.hh"
+#include "debug/AnnotateVerbose.hh"
 #include "sim/arguments.hh"
 #include "sim/core.hh"
 #include "sim/sim_exit.hh"
@@ -142,6 +144,17 @@ CPA::startup()
 
     registerExitCallback(new AnnotateDumpCallback(this));
 }
+
+uint64_t
+CPA::getFrame(ThreadContext *tc)
+{
+    // This code is ISA specific and will need to be changed
+    // if the annotation code is used for something other than Alpha
+    return (tc->readMiscRegNoEffect(TheISA::IPR_PALtemp23) &
+            ~ULL(0x3FFF));
+
+}
+
 void
 CPA::swSmBegin(ThreadContext *tc)
 {
@@ -161,7 +174,7 @@ CPA::swSmBegin(ThreadContext *tc)
     StringWrap name(sys->name());
 
     if (!sm[0])
-        warn("Got null SM at tick %d\n", curTick);
+        warn("Got null SM at tick %d\n", curTick());
 
     int sysi = getSys(sys);
     int smi = getSm(sysi, sm, args[1]);
@@ -273,7 +286,7 @@ CPA::doSwSmEnd(System *sys, int cpuid, string sm, uint64_t frame)
         DPRINTF(Annotate, "Ending machine: %s; end stack: %s\n", sm,
                 smMap[smib-1].second.first);
 
-        warn("State machine stack not unwinding correctly at %d\n", curTick);
+        warn("State machine stack not unwinding correctly at %d\n", curTick());
     } else {
         DPRINTF(Annotate, 
                 "State machine ending:%s sysi:%d id:%#x back:%d getSm:%d\n",
@@ -316,7 +329,7 @@ CPA::swExplictBegin(ThreadContext *tc)
     DPRINTF(Annotate, "Explict begin of state %s\n", st);
     uint32_t flags = args[0];
     if (flags & FL_BAD)
-        warn("BAD state encountered: at cycle %d: %s\n", curTick, st);
+        warn("BAD state encountered: at cycle %d: %s\n", curTick(), st);
     swBegin(tc->getSystemPtr(), tc->contextId(), st, getFrame(tc), true, args[0]);
 }
 
@@ -328,12 +341,9 @@ CPA::swAutoBegin(ThreadContext *tc, Addr next_pc)
 
     string sym;
     Addr sym_addr = 0;
-    SymbolTable *symtab = NULL;
-
 
     if (!TheISA::inUserMode(tc)) {
         debugSymbolTable->findNearestSymbol(next_pc, sym, sym_addr);
-        symtab = debugSymbolTable;
     } else {
         Linux::ThreadInfo ti(tc);
         string app = ti.curTaskName();
@@ -688,10 +698,10 @@ CPA::swAq(ThreadContext *tc)
 
         warn("%d: Queue Assert: SW said there should be %d byte(s) in %s," 
                 "however there are %d byte(s)\n",
-            curTick, size, q, qBytes[qi-1]);
+            curTick(), size, q, qBytes[qi-1]);
         DPRINTF(AnnotateQ, "%d: Queue Assert: SW said there should be %d"
                 " byte(s) in %s, however there are %d byte(s)\n",
-            curTick, size, q, qBytes[qi-1]);
+            curTick(), size, q, qBytes[qi-1]);
     }
 }
 
@@ -812,8 +822,8 @@ CPA::swSyscallLink(ThreadContext  *tc)
 CPA::AnnDataPtr
 CPA::add(int t, int f, int c, int sm, int stq, int32_t d)
 {
-    AnnDataPtr an = new AnnotateData;
-    an->time = curTick;
+    AnnDataPtr an = std::make_shared<AnnotateData>();
+    an->time = curTick();
     an->data = d;
     an->orig_data = d;
     an->op = t;
@@ -1285,7 +1295,7 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
 
         paramIn(cp, section, csprintf("nameCache%d.str", x), str);
         paramIn(cp, section, csprintf("nameCache%d.int", x), sysi);
-        nameCache[sys] = std::make_pair<std::string,int>(str, sysi);
+        nameCache[sys] = std::make_pair(str, sysi);
     }
 
     //smStack (SmStack)
@@ -1363,7 +1373,7 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
         if (!qSize[x])
             continue;
         for (int y = 0; y < qSize[x]; y++) {
-            AnnDataPtr a = new AnnotateData;
+            AnnDataPtr a = std::make_shared<AnnotateData>();
             a->unserialize(cp, csprintf("%s.Q%d_%d", section, x, y));
             data.push_back(a);
             qData[x].push_back(a);