Make it easier to turn off the remote debugger
authorNathan Binkert <binkertn@umich.edu>
Thu, 22 Feb 2007 06:25:48 +0000 (22:25 -0800)
committerNathan Binkert <binkertn@umich.edu>
Thu, 22 Feb 2007 06:25:48 +0000 (22:25 -0800)
--HG--
extra : convert_revision : d88784736df5f9b498770fb7e98f52715669c0e1

src/sim/system.cc

index f6febe4b199bf7c126fd9ca41ab9d31184b6e8e9..1a87e1754f0020e4d84d70665a6b79ea2f4a9c8a 100644 (file)
@@ -142,6 +142,7 @@ System::~System()
 }
 
 int rgdb_wait = -1;
+int rgdb_enable = true;
 
 void
 System::setMemoryMode(MemoryMode mode)
@@ -152,7 +153,9 @@ System::setMemoryMode(MemoryMode mode)
 
 bool System::breakpoint()
 {
-    return remoteGDB[0]->breakpoint();
+    if (remoteGDB.size())
+        return remoteGDB[0]->breakpoint();
+    return false;
 }
 
 int
@@ -174,22 +177,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;
 }
 
@@ -210,7 +215,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