From: Markus Metzger Date: Fri, 1 Aug 2025 09:44:44 +0000 (+0000) Subject: gdbserver, read_ptid: handle '0' and '-1' thread ids X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43ae0585aa438e66a5e1ed79b42afe986c18d0a3;p=thirdparty%2Fbinutils-gdb.git gdbserver, read_ptid: handle '0' and '-1' thread ids The special thread id '-1' means 'all threads'. The special thread id '0' means 'any thread'. Read_ptid () currently returns .-1.0 and .0.0 respectively. Change that to minus_one_ptid for '-1' and to null_ptid for '0'. CC: Thiago Jung Bauermann Approved-By: Tom Tromey --- diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index a89d5c66a81..b7eed731749 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -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. */