sim,arch: Move code that waits for a GDB connection to startup().
Currently the System class has a mechanism to wait for a GDB connection for each CPU which has requested it through one of its parameters. Unfortunately, not every thread context/CPU will be ready for GDB at that point, particularly considering that in an FS simulation the kernel won't have been read so there will be no symbols, none of the registers or the entry point will have been set. Also in the fast models, the CPUs haven't had a chance to initialize themselves enough by that point to respond to the API calls which are used to implement GDB support. Change-Id: If27cb3e0259a1f67599ab0493695b2f8af640d8e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24963 Reviewed-by: Gabe Black <gabeblack@google.com> Reviewed-by: Chun-Chen TK Hsu <chunchenhsu@google.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -147,8 +147,3 @@ FreebsdArmSystemParams::create()
|
||||
{
|
||||
return new FreebsdArmSystem(this);
|
||||
}
|
||||
|
||||
void
|
||||
FreebsdArmSystem::startup()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -74,8 +74,6 @@ class FreebsdArmSystem : public GenericArmSystem
|
||||
|
||||
void initState();
|
||||
|
||||
void startup();
|
||||
|
||||
/** This function creates a new task Id for the given pid.
|
||||
* @param tc thread context that is currentyl executing */
|
||||
void mapPid(ThreadContext* tc, uint32_t pid);
|
||||
|
||||
@@ -223,6 +223,8 @@ LinuxArmSystemParams::create()
|
||||
void
|
||||
LinuxArmSystem::startup()
|
||||
{
|
||||
GenericArmSystem::startup();
|
||||
|
||||
if (enableContextSwitchStatsDump) {
|
||||
if (!highestELIs64()) {
|
||||
dumpStatsPCEvent =
|
||||
|
||||
@@ -228,6 +228,31 @@ System::init()
|
||||
panic("System port on %s is not connected.\n", name());
|
||||
}
|
||||
|
||||
void
|
||||
System::startup()
|
||||
{
|
||||
SimObject::startup();
|
||||
|
||||
// Now that we're about to start simulation, wait for GDB connections if
|
||||
// requested.
|
||||
#if THE_ISA != NULL_ISA
|
||||
for (auto *tc: threadContexts) {
|
||||
auto *cpu = tc->getCpuPtr();
|
||||
auto id = tc->contextId();
|
||||
if (remoteGDB.size() <= id)
|
||||
continue;
|
||||
auto *rgdb = remoteGDB[id];
|
||||
|
||||
if (cpu->waitForRemoteGDB()) {
|
||||
inform("%s: Waiting for a remote GDB connection on port %d.\n",
|
||||
cpu->name(), rgdb->port());
|
||||
|
||||
rgdb->connect();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Port &
|
||||
System::getPort(const std::string &if_name, PortID idx)
|
||||
{
|
||||
@@ -276,16 +301,8 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned)
|
||||
RemoteGDB *rgdb = new RemoteGDB(this, tc, port + id);
|
||||
rgdb->listen();
|
||||
|
||||
BaseCPU *cpu = tc->getCpuPtr();
|
||||
if (cpu->waitForRemoteGDB()) {
|
||||
inform("%s: Waiting for a remote GDB connection on port %d.\n",
|
||||
cpu->name(), rgdb->port());
|
||||
|
||||
rgdb->connect();
|
||||
}
|
||||
if (remoteGDB.size() <= id) {
|
||||
if (remoteGDB.size() <= id)
|
||||
remoteGDB.resize(id + 1);
|
||||
}
|
||||
|
||||
remoteGDB[id] = rgdb;
|
||||
}
|
||||
|
||||
@@ -99,11 +99,8 @@ class System : public SimObject, public PCEventScope
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* After all objects have been created and all ports are
|
||||
* connected, check that the system port is connected.
|
||||
*/
|
||||
void init() override;
|
||||
void startup() override;
|
||||
|
||||
/**
|
||||
* Get a reference to the system port that can be used by
|
||||
|
||||
Reference in New Issue
Block a user