patch to remove gratuitous ACK in stubs

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


This is a re-send of a patch I sent back in March.  It wasn't
rejected, but it wasn't integrated either.

This change removes the gratuitous ACK sent in set_debug_traps() in
most of the sample stubs.  The comment said that the ACK is sent 'In
case GDB is started before us', but that is exactly the case that
causes problems.

If 'target remote /dev/blah' is invoked before the debug stub is
initialized, the packet is naturally lost.  But if set_debug_traps()
then ACKs the unreceived packet, GDB will continue.  In the case of
code sequences like:

        putpkt (buf);
        getpkt (buf, 0);

(Which happens to be present in set_thread, the first sets of packets
GDB currently exchanges with the debug agent) getpkt() waits for 3 *
remotetimeout seconds before timing out waiting for a packet that will
never be sent.  Had the stub not sent the ACK, putpkt() would have
timed out, giving the target system time to initialize before the next
retry.

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

	* i386-stub.c, m32r-stub.c, sparc-stub.c, sparcl-stub.c,
 	sparclet-stub.c (set_debug_traps): Don't send gratuitous ACK.

Index: i386-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/i386-stub.c,v
retrieving revision 1.2
diff -c -r1.2 i386-stub.c
*** i386-stub.c	1999/08/18 05:09:23	1.2
--- i386-stub.c	1999/08/18 05:41:30
***************
*** 905,916 ****
        exceptionHook    = remcomHandler;
    }
  
-   /* In case GDB is started before us, ack any packets (presumably
-      "$?#xx") sitting there.  */
-   putDebugChar ('+');
- 
    initialized = 1;
- 
  }
  
  /* This function will generate a breakpoint exception.  It is used at the
--- 905,911 ----
Index: m32r-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/m32r-stub.c,v
retrieving revision 1.2
diff -c -r1.2 m32r-stub.c
*** m32r-stub.c	1999/08/18 05:09:24	1.2
--- m32r-stub.c	1999/08/18 05:41:35
***************
*** 1579,1588 ****
    exceptionHandler (16, _catchException16);
    /*  exceptionHandler (17, _catchException17); */
  
-   /* In case GDB is started before us, ack any packets (presumably
-      "$?#xx") sitting there.  */
-   putDebugChar ('+');
- 
    initialized = 1;
  }
  
--- 1579,1584 ----
Index: sparc-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/sparc-stub.c,v
retrieving revision 1.2
diff -c -r1.2 sparc-stub.c
*** sparc-stub.c	1999/08/18 05:09:26	1.2
--- sparc-stub.c	1999/08/18 05:41:43
***************
*** 480,490 ****
    for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
      exceptionHandler(ht->tt, trap_low);
  
-   /* In case GDB is started before us, ack any packets (presumably
-      "$?#xx") sitting there.  */
- 
-   putDebugChar ('+');
- 
    initialized = 1;
  }
  
--- 480,485 ----
Index: sparcl-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/sparcl-stub.c,v
retrieving revision 1.2
diff -c -r1.2 sparcl-stub.c
*** sparcl-stub.c	1999/08/18 05:09:27	1.2
--- sparcl-stub.c	1999/08/18 05:41:57
***************
*** 587,597 ****
      if (ht->tt != 4 || ! (read_psr () & 0x1000))
        exceptionHandler(ht->tt, trap_low);
  
-   /* In case GDB is started before us, ack any packets (presumably
-      "$?#xx") sitting there.  */
- 
-   putDebugChar ('+');
- 
    initialized = 1;
  }
  
--- 587,592 ----
Index: sparclet-stub.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/sparclet-stub.c,v
retrieving revision 1.2
diff -c -r1.2 sparclet-stub.c
*** sparclet-stub.c	1999/08/18 05:09:27	1.2
--- sparclet-stub.c	1999/08/18 05:42:30
***************
*** 647,656 ****
    for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
      exceptionHandler(ht->tt, trap_low);
  
-   /* In case GDB is started before us, ack any packets (presumably
-      "$?#xx") sitting there.  */
-   putDebugChar ('+');
- 
    initialized = 1;
  }
  
--- 647,652 ----



-- 
J.T. Conklin
RedBack Networks


More information about the Gdb-patches mailing list