From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6286 invoked by alias); 9 Feb 2005 11:54:11 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 6125 invoked from network); 9 Feb 2005 11:53:58 -0000 Received: from unknown (HELO mail.codesourcery.com) (65.74.133.9) by sourceware.org with SMTP; 9 Feb 2005 11:53:58 -0000 Received: (qmail 31587 invoked from network); 9 Feb 2005 11:53:57 -0000 Received: from localhost (HELO ?192.168.189.167?) (nathan@127.0.0.1) by mail.codesourcery.com with SMTP; 9 Feb 2005 11:53:57 -0000 Message-ID: <4209F9CE.4030405@codesourcery.com> Date: Wed, 09 Feb 2005 14:19:00 -0000 From: Nathan Sidwell Organization: Codesourcery LLC User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com CC: Paul Brook Subject: [PATCH] remote protocol cleanups Content-Type: multipart/mixed; boundary="------------030302050407080503080509" X-SW-Source: 2005-02/txt/msg00050.txt.bz2 This is a multi-part message in MIME format. --------------030302050407080503080509 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 845 Hi, This patch fixes a couple of problems with the remote protcol handling 1) remote_fetch_registers checks to see things have not got out of sync, but it does not deal with upper case hex characters and so can get confused 2) remote_write_bytes attempts to honour get_memory_write_packet_size's limit, but fails in two ways when that is a very small number. a) it can end up with a negative byte count. b) it deducts the number of chars in the *maximal* length count, not the number of chars in the actual length count. This can result in packets sending 1 or 2 bytes fewer than they are limited to. built & tested on i686-pc-linux-gnu and an unreleased architecture. ok? nathan -- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk --------------030302050407080503080509 Content-Type: text/plain; name="remote.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="remote.patch" Content-length: 2405 2005-02-09 Nathan Sidwell * remote.c (remote_fetch_registers): Allow uppercase hex when resyncing. (remote_write_bytes): Robustify packet size calculation for very small packets. Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.163 diff -c -3 -p -r1.163 remote.c *** remote.c 19 Jan 2005 21:15:44 -0000 1.163 --- remote.c 9 Feb 2005 11:09:39 -0000 *************** remote_fetch_registers (int regnum) *** 3307,3312 **** --- 3307,3313 ---- in the buffer is not a hex character, assume that has happened and try to fetch another packet to read. */ while ((buf[0] < '0' || buf[0] > '9') + && (buf[0] < 'A' || buf[0] > 'F') && (buf[0] < 'a' || buf[0] > 'f') && buf[0] != 'x') /* New: unavailable register value. */ { *************** remote_write_bytes (CORE_ADDR memaddr, c *** 3640,3649 **** buf = alloca (sizeof_buf); /* Compute the size of the actual payload by subtracting out the ! packet header and footer overhead: "$M,:...#nn". */ ! payload_size = (get_memory_write_packet_size () - (strlen ("$M,:#NN") ! + hexnumlen (memaddr) ! + hexnumlen (len))); /* Construct the packet header: "[MX],:". */ --- 3641,3651 ---- buf = alloca (sizeof_buf); /* Compute the size of the actual payload by subtracting out the ! packet header and footer overhead: "$M,:...#nn". ! */ ! payload_size = get_memory_write_packet_size (); ! payload_size -= strlen ("$M,:#NN"); ! payload_size -= hexnumlen (memaddr); /* Construct the packet header: "[MX],:". */ *************** remote_write_bytes (CORE_ADDR memaddr, c *** 3656,3666 **** --- 3658,3673 ---- *p++ = 'X'; /* Best guess at number of bytes that will fit. */ todo = min (len, payload_size); + payload_size -= hexnumlen (todo); + todo = min (todo, payload_size); break; case PACKET_DISABLE: *p++ = 'M'; /* Num bytes that will fit. */ todo = min (len, payload_size / 2); + payload_size -= hexnumlen (todo); + todo = min (todo, payload_size / 2); + todo = max (todo, 1); break; case PACKET_SUPPORT_UNKNOWN: internal_error (__FILE__, __LINE__, --------------030302050407080503080509--