This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch gdb]: Fix PR gdb/15161 part 3 of 3


On 02/19/2013 05:19 PM, Kai Tietz wrote:
> Hi,
> 
> this patch fixes part three of the PR gdb/15161 issue in
> gdbserver/server.c file.
> Here we are using to evaluate 'long long' types via strto(u)l instead
> of strto(u)ll function.
> That patch fixes that.

Thanks for that patch.  However, we use unpack_varlen_hex
throughout gdbserver for this purpose.

I'm applying this alternative patch.

commit fc8368b5927a61d0a62509adf9cc4862f01ec34b
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Feb 19 19:49:01 2013 +0000

    gdbserver:server.c - use unpack_varlen_hex to extract hex numbers.
    
    Addresses, as most numbers in the RSP are hex encoded, with variable
    length (that just means the width isn't specified, and there's no top
    cap.  So they should be extracted with unpack_varlen_hex.
    
    A couple spots in server.c are using strto(u)l, which doesn't work on
    LLP64 targets.
    
    This patch fixes it.
    
    Tested on x86_64 Fedora 17.
    
    2013-02-19  Pedro Alves  <palves@redhat.com>
    	    Kai Tietz <ktietz@redhat.com>
    
    	PR gdb/15161
    
    	* server.c (handle_query) <CRC check>: Use unpack_varlen_hex
    	instead of strtoul to extract address from packet.
    	(process_serial_event) <'z'>: Likewise.

diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 775d9ef..371647c 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -1808,12 +1808,12 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
     {
       /* CRC check (compare-section).  */
       char *comma;
-      CORE_ADDR base;
+      ULONGEST base;
       int len;
       unsigned long long crc;
 
       require_running (own_buf);
-      base = strtoul (own_buf + 5, &comma, 16);
+      comma = unpack_varlen_hex (own_buf + 5, &base);
       if (*comma++ != ',')
 	{
 	  write_enn (own_buf);
@@ -3192,13 +3192,16 @@ process_serial_event (void)
       /* Fallthrough.  */
     case 'z':  /* remove_ ... */
       {
-	char *lenptr;
 	char *dataptr;
-	CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16);
-	int len = strtol (lenptr + 1, &dataptr, 16);
+	ULONGEST addr;
+	int len;
 	char type = own_buf[1];
 	int res;
 	const int insert = ch == 'Z';
+	char *p = &own_buf[3];
+
+	p = unpack_varlen_hex (p, &addr);
+	len = strtol (p + 1, &dataptr, 16);
 
 	/* Default to unrecognized/unsupported.  */
 	res = 1;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]