From c2baaab0ed43ad09fc8b7fcda25207b6ccd6c0e3 Mon Sep 17 00:00:00 2001 From: Jose Marinho Date: Wed, 28 Jun 2017 11:09:13 +0100 Subject: cpu, sim: Add param to force CPUs to wait for GDB By setting the BaseCPU parameter wait_for_dbg_connection, the GDB server blocks during initialisation waiting for the remote debugger to connect before starting the simulated CPU. Change-Id: I4d62c68ce9adf69344bccbb44f66e30b33715a1c [ Update info message to include remote GDB port, rename param. ] Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/3963 Reviewed-by: Gabe Black Reviewed-by: Anthony Gutierrez --- src/sim/system.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/sim/system.cc') 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); } -- cgit v1.2.3