diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base/remote_gdb.cc | 10 | ||||
-rw-r--r-- | src/base/remote_gdb.hh | 2 | ||||
-rw-r--r-- | src/cpu/BaseCPU.py | 3 | ||||
-rw-r--r-- | src/cpu/base.cc | 6 | ||||
-rw-r--r-- | src/cpu/base.hh | 2 | ||||
-rw-r--r-- | src/sim/system.cc | 16 |
6 files changed, 30 insertions, 9 deletions
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc index f7b0253a5..3b436cced 100644 --- a/src/base/remote_gdb.cc +++ b/src/base/remote_gdb.cc @@ -250,6 +250,16 @@ GDBListener::accept() } } +int +GDBListener::getPort() const +{ + panic_if(!listener.islistening(), + "Remote GDB port is unknown until GDBListener::listen() has " + "been called.\n"); + + return port; +} + BaseRemoteGDB::InputEvent::InputEvent(BaseRemoteGDB *g, int fd, int e) : PollEvent(fd, e), gdb(g) {} diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh index b860f5d33..b7de0ae54 100644 --- a/src/base/remote_gdb.hh +++ b/src/base/remote_gdb.hh @@ -364,6 +364,8 @@ class GDBListener void accept(); void listen(); std::string name(); + + int getPort() const; }; #endif /* __REMOTE_GDB_H__ */ diff --git a/src/cpu/BaseCPU.py b/src/cpu/BaseCPU.py index 550ba62ac..fcae74207 100644 --- a/src/cpu/BaseCPU.py +++ b/src/cpu/BaseCPU.py @@ -151,6 +151,9 @@ class BaseCPU(MemObject): profile = Param.Latency('0ns', "trace the kernel stack") do_quiesce = Param.Bool(True, "enable quiesce instructions") + wait_for_remote_gdb = Param.Bool(False, + "Wait for a remote GDB connection"); + workload = VectorParam.Process([], "processes to run") if buildEnv['TARGET_ISA'] == 'sparc': diff --git a/src/cpu/base.cc b/src/cpu/base.cc index 6f460d3af..78b25caf8 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -783,3 +783,9 @@ BaseCPU::traceFunctionsInternal(Addr pc) functionEntryTick = curTick(); } } + +bool +BaseCPU::waitForRemoteGDB() const +{ + return params()->wait_for_remote_gdb; +} diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 14dfc260b..b49f30272 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -589,6 +589,8 @@ class BaseCPU : public MemObject return &addressMonitor[tid]; } + bool waitForRemoteGDB() const; + Cycles syscallRetryLatency; }; diff --git a/src/sim/system.cc b/src/sim/system.cc index e46c35611..42cd5e720 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -58,6 +58,7 @@ #include "cpu/kvm/base.hh" #include "cpu/kvm/vm.hh" #endif +#include "cpu/base.hh" #include "cpu/thread_context.hh" #include "debug/Loader.hh" #include "debug/WorkItems.hh" @@ -221,13 +222,6 @@ bool System::breakpoint() return false; } -/** - * Setting rgdb_wait to a positive integer waits for a remote debugger to - * connect to that context ID before continuing. This should really - be a parameter on the CPU object or something... - */ -int rgdb_wait = -1; - ContextID System::registerThreadContext(ThreadContext *tc, ContextID assigned) { @@ -259,9 +253,13 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned) GDBListener *gdbl = new GDBListener(rgdb, port + id); gdbl->listen(); - if (rgdb_wait != -1 && rgdb_wait == id) - gdbl->accept(); + BaseCPU *cpu = tc->getCpuPtr(); + if (cpu->waitForRemoteGDB()) { + inform("%s: Waiting for a remote GDB connection on port %d.\n", + cpu->name(), gdbl->getPort()); + gdbl->accept(); + } if (remoteGDB.size() <= id) { remoteGDB.resize(id + 1); } |