public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug remote/14314] New: PID read as ULONGEST but written as int
@ 2012-06-29 15:39 obilaniu at yahoo dot com
  2012-06-29 15:42 ` [Bug remote/14314] " obilaniu at yahoo dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: obilaniu at yahoo dot com @ 2012-06-29 15:39 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14314

             Bug #: 14314
           Summary: PID read as ULONGEST but written as int
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: remote
        AssignedTo: unassigned@sourceware.org
        ReportedBy: obilaniu@yahoo.com
    Classification: Unclassified


In remote.c, there is a mismatch in the way the remote protocol reads and
writes PTIDs in the functions write_ptid() and read_ptid().


- In read_ptid(), both the PID and the TID are declared and read as ULONGEST
(64-bit?).
- In write_ptid(), the PID is declared a (signed, 32-bit?) int and the TID is
declared a (signed, 64-bit?) long, but are written with xsnprintf() as unsigned
hex integers.


This asymmetry causes a problem on remote targets where there exists a PID (or
TID) larger than or equal to 2^31 (2^63). In that case, GDB will read correctly
the PID (TID) from the qxThreadInfo exchange, but when using the T packet to
later verify the existence of the PID (TID), instead of querying with the true
ID, it's two's complement is sent. This leads to gdbstub replying with E01 that
such a thread ID does not exist, and when subsequently GDB queries for what
threads do exist, it "rediscovers" the PID (TID) even though it was always
there.



Proposed solutions:
- Short-term: Repair write_ptid() by declaring both PID and TID to be ULONGEST
and replacing the xsnprintf() format specifier "%x" by "%lx".

- Long-term: Widen ptid_t 's PID field to a long-size integer. Also widen the
return type of ptid_get_pid(), ptid_build(), etc. accordingly.


The reason why high-valued PIDs and TIDs may exist is that on some systems, the
integer identifier is in fact a cast pointer to its (malloc-ed) block.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug remote/14314] PID read as ULONGEST but written as int
  2012-06-29 15:39 [Bug remote/14314] New: PID read as ULONGEST but written as int obilaniu at yahoo dot com
@ 2012-06-29 15:42 ` obilaniu at yahoo dot com
  2022-01-07 21:03 ` tromey at sourceware dot org
  2022-01-07 21:11 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: obilaniu at yahoo dot com @ 2012-06-29 15:42 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14314

obilaniu at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |obilaniu at yahoo dot com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug remote/14314] PID read as ULONGEST but written as int
  2012-06-29 15:39 [Bug remote/14314] New: PID read as ULONGEST but written as int obilaniu at yahoo dot com
  2012-06-29 15:42 ` [Bug remote/14314] " obilaniu at yahoo dot com
@ 2022-01-07 21:03 ` tromey at sourceware dot org
  2022-01-07 21:11 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at sourceware dot org @ 2022-01-07 21:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14314

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
This seems to still be a problem.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug remote/14314] PID read as ULONGEST but written as int
  2012-06-29 15:39 [Bug remote/14314] New: PID read as ULONGEST but written as int obilaniu at yahoo dot com
  2012-06-29 15:42 ` [Bug remote/14314] " obilaniu at yahoo dot com
  2022-01-07 21:03 ` tromey at sourceware dot org
@ 2022-01-07 21:11 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at sourceware dot org @ 2022-01-07 21:11 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14314

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
The other bug has a patch.

*** This bug has been marked as a duplicate of bug 25111 ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2022-01-07 21:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29 15:39 [Bug remote/14314] New: PID read as ULONGEST but written as int obilaniu at yahoo dot com
2012-06-29 15:42 ` [Bug remote/14314] " obilaniu at yahoo dot com
2022-01-07 21:03 ` tromey at sourceware dot org
2022-01-07 21:11 ` tromey at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).