]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver, read_ptid: handle '0' and '-1' thread ids
authorMarkus Metzger <markus.t.metzger@intel.com>
Fri, 1 Aug 2025 09:44:44 +0000 (09:44 +0000)
committerMarkus Metzger <markus.t.metzger@intel.com>
Mon, 17 Nov 2025 07:12:38 +0000 (07:12 +0000)
The special thread id '-1' means 'all threads'.
The special thread id '0' means 'any thread'.

Read_ptid () currently returns

    <current pid>.-1.0

and

    <current pid>.0.0

respectively.

Change that to minus_one_ptid for '-1' and to null_ptid for '0'.

CC: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Tom Tromey <tom@tromey.com>
gdbserver/remote-utils.cc

index a89d5c66a81be9dc7043d3955a1120f4729feb4d..b7eed731749fe94e38f9419daa073bd7bb842ff6 100644 (file)
@@ -557,8 +557,8 @@ hex_or_minus_one (const char *buf, const char **obuf)
   return ret;
 }
 
-/* Extract a PTID from BUF.  If non-null, OBUF is set to the to one
-   passed the last parsed char.  Returns null_ptid on error.  */
+/* Extract a PTID from BUF.  If non-null, OBUF is set to one past the last
+   parsed char.  Throws on error.  */
 ptid_t
 read_ptid (const char *buf, const char **obuf)
 {
@@ -587,6 +587,13 @@ read_ptid (const char *buf, const char **obuf)
   /* No multi-process.  Just a tid.  */
   ULONGEST tid = hex_or_minus_one (p, &pp);
 
+  /* Handle special thread ids.  */
+  if (tid == (ULONGEST) -1)
+    return minus_one_ptid;
+
+  if (tid == 0)
+    return null_ptid;
+
   /* Since GDB is not sending a process id (multi-process extensions
      are off), then there's only one process.  Default to the first in
      the list.  */