Get rid of the immediate and displacement components of the EmulEnv struct and use...
[gem5.git] / src / sim / system.cc
index f6febe4b199bf7c126fd9ca41ab9d31184b6e8e9..2d0eaaf5bd93993770c5e64c9a4fcb5e74e5fd06 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "arch/isa_traits.hh"
 #include "arch/remote_gdb.hh"
+#include "arch/utility.hh"
 #include "base/loader/object_file.hh"
 #include "base/loader/symtab.hh"
 #include "base/trace.hh"
@@ -142,6 +143,7 @@ System::~System()
 }
 
 int rgdb_wait = -1;
+int rgdb_enable = true;
 
 void
 System::setMemoryMode(MemoryMode mode)
@@ -152,7 +154,9 @@ System::setMemoryMode(MemoryMode mode)
 
 bool System::breakpoint()
 {
-    return remoteGDB[0]->breakpoint();
+    if (remoteGDB.size())
+        return remoteGDB[0]->breakpoint();
+    return false;
 }
 
 int
@@ -174,22 +178,24 @@ System::registerThreadContext(ThreadContext *tc, int id)
     threadContexts[id] = tc;
     numcpus++;
 
-    RemoteGDB *rgdb = new RemoteGDB(this, tc);
-    GDBListener *gdbl = new GDBListener(rgdb, 7000 + id);
-    gdbl->listen();
-    /**
-     * Uncommenting this line waits for a remote debugger to connect
-     * to the simulator before continuing.
-     */
-    if (rgdb_wait != -1 && rgdb_wait == id)
-        gdbl->accept();
+    if (rgdb_enable) {
+        RemoteGDB *rgdb = new RemoteGDB(this, tc);
+        GDBListener *gdbl = new GDBListener(rgdb, 7000 + id);
+        gdbl->listen();
+        /**
+         * Uncommenting this line waits for a remote debugger to
+         * connect to the simulator before continuing.
+         */
+        if (rgdb_wait != -1 && rgdb_wait == id)
+            gdbl->accept();
+
+        if (remoteGDB.size() <= id) {
+            remoteGDB.resize(id + 1);
+        }
 
-    if (remoteGDB.size() <= id) {
-        remoteGDB.resize(id + 1);
+        remoteGDB[id] = rgdb;
     }
 
-    remoteGDB[id] = rgdb;
-
     return id;
 }
 
@@ -198,7 +204,7 @@ System::startup()
 {
     int i;
     for (i = 0; i < threadContexts.size(); i++)
-        threadContexts[i]->activate(0);
+        TheISA::startupCPU(threadContexts[i], i);
 }
 
 void
@@ -210,7 +216,8 @@ System::replaceThreadContext(ThreadContext *tc, int id)
     }
 
     threadContexts[id] = tc;
-    remoteGDB[id]->replaceThreadContext(tc);
+    if (id < remoteGDB.size())
+        remoteGDB[id]->replaceThreadContext(tc);
 }
 
 #if !FULL_SYSTEM