This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] [PATCH] handle timeout in read_frame
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA] [PATCH] handle timeout in read_frame
- From: Michael Elizabeth Chastain <chastain at cygnus dot com>
- Date: Mon, 21 Aug 2000 13:18:24 -0700
This patch fixes a timeout bug in remote.c.
If a timeout occurs while reading the packet checksum, read_frame
treats the timeout as an ordinary input character with a value of "-2".
gdb not only loses that frame: it throws an error out of fromhex.
This causes a lot of random testsuite failures with the message "Reply
contains invalid hex digit -2".
Testing: first, find a host, target, and testsuite that suffer from the
"invalid hex digit -2" problem. I used a Red Hat Linux 6.0 box for the
host, i386-pc-aout for the target and call-ar-st.exp for the testsuite.
Here's an excerpt from gdb.log before the patch:
Reply contains invalid hex digit -2
FAIL: gdb.base/call-ar-st.exp: (timeout) print print_array_rep(*list1, *list2, *list3)
After the patch, these errors go away.
Michael Elizabeth Chastain
<chastain@redhat.com>
"love without fear"
===
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.21
diff -c -3 -p -r1.21 remote.c
*** remote.c 2000/08/18 22:52:23 1.21
--- remote.c 2000/08/21 19:50:11
*************** read_frame (char *buf,
*** 3871,3882 ****
case '#':
{
unsigned char pktcsum;
buf[bc] = '\0';
! pktcsum = fromhex (readchar (remote_timeout)) << 4;
! pktcsum |= fromhex (readchar (remote_timeout));
if (csum == pktcsum)
return bc;
--- 3871,3895 ----
case '#':
{
unsigned char pktcsum;
+ int check_0 = 0;
+ int check_1 = 0;
buf[bc] = '\0';
! check_0 = readchar (remote_timeout);
! if (check_0 >= 0)
! check_1 = readchar (remote_timeout);
!
! if (check_0 == SERIAL_TIMEOUT || check_1 == SERIAL_TIMEOUT)
! {
! if (remote_debug)
! fputs_filtered ("Timeout in checksum, retrying\n", gdb_stdlog);
! return -1;
! }
! else if (check_0 < 0 || check_1 < 0)
! error ("Communication error in checksum");
+ pktcsum = (fromhex (check_0) << 4) | fromhex (check_1);
if (csum == pktcsum)
return bc;