Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids
@ 2025-08-05  7:19 Markus Metzger
  2025-08-05  7:19 ` [PATCH 2/2] gdb, remote: fix set_thread () in start_remote () Markus Metzger
  2025-08-14  3:36 ` [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids Thiago Jung Bauermann
  0 siblings, 2 replies; 14+ messages in thread
From: Markus Metzger @ 2025-08-05  7:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Thiago Jung Bauermann

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>
---
 gdbserver/remote-utils.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 15f073dd6be..9562cc2e1fb 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -566,6 +566,26 @@ read_ptid (const char *buf, const char **obuf)
   const char *p = buf;
   const char *pp;
 
+  /* Handle special thread ids.  */
+  if (*p == '0')
+    {
+      if (obuf)
+	*obuf = p + 1;
+
+      return null_ptid;
+    }
+
+  if (*p == '-')
+    {
+      if (p[1] != '1')
+	return null_ptid;
+
+      if (obuf)
+	*obuf = p + 2;
+
+      return minus_one_ptid;
+    }
+
   if (*p == 'p')
     {
       ULONGEST pid;
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-09-26  6:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-05  7:19 [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids Markus Metzger
2025-08-05  7:19 ` [PATCH 2/2] gdb, remote: fix set_thread () in start_remote () Markus Metzger
2025-08-14  4:29   ` Thiago Jung Bauermann
2025-08-14 22:28     ` Simon Marchi
2025-08-15  0:29       ` Thiago Jung Bauermann
2025-08-15  5:33         ` Simon Marchi
2025-08-18  1:43           ` Thiago Jung Bauermann
2025-09-22 13:29       ` Metzger, Markus T
2025-08-14  3:36 ` [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids Thiago Jung Bauermann
2025-08-14 20:40   ` Simon Marchi
2025-09-22 13:29     ` Metzger, Markus T
2025-09-23 18:26       ` Tom Tromey
2025-09-24  8:04         ` Metzger, Markus T
2025-09-26  6:43           ` Metzger, Markus T

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox