Change stubs to handle '$' after packet start

J.T. Conklin jtc@redback.com
Tue Aug 17 23:27:00 GMT 1999


Now for some new changes...

This change adds code in getpacket() to start a new packet if the
packet start character ('$') is received while reading the packet
contents.  This prevents the loss of the subsequent packet if the
packet end character '#' is lost/garbled.

        --jtc

1999-08-17  J.T. Conklin  <jtc@redback.com>

	* i386-stub.c, m32r-stub.c, m68k-stub.c, sh-stub.c, sh-stub.c,
 	sparc-stub, sparcl-stub.c sparclet-stub.c (getpacket): If '$',
	the packet start character is received in the 'middle' of a 
	packet, assume that packet end character has been lost and
	start a new packet

Index: i386-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/i386-stub.c,v
retrieving revision 1.4
diff -c -r1.4 i386-stub.c
*** i386-stub.c	1999/08/18 06:09:23	1.4
--- i386-stub.c	1999/08/18 06:10:25
***************
*** 473,478 ****
--- 473,479 ----
        while ((ch = getDebugChar ()) != '$')
  	;
  
+ retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;
***************
*** 481,486 ****
--- 482,489 ----
        while (count < BUFMAX)
  	{
  	  ch = getDebugChar ();
+           if (ch == '$')
+ 	    goto retry;
  	  if (ch == '#')
  	    break;
  	  checksum = checksum + ch;
Index: m32r-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/m32r-stub.c,v
retrieving revision 1.3
diff -c -r1.3 m32r-stub.c
*** m32r-stub.c	1999/08/18 06:02:35	1.3
--- m32r-stub.c	1999/08/18 06:11:19
***************
*** 589,594 ****
--- 589,595 ----
        while ((ch = getDebugChar ()) != '$')
  	;
  
+ retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;
***************
*** 597,602 ****
--- 598,605 ----
        while (count < BUFMAX)
  	{
  	  ch = getDebugChar ();
+           if (ch == '$')
+ 	    goto retry;
  	  if (ch == '#')
  	    break;
  	  checksum = checksum + ch;
Index: m68k-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/m68k-stub.c,v
retrieving revision 1.3
diff -c -r1.3 m68k-stub.c
*** m68k-stub.c	1999/08/18 05:32:30	1.3
--- m68k-stub.c	1999/08/18 06:11:56
***************
*** 539,544 ****
--- 539,545 ----
        while ((ch = getDebugChar ()) != '$')
  	;
  
+ retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;
***************
*** 547,552 ****
--- 548,555 ----
        while (count < BUFMAX)
  	{
  	  ch = getDebugChar ();
+ 	  if (ch == '$')
+             goto retry;
  	  if (ch == '#')
  	    break;
  	  checksum = checksum + ch;
Index: sh-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/sh-stub.c,v
retrieving revision 1.3
diff -c -r1.3 sh-stub.c
*** sh-stub.c	1999/08/18 05:32:31	1.3
--- sh-stub.c	1999/08/18 06:14:45
***************
*** 388,394 ****
  {
    unsigned char checksum;
    unsigned char xmitcsum;
-   int i;
    int count;
    char ch;
  
--- 388,393 ----
***************
*** 398,403 ****
--- 397,403 ----
        while ((ch = getDebugChar ()) != '$')
  	;
  
+ retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;
***************
*** 406,411 ****
--- 406,413 ----
        while (count < BUFMAX)
  	{
  	  ch = getDebugChar ();
+           if (ch == '$')
+             goto retry;
  	  if (ch == '#')
  	    break;
  	  checksum = checksum + ch;
Index: sparc-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/sparc-stub.c,v
retrieving revision 1.3
diff -c -r1.3 sparc-stub.c
*** sparc-stub.c	1999/08/18 06:02:35	1.3
--- sparc-stub.c	1999/08/18 06:13:23
***************
*** 301,306 ****
--- 301,307 ----
        while ((ch = getDebugChar ()) != '$')
  	;
  
+ retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;
***************
*** 309,314 ****
--- 310,317 ----
        while (count < BUFMAX)
  	{
  	  ch = getDebugChar ();
+           if (ch == '$')
+             goto retry;
  	  if (ch == '#')
  	    break;
  	  checksum = checksum + ch;
Index: sparcl-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/sparcl-stub.c,v
retrieving revision 1.3
diff -c -r1.3 sparcl-stub.c
*** sparcl-stub.c	1999/08/18 06:02:36	1.3
--- sparcl-stub.c	1999/08/18 06:14:05
***************
*** 397,402 ****
--- 397,403 ----
        while ((ch = getDebugChar ()) != '$')
  	;
  
+ retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;
***************
*** 405,410 ****
--- 406,413 ----
        while (count < BUFMAX)
  	{
  	  ch = getDebugChar ();
+           if (ch == '$')
+             goto retry;
  	  if (ch == '#')
  	    break;
  	  checksum = checksum + ch;
Index: sparclet-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/sparclet-stub.c,v
retrieving revision 1.3
diff -c -r1.3 sparclet-stub.c
*** sparclet-stub.c	1999/08/18 06:02:36	1.3
--- sparclet-stub.c	1999/08/18 06:14:25
***************
*** 467,472 ****
--- 467,473 ----
        while ((ch = getDebugChar ()) != '$')
  	;
  
+ retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;
***************
*** 475,480 ****
--- 476,483 ----
        while (count < BUFMAX)
  	{
  	  ch = getDebugChar ();
+ 	  if (ch == '$')
+ 	    goto retry;
  	  if (ch == '#')
  	    break;
  	  checksum = checksum + ch;

-- 
J.T. Conklin
RedBack Networks


More information about the Gdb-patches mailing list