Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: RFA: remote.c: parse thread ID's as unsigned values
Date: Wed, 27 Oct 2004 22:56:00 -0000	[thread overview]
Message-ID: <vt2654vhix9.fsf@zenia.home> (raw)


The GDB manual isn't clear on whether thread ID's carried in the
responses to the qfThreadInfo and the qC packet may have a sign; I'm
assuming that they're just a series of hex digits.

2004-10-27  Jim Blandy  <jimb@redhat.com>

	* remote.c (remote_threads_info, remote_current_thread): Use
	strtoul to parse thread ID numbers.

Index: gdb/remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.134
diff -c -r1.134 remote.c
*** gdb/remote.c	26 Apr 2004 09:02:41 -0000	1.134
--- gdb/remote.c	27 Oct 2004 21:26:40 -0000
***************
*** 1755,1761 ****
    putpkt ("qC");
    getpkt (buf, (rs->remote_packet_size), 0);
    if (buf[0] == 'Q' && buf[1] == 'C')
!     return pid_to_ptid (strtol (&buf[2], NULL, 16));
    else
      return oldpid;
  }
--- 1755,1766 ----
    putpkt ("qC");
    getpkt (buf, (rs->remote_packet_size), 0);
    if (buf[0] == 'Q' && buf[1] == 'C')
!     /* Use strtoul here, so we'll correctly parse values whose highest
!        bit is set.  The protocol carries them as a simple series of
!        hex digits; in the absence of a sign, strtol will see such
!        values as positive numbers out of range for signed 'long', and
!        return LONG_MAX to indicate an overflow.  */
!     return pid_to_ptid (strtoul (&buf[2], NULL, 16));
    else
      return oldpid;
  }
***************
*** 1802,1808 ****
  	    {
  	      do
  		{
! 		  tid = strtol (bufp, &bufp, 16);
  		  if (tid != 0 && !in_thread_list (pid_to_ptid (tid)))
  		    add_thread (pid_to_ptid (tid));
  		}
--- 1807,1819 ----
  	    {
  	      do
  		{
! 		  /* Use strtoul here, so we'll correctly parse values
! 		     whose highest bit is set.  The protocol carries
! 		     them as a simple series of hex digits; in the
! 		     absence of a sign, strtol will see such values as
! 		     positive numbers out of range for signed 'long',
! 		     and return LONG_MAX to indicate an overflow.  */
! 		  tid = strtoul (bufp, &bufp, 16);
  		  if (tid != 0 && !in_thread_list (pid_to_ptid (tid)))
  		    add_thread (pid_to_ptid (tid));
  		}


             reply	other threads:[~2004-10-27 22:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-27 22:56 Jim Blandy [this message]
2004-12-03  0:31 ` Jim Blandy
2004-12-03 21:54   ` Michael Snyder
2004-12-03 22:37     ` Daniel Jacobowitz
2004-12-07 20:26       ` Jim Blandy
2004-12-07 21:44         ` Eli Zaretskii
2004-12-08  6:05           ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt2654vhix9.fsf@zenia.home \
    --to=jimb@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox