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 <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Gabe Black
2021-04-12 05:52:33 -07:00
parent 07074f40e5
commit 8d99785080

View File

@@ -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;
}