From: Ciaran Woodward Date: Tue, 19 Jul 2022 15:23:53 +0000 (+0100) Subject: gdb/remote: Set the thread of the remote before sending qRcmd. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd217f6d0570c56cf15faf9852753bc56b504bbf;p=thirdparty%2Fbinutils-gdb.git gdb/remote: Set the thread of the remote before sending qRcmd. GDB allows remotes to implement extension commands which can be accessed using the 'monitor' command. This allows remotes to implement functionality which does not exist in GDB for whatever reason (doesn't make sense, too specific to one target, etc.) However, before this change, the remote would not necessarily know which thread/inferior was currently selected on the GDB client. This prevents the implementation of any 'monitor' commands which are specific to a single inferior/thread on the remote. This is because GDB informs the remote of the current thread lazily - only when it is relevant to the RSP command next being sent. qRcmd is the underlying RSP command used for monitor commands, so this change ensures that GDB will update the remote with the 'current' thread if it has changed since the remote was last informed. Approved-By: Tom Tromey --- diff --git a/gdb/remote.c b/gdb/remote.c index 9dfc372fc41..87946490a9e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -12072,6 +12072,9 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf) if (command == NULL) command = ""; + /* It might be important for this command to know the current thread. */ + set_general_thread (inferior_ptid); + /* The query prefix. */ strcpy (rs->buf.data (), "qRcmd,"); p = strchr (rs->buf.data (), '\0');