Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Nathan Froyd <froydnj <at> codesourcery.com>
Subject: [PATCH] fix internal errors on 64-bit remote tarets
Newsgroups: gmane.comp.gdb.patches
Date: Monday 13th July 2009 18:10:27 UTC (over 7 years ago)
remote.exp fails on mips-sde-elf because remote.c tries to limit the
minimum remote packet size to 20:
                                                                           
    
     - six bytes for $,:#NN                                                
    
     - one byte for 'M' or 'X'                                             
    
     - eight bytes for the address                                         
    
     - two bytes of hex-encoded payload                                    
    
     - two bytes of hex-encoded length                                     
    
     - one byte for null termination                                       
    
                                                                           
    
which does indeed come out to 20.  Except this is obviously wrong for
64-bit targets and is subtlely wrong for mips-sde-elf, because CORE_ADDR
there is a 64-bit type.  This patch bumps up the size unconditionally
and adds an explanatory comment about how we get to the value we did.
                                                                           
    
Tested on mips-sde-elf.  OK to commit?

-Nathan

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ff692ca..da588bc 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-07-13  Nathan Froyd  
+
+	* gdb.base/remote.exp: Adjust messages.
+
 2009-07-09  Tom Tromey  
 
 	* lib/gdb.exp: Handle TRANSCRIPT.
index dd0518a..c4b28c3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2009-07-13  Nathan Froyd  
+
+	* remote.c (MIN_REMOTE_PACKET_SIZE): Adjust for 64-bit targets.
+
 2009-07-10  Tom Tromey  
 
 	* dwarf2-frame.c: Include dwarf2.h, not elf/dwarf2.h.
diff --git a/gdb/remote.c b/gdb/remote.c
index 756186f..fad9de8 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -611,9 +611,20 @@ get_memory_packet_size (struct memory_packet_config
*config)
 #ifndef MAX_REMOTE_PACKET_SIZE
 #define MAX_REMOTE_PACKET_SIZE 16384
 #endif
-  /* NOTE: 20 ensures we can write at least one byte.  */
+  /* NOTE: This ensures we can write at least one byte.  For writing one
+     byte, we need:
+
+     - six bytes for $,:#NN
+     - one byte for 'M' or 'X'
+     - hexnumlen(address) bytes for the address
+     - two bytes of payload (after hex-encoding)
+     - two bytes of length (after hex-encoding)
+     - one byte for null termination
+
+     To accommodate 64-bit remote targets, then, we need 28 bytes at a
+     minimum.  */
 #ifndef MIN_REMOTE_PACKET_SIZE
-#define MIN_REMOTE_PACKET_SIZE 20
+#define MIN_REMOTE_PACKET_SIZE 28
 #endif
   long what_they_get;
   if (config->fixed_p)
diff --git a/gdb/testsuite/gdb.base/remote.exp
b/gdb/testsuite/gdb.base/remote.exp
index 113c56b..ad2e5eb 100644
--- a/gdb/testsuite/gdb.base/remote.exp
+++ b/gdb/testsuite/gdb.base/remote.exp
@@ -53,12 +53,12 @@ gdb_test "set remote memory-write-packet-size" \
 
 gdb_test "set remote memory-write-packet-size 20" ""
 gdb_test "show remote memory-write-packet-size" \
-	"The memory-write-packet-size is 20. Packets are limited to 20 bytes." \
+	"The memory-write-packet-size is 20. Packets are limited to 28 bytes." \
 	"set write-packet - small"
 
 gdb_test "set remote memory-write-packet-size 1" ""
 gdb_test "show remote memory-write-packet-size" \
-	"The memory-write-packet-size is 1. Packets are limited to 20 bytes." \
+	"The memory-write-packet-size is 1. Packets are limited to 28 bytes." \
 	"set write-packet - very-small"
 
 #
@@ -154,7 +154,7 @@ if {$sizeof_random_data > 16380 } then {
 gdb_test "set remote memory-read-packet-size 16" \
 	""
 gdb_test "show remote memory-read-packet-size" \
-	"The memory-read-packet-size is 16. Packets are limited to 20 bytes."
+	"The memory-read-packet-size is 16. Packets are limited to 28 bytes."
 gdb_test "x/17ub random_data" \
 	":\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[
\t\]+49\[ \t\]+207\[ \t\]+44.*:\[ \t\]+124\[ \t\]+38\[
\t\]+93\[ \t\]+125\[ \t\]+232\[ \t\]+67\[ \t\]+228\[
\t\]+56.*:\[ \t\]+161"
 
CD: 3ms