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 <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/3963 Reviewed-by: Gabe Black <gabeblack@google.com> Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
This commit is contained in:
committed by
Andreas Sandberg
parent
eef537fd99
commit
c2baaab0ed
@@ -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)
|
BaseRemoteGDB::InputEvent::InputEvent(BaseRemoteGDB *g, int fd, int e)
|
||||||
: PollEvent(fd, e), gdb(g)
|
: PollEvent(fd, e), gdb(g)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -364,6 +364,8 @@ class GDBListener
|
|||||||
void accept();
|
void accept();
|
||||||
void listen();
|
void listen();
|
||||||
std::string name();
|
std::string name();
|
||||||
|
|
||||||
|
int getPort() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __REMOTE_GDB_H__ */
|
#endif /* __REMOTE_GDB_H__ */
|
||||||
|
|||||||
@@ -151,6 +151,9 @@ class BaseCPU(MemObject):
|
|||||||
profile = Param.Latency('0ns', "trace the kernel stack")
|
profile = Param.Latency('0ns', "trace the kernel stack")
|
||||||
do_quiesce = Param.Bool(True, "enable quiesce instructions")
|
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")
|
workload = VectorParam.Process([], "processes to run")
|
||||||
|
|
||||||
if buildEnv['TARGET_ISA'] == 'sparc':
|
if buildEnv['TARGET_ISA'] == 'sparc':
|
||||||
|
|||||||
@@ -783,3 +783,9 @@ BaseCPU::traceFunctionsInternal(Addr pc)
|
|||||||
functionEntryTick = curTick();
|
functionEntryTick = curTick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BaseCPU::waitForRemoteGDB() const
|
||||||
|
{
|
||||||
|
return params()->wait_for_remote_gdb;
|
||||||
|
}
|
||||||
|
|||||||
@@ -589,6 +589,8 @@ class BaseCPU : public MemObject
|
|||||||
return &addressMonitor[tid];
|
return &addressMonitor[tid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForRemoteGDB() const;
|
||||||
|
|
||||||
Cycles syscallRetryLatency;
|
Cycles syscallRetryLatency;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
#include "cpu/kvm/base.hh"
|
#include "cpu/kvm/base.hh"
|
||||||
#include "cpu/kvm/vm.hh"
|
#include "cpu/kvm/vm.hh"
|
||||||
#endif
|
#endif
|
||||||
|
#include "cpu/base.hh"
|
||||||
#include "cpu/thread_context.hh"
|
#include "cpu/thread_context.hh"
|
||||||
#include "debug/Loader.hh"
|
#include "debug/Loader.hh"
|
||||||
#include "debug/WorkItems.hh"
|
#include "debug/WorkItems.hh"
|
||||||
@@ -221,13 +222,6 @@ bool System::breakpoint()
|
|||||||
return false;
|
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
|
ContextID
|
||||||
System::registerThreadContext(ThreadContext *tc, ContextID assigned)
|
System::registerThreadContext(ThreadContext *tc, ContextID assigned)
|
||||||
{
|
{
|
||||||
@@ -259,9 +253,13 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned)
|
|||||||
GDBListener *gdbl = new GDBListener(rgdb, port + id);
|
GDBListener *gdbl = new GDBListener(rgdb, port + id);
|
||||||
gdbl->listen();
|
gdbl->listen();
|
||||||
|
|
||||||
if (rgdb_wait != -1 && rgdb_wait == id)
|
BaseCPU *cpu = tc->getCpuPtr();
|
||||||
gdbl->accept();
|
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) {
|
if (remoteGDB.size() <= id) {
|
||||||
remoteGDB.resize(id + 1);
|
remoteGDB.resize(id + 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user