Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/44617 )
Change subject: sim,cpu: Move the remote GDB stub into the workload.
......................................................................
sim,cpu: Move the remote GDB stub into the workload.
There are two user visible effects of this change. First, all of the
threads for a particular workload are moved under a single GDB instance.
The GDB session can see all the threads at once, and can let you move
between them as you want.
Second, since there is a GDB instance per workload and not per CPU, the
wait_for_gdb parameter was moved to the workload.
Change-Id: I510410c3cbb56e445b0fbb1def94c769d3a7b2e3
---
M src/cpu/BaseCPU.py
M src/cpu/base.cc
M src/cpu/base.hh
M src/sim/Workload.py
M src/sim/system.cc
M src/sim/system.hh
M src/sim/workload.cc
M src/sim/workload.hh
8 files changed, 42 insertions(+), 45 deletions(-)
diff --git a/src/cpu/BaseCPU.py b/src/cpu/BaseCPU.py
index cb43419..bd702e2 100644
--- a/src/cpu/BaseCPU.py
+++ b/src/cpu/BaseCPU.py
@@ -146,9 +146,6 @@
do_statistics_insts = Param.Bool(True,
"enable statistics pseudo instructions")
- wait_for_remote_gdb = Param.Bool(False,
- "Wait for a remote GDB connection");
-
workload = VectorParam.Process([], "processes to run")
mmu = Param.BaseMMU(ArchMMU(), "CPU memory management unit")
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index c40c001..3eaa1e8 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -724,12 +724,6 @@
}
}
-bool
-BaseCPU::waitForRemoteGDB() const
-{
- return params().wait_for_remote_gdb;
-}
-
BaseCPU::GlobalStats::GlobalStats(::Stats::Group *parent)
: ::Stats::Group(parent),
diff --git a/src/cpu/base.hh b/src/cpu/base.hh
index 6d324da..e7b2ccc 100644
--- a/src/cpu/base.hh
+++ b/src/cpu/base.hh
@@ -623,8 +623,6 @@
return &addressMonitor[tid];
}
- bool waitForRemoteGDB() const;
-
Cycles syscallRetryLatency;
// Enables CPU to enter power gating on a configurable cycle count
diff --git a/src/sim/Workload.py b/src/sim/Workload.py
index 4f1b1b5..91c1c55 100644
--- a/src/sim/Workload.py
+++ b/src/sim/Workload.py
@@ -33,6 +33,9 @@
cxx_header = "sim/workload.hh"
abstract = True
+ wait_for_remote_gdb = Param.Bool(False,
+ "Wait for a remote GDB connection");
+
class KernelWorkload(Workload):
type = 'KernelWorkload'
cxx_header = "sim/kernel_workload.hh"
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 9fd312c..1d39f36 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -43,7 +43,6 @@
#include <algorithm>
-#include "arch/remote_gdb.hh"
#include "base/compiler.hh"
#include "base/loader/object_file.hh"
#include "base/loader/symtab.hh"
@@ -124,13 +123,6 @@
// been reallocated.
t.resumeEvent = new EventFunctionWrapper(
[this, id](){ thread(id).resume(); }, sys->name());
-# if THE_ISA != NULL_ISA
- int port = getRemoteGDBPort();
- if (port) {
- t.gdb = new TheISA::RemoteGDB(sys, tc, port + id);
- t.gdb->listen();
- }
-# endif
}
void
@@ -138,8 +130,6 @@
{
auto &t = thread(id);
panic_if(!t.context, "Can't replace a context which doesn't exist.");
- if (t.gdb)
- t.gdb->replaceThreadContext(tc);
# if THE_ISA != NULL_ISA
if (t.resumeEvent->scheduled()) {
Tick when = t.resumeEvent->when();
@@ -262,26 +252,6 @@
delete workItemStats[j];
}
-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 (int i = 0; i < threads.size(); i++) {
- auto *gdb = threads.thread(i).gdb;
- auto *cpu = threads[i]->getCpuPtr();
- if (gdb && cpu->waitForRemoteGDB()) {
- inform("%s: Waiting for a remote GDB connection on port %d.",
- cpu->name(), gdb->port());
- gdb->connect();
- }
- }
-#endif
-}
-
Port &
System::getPort(const std::string &if_name, PortID idx)
{
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 6613217..37acf2c 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -118,7 +118,6 @@
{
ThreadContext *context = nullptr;
bool active = false;
- BaseRemoteGDB *gdb = nullptr;
Event *resumeEvent = nullptr;
void resume();
@@ -230,8 +229,6 @@
const_iterator end() const { return const_iterator(*this, size());
}
};
- void startup() override;
-
/**
* Get a reference to the system port that can be used by
* non-structural simulation objects like processes or threads, or
diff --git a/src/sim/workload.cc b/src/sim/workload.cc
index c7dfcd4..989305b 100644
--- a/src/sim/workload.cc
+++ b/src/sim/workload.cc
@@ -27,7 +27,9 @@
#include "sim/workload.hh"
+#include "arch/remote_gdb.hh"
#include "cpu/thread_context.hh"
+#include "sim/debug.hh"
void
Workload::registerThreadContext(ThreadContext *tc)
@@ -37,6 +39,16 @@
std::tie(it, success) = threads.insert(tc);
panic_if(!success, "Failed to add thread context %d.",
tc->contextId());
+
+# if THE_ISA != NULL_ISA
+ int port = getRemoteGDBPort();
+ if (port && !gdb) {
+ gdb = new TheISA::RemoteGDB(system, tc, port);
+ gdb->listen();
+ } else if (gdb) {
+ gdb->addThreadContext(tc);
+ }
+# endif
}
void
@@ -54,7 +66,27 @@
std::tie(it, success) = threads.insert(tc);
panic_if(!success,
"Failed to insert replacement thread context %d.", id);
+
+ if (gdb)
+ gdb->replaceThreadContext(tc);
+
return;
}
panic("Replacement thread context %d doesn't match any known id.", id);
}
+
+void
+Workload::startup()
+{
+ SimObject::startup();
+
+# if THE_ISA != NULL_ISA
+ // Now that we're about to start simulation, wait for GDB connections
if
+ // requested.
+ if (gdb && waitForRemoteGDB) {
+ inform("%s: Waiting for a remote GDB connection on port %d.",
name(),
+ gdb->port());
+ gdb->connect();
+ }
+# endif
+}
diff --git a/src/sim/workload.hh b/src/sim/workload.hh
index f3b55ad..3418a7d 100644
--- a/src/sim/workload.hh
+++ b/src/sim/workload.hh
@@ -37,6 +37,7 @@
#include "sim/sim_object.hh"
#include "sim/stats.hh"
+class BaseRemoteGDB;
class System;
class ThreadContext;
@@ -66,10 +67,13 @@
{}
} stats;
+ BaseRemoteGDB *gdb = nullptr;
+ bool waitForRemoteGDB = false;
std::set<ThreadContext *> threads;
public:
- Workload(const WorkloadParams ¶ms) : SimObject(params), stats(this)
+ Workload(const WorkloadParams ¶ms) : SimObject(params),
stats(this),
+ waitForRemoteGDB(params.wait_for_remote_gdb)
{}
void recordQuiesce() { stats.instStats.quiesce++; }
@@ -80,6 +84,8 @@
virtual void registerThreadContext(ThreadContext *tc);
virtual void replaceThreadContext(ThreadContext *tc);
+ void startup() override;
+
virtual Addr getEntry() const = 0;
virtual Loader::Arch getArch() const = 0;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44617
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I510410c3cbb56e445b0fbb1def94c769d3a7b2e3
Gerrit-Change-Number: 44617
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s