This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: handle NAK packets sent by remote stub.

This patch wasn't lost, but rather deferred for further thought just
before the 4.18 branch/release.

The putpkt_binary() function doesn't specifically handle the NAK ('-')
character after a packet has been transmitted.  It's treated as a junk
character and ignored.  As a result, in the case of packet corruption,
GDB waits remote_timeout seconds to re-try the packet even though the
target has told GDB that the packet needs to be retransmitted.  The 
enclosed patch handles Nak, so the packet is retransmitted immediately.

The one concern that I remember was the risk of spurious NAKs from the
target interfering with the proper operation remote protocol.  This is
a possibility, but in my opinion it's no more so than spurious ACKs.
Without ACKs and NAKs being framed/checksummed, the remote protocol is
simply vulnerable to communication errors.

We've had this change in our local GDBs for about a year.  It has
caused no problems that I'm aware of.

I submitted this patch before I started archiving my outbound mail.
So this time, the ChangeLog is new.


2000-02-05  J.T. Conklin  <>

	* remote.c (putpkt_binary): Handle NAK from target stub.

Index: remote.c
RCS file: /home/jtc/CVSROOT/gdb/gdb/remote.c,v
retrieving revision
retrieving revision 1.19
diff -c -r1.1.1.28 -r1.19
*** remote.c	2000/02/04 21:24:02
--- remote.c	2000/02/04 23:52:40	1.19
*** 3730,3735 ****
--- 3721,3727 ----
  	      switch (ch)
  		case '+':
+ 		case '-':
  		case '$':
  		  if (started_error_output)
*** 3746,3751 ****
--- 3738,3746 ----
  	      if (remote_debug)
  		fprintf_unfiltered (gdb_stdlog, "Ack\n");
  	      return 1;
+ 	    case '-':
+ 	      if (remote_debug)
+ 		fprintf_unfiltered (gdb_stdlog, "Nak\n");
  	    case SERIAL_TIMEOUT:
  	      if (tcount > 3)

J.T. Conklin
RedBack Networks

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]