Jan Vrany has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/48183 )
Change subject: base: Do no listen for GDB when no `--wait-gdb` is specified
......................................................................
base: Do no listen for GDB when no `--wait-gdb` is specified
Remote GDB listening socket was open as soon as first thread has been
added, regardless whether a `--wait-gdb` has been specified or not.
Moreover, a message that gem5 is listening to GDB connection has been
printed as soon as the listening socket was open, but gem5 was ready
to accept data much later at workflow startup time. When GDB tried to
connect before gem5 was ready, a timeout on GDB side may (and did) have
occurred, depending on how fast was the host machine.
This commit solves both problems by opening the listening socket to
workflow startup and doing so only if `--wait-gdb` is specified.
Change-Id: Ibe09c8ed4564474eefcb7211f1b63acbe24c9efb
---
M src/base/remote_gdb.cc
M src/sim/workload.cc
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index a6c569e..76541d9 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -373,6 +373,9 @@
void
BaseRemoteGDB::listen()
{
+ panic_if(!tc, "Can't accept GDB connection without any threads.");
+ panic_if(listener.islistening(), "Already accepting GDB connection.");
+
if (ListenSocket::allDisabled()) {
warn_once("Sockets disabled, not accepting gdb connections");
return;
@@ -385,17 +388,11 @@
connectEvent = new ConnectEvent(this, listener.getfd(), POLLIN);
pollQueue.schedule(connectEvent);
-
- ccprintf(std::cerr, "%d: %s: listening for remote gdb on port %d\n",
- curTick(), name(), _port);
}
void
BaseRemoteGDB::connect()
{
- panic_if(!listener.islistening(),
- "Can't accept GDB connections without any threads!");
-
int sfd = listener.accept(true);
if (sfd != -1) {
@@ -448,10 +445,6 @@
// If no ThreadContext is current selected, select this one.
if (!tc)
assert(selectThreadContext(_tc->contextId()));
-
- // Now that we have a thread, we can start listening.
- if (!listener.islistening())
- listen();
}
void
diff --git a/src/sim/workload.cc b/src/sim/workload.cc
index d208a58..7b33780 100644
--- a/src/sim/workload.cc
+++ b/src/sim/workload.cc
@@ -97,6 +97,7 @@
// Now that we're about to start simulation, wait for GDB connections
if
// requested.
if (gdb && waitForRemoteGDB) {
+ gdb->listen();
inform("%s: Waiting for a remote GDB connection on port %d.",
name(),
gdb->port());
gdb->connect();
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48183
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: Ibe09c8ed4564474eefcb7211f1b63acbe24c9efb
Gerrit-Change-Number: 48183
Gerrit-PatchSet: 1
Gerrit-Owner: Jan Vrany <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s