SPARC: Make SPARC's ISA's clear function initialize everything it should.
authorGabe Black <gblack@eecs.umich.edu>
Mon, 11 Oct 2010 03:38:05 +0000 (20:38 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Mon, 11 Oct 2010 03:38:05 +0000 (20:38 -0700)
Also make it not set some pointers to NULL potentially introducing a memory
leak. That should be done in the constructor.

src/arch/alpha/isa.hh
src/arch/sparc/isa.cc
src/arch/sparc/isa.hh

index 01666c7833c42285628629ece635698932492114..cd2ece22dc4e4854f31cf0dcd3e5562a699c30fe 100644 (file)
@@ -31,6 +31,8 @@
 #ifndef __ARCH_ALPHA_ISA_HH__
 #define __ARCH_ALPHA_ISA_HH__
 
+#include <string.h>
+
 #include <string>
 #include <iostream>
 
index 3226b4e4290a030dde25c23ef20391bdbad942a2..9d4490fa30a500c5a677539816b8a259950ed32c 100644 (file)
@@ -99,6 +99,7 @@ ISA::clear()
     memset(tnpc, 0, sizeof(tnpc));
     memset(tstate, 0, sizeof(tstate));
     memset(tt, 0, sizeof(tt));
+    tba = 0;
     pstate = 0;
     tl = 0;
     pil = 0;
@@ -123,10 +124,21 @@ ISA::clear()
     lsuCtrlReg = 0;
 
     memset(scratchPad, 0, sizeof(scratchPad));
+
+    cpu_mondo_head = 0;
+    cpu_mondo_tail = 0;
+    dev_mondo_head = 0;
+    dev_mondo_tail = 0;
+    res_error_head = 0;
+    res_error_tail = 0;
+    nres_error_head = 0;
+    nres_error_tail = 0;
+
 #if FULL_SYSTEM
-    tickCompare = NULL;
-    sTickCompare = NULL;
-    hSTickCompare = NULL;
+    // If one of these events is active, it's not obvious to me how to get
+    // rid of it cleanly. For now we'll just assert that they're not.
+    if (tickCompare != NULL && sTickCompare != NULL && hSTickCompare != NULL)
+        panic("Tick comparison event active when clearing the ISA object.\n");
 #endif
 }
 
index 9b4fd50d058691bd31c3366aa5d7ccfecb8548b8..5fe57773ca323d0875996eb158992ef19ceb61f9 100644 (file)
@@ -205,6 +205,12 @@ namespace SparcISA
 
         ISA()
         {
+#if FULL_SYSTEM
+            tickCompare = NULL;
+            sTickCompare = NULL;
+            hSTickCompare = NULL;
+#endif
+
             clear();
         }
     };