]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/remote: Set the thread of the remote before sending qRcmd.
authorCiaran Woodward <ciaranwoodward@xmos.com>
Tue, 19 Jul 2022 15:23:53 +0000 (16:23 +0100)
committerCiaran Woodward <ciaranwoodward@xmos.com>
Tue, 25 Feb 2025 11:27:18 +0000 (11:27 +0000)
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 <tom@tromey.com>
gdb/remote.c

index 9dfc372fc41b4c9f448926b817999b850087989c..87946490a9e99e9760717af2aae09b8adab1f033 100644 (file)
@@ -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');