From 8d99785080394cec46e0dcde0c0d9a84a1c3d16f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 12 Apr 2021 05:52:33 -0700 Subject: [PATCH] base: Fill out the 'H' thread setting command in remote GDB. Distinguish between the 'g' and 'c' subcommands. 'c' sets what thread(s) should be continued or single stepped when those commands are used, and 'g' sets what thread(s) should be used for anything else. Also, insist that all threads are used for continuing or single stepping. Still complain if we're asked to switch threads, since we only have one and we can't change to anything else. Change-Id: Ia15c055baba48f75fc29ef369567535b0aa2c76b Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44609 Tested-by: kokoro Reviewed-by: Bobby R. Bruce Reviewed-by: Daniel Carvalho Maintainer: Bobby R. Bruce --- src/base/remote_gdb.cc | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc index efda8e85cf..98686cf56e 100644 --- a/src/base/remote_gdb.cc +++ b/src/base/remote_gdb.cc @@ -909,13 +909,33 @@ BaseRemoteGDB::cmdRegW(GdbCommand::Context &ctx) bool BaseRemoteGDB::cmdSetThread(GdbCommand::Context &ctx) { - const char *p = ctx.data + 1; // Ignore the subcommand byte. - ContextID tid = 0; + const char *p = ctx.data; + char subcommand = *p++; + int tid = 0; bool all, any; if (!parseThreadId(&p, all, any, tid)) throw CmdError("E01"); - if (any || all || tid != tc->contextId()) - throw CmdError("E02"); + + if (subcommand == 'c') { + // We can only single step or continue all threads at once, since we + // stop time itself and not individual threads. + if (!all) + throw CmdError("E02"); + } else if (subcommand == 'g') { + // We don't currently support reading registers, memory, etc, from all + // threads at once. GDB may never ask for this, but if it does we + // should complain. + if (all) + throw CmdError("E03"); + // If GDB cares which thread we're using and wants a different one, we + // don't support that right now. + if (!any && tid != tc->contextId()) + throw CmdError("E04"); + // Since we weren't asked to do anything, we succeeded. + } else { + throw CmdError("E05"); + } + send("OK"); return true; }