base: cmdIsThreadAlive implementation
Some GDB implementations, specifically ARM's, needed this to be able to
switch between thread.
Change-Id: I0d4db0c008c336eac51008bcfefd04c375c333f7
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63527
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index fb778a6..2cc8402 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -971,7 +971,7 @@
// signal and step
{ 'S', { "KGDB_ASYNC_STEP", &BaseRemoteGDB::cmdAsyncStep } },
// find out if the thread is alive
- { 'T', { "KGDB_THREAD_ALIVE", &BaseRemoteGDB::cmdUnsupported } },
+ { 'T', { "KGDB_THREAD_ALIVE", &BaseRemoteGDB::cmdIsThreadAlive } },
//multi letter command
{ 'v', { "KGDB_MULTI_LETTER", &BaseRemoteGDB::cmdMultiLetter } },
// target exited
@@ -1106,6 +1106,22 @@
}
bool
+BaseRemoteGDB::cmdIsThreadAlive(GdbCommand::Context &ctx)
+{
+ const char *p = ctx.data;
+ int tid = 0;
+ bool all, any;
+ if (!parseThreadId(&p, all, any, tid))
+ throw CmdError("E01");
+ if (all)
+ throw CmdError("E03");
+ if (threads.find(tid) == threads.end())
+ throw CmdError("E04");
+ send("OK");
+ return true;
+}
+
+bool
BaseRemoteGDB::cmdMemR(GdbCommand::Context &ctx)
{
const char *p = ctx.data;
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 3d8f703..d0c4781 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -378,6 +378,7 @@
bool cmdRegR(GdbCommand::Context &ctx);
bool cmdRegW(GdbCommand::Context &ctx);
bool cmdSetThread(GdbCommand::Context &ctx);
+ bool cmdIsThreadAlive(GdbCommand::Context &ctx);
bool cmdMemR(GdbCommand::Context &ctx);
bool cmdMemW(GdbCommand::Context &ctx);
bool cmdQueryVar(GdbCommand::Context &ctx);