]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Handle -1 in ptid_t::parse
authorTom Tromey <tromey@adacore.com>
Thu, 2 Jul 2026 18:12:49 +0000 (12:12 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 2 Jul 2026 18:55:33 +0000 (12:55 -0600)
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

index 5de1da3ba44ff00f31d72bfcd93e4df86d1a2c82..933e441f9b873992604ad213569774a51549e52d 100644 (file)
@@ -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)