Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [pushed] Handle -1 in ptid_t::parse
@ 2026-07-02 18:56 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2026-07-02 18:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

ptid_t::parse fails to correctly handle the -1 return from
hex_or_minus_one in the 'p' case.  As Mark Wielaard pointed out, it
does this check:

      if (hex != ((unsigned_lwp_type) lwp))

However on 32-bit, this means that it will mishandle (ULONGEST) -1.

This patch fixes the problem by adding a check for the -1 case.

I built a -m32 gdb and verified this fix; I'm checking it in.
---
 gdbsupport/ptid.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdbsupport/ptid.cc b/gdbsupport/ptid.cc
index 5de1da3ba44..933e441f9b8 100644
--- a/gdbsupport/ptid.cc
+++ b/gdbsupport/ptid.cc
@@ -109,7 +109,7 @@ ptid_t::parse (const char *buf, const char **obuf, bool for_remote,
 	error (_("invalid remote ptid: %s"), buf);
 
       lwp = (ptid_t::lwp_type) hex;
-      if (hex != ((unsigned_lwp_type) lwp))
+      if (hex != ((unsigned_lwp_type) lwp) && hex != (ULONGEST) -1)
 	error (_("invalid remote ptid: %s"), buf);
 
       if (obuf != nullptr)

base-commit: de5bd217372a41c119492ef90ebd53eaae78f248
-- 
2.54.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-02 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-02 18:56 [pushed] Handle -1 in ptid_t::parse Tom Tromey

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