Thread View: gnu.gdb.bug
1 messages
1 total messages
Started by Richard Stallman
Sat, 11 Feb 1989 04:43
[brad%cayman@harvard.harvard.edu: gdb 3.x / some diffs to remote.c ]
Author: Richard Stallman
Date: Sat, 11 Feb 1989 04:43
Date: Sat, 11 Feb 1989 04:43
244 lines
5803 bytes
5803 bytes
Return-Path: <somewhere!brad@cayman.cayman.com>
Date: Fri, 10 Feb 89 08:25:42 EST
From: brad%cayman@harvard.harvard.edu (Brad Parker)
To: bug-gcc@prep.ai.mit.edu
Subject: gdb 3.x / some diffs to remote.c
I started using the gdb 3.0 "remote" option with a 9600 baud serial line
to a target (the GatorBox). I found some simple bugs - this is so obscure that
no one may use this, but I do! These patches fix a retry checksum bug and
cause the packet code to retry which makes it more robust.
I added the simple fixes from the gdb 3.1 patches.
I also have the "nub" which runs in the remote system. If any one would like
a copy, let me know.
-brad
Brad Parker
Cayman Systems, Inc.
brad@cayman.com
---- cut here ----
*** remote.c.orig Fri Feb 10 08:03:54 1989
--- remote.c Fri Feb 10 08:21:11 1989
***************
*** 94,100 ****
#define TERMINAL struct sgttyb
#endif
! int kiodebug;
int icache;
--- 94,101 ----
#define TERMINAL struct sgttyb
#endif
! static int kiodebug = 0;
! static int timeout = 5;
int icache;
***************
*** 101,107 ****
/* Descriptor for I/O to remote machine. */
int remote_desc;
! #define PBUFSIZ 300
static void remote_send ();
static void putpkt ();
--- 102,108 ----
/* Descriptor for I/O to remote machine. */
int remote_desc;
! #define PBUFSIZ 400
static void remote_send ();
static void putpkt ();
***************
*** 109,114 ****
--- 110,126 ----
static void dcache_flush ();
+ /* called when SIGALRM signal sent due to alarm() timeout */
+
+ void
+ remote_timer()
+ {
+ if (kiodebug)
+ printf("[remote_timer]\n");
+
+ alarm(timeout);
+ }
+
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
***************
*** 137,142 ****
--- 149,162 ----
if (from_tty)
printf ("Remote debugging using %s\n", name);
remote_debugging = 1;
+
+ /* cause SIGALRM's to make reads fail */
+ if (siginterrupt(SIGALRM, 1) != 0)
+ perror("[remote_open] siginterrupt");
+
+ /* set up read timeout timer */
+ if (signal(SIGALRM, remote_timer) == (void (*))-1)
+ perror("[remote_open] signal");
}
/* Convert hex digit A to a number. */
***************
*** 246,251 ****
--- 266,272 ----
*p++ = tohex (regs[i] & 0xf);
}
+ *p = '\0';
remote_send (buf);
}
***************
*** 312,317 ****
--- 333,339 ----
*p++ = tohex (myaddr[i] & 0xf);
}
+ *p = '\0';
remote_send (buf);
}
***************
*** 371,376 ****
--- 393,416 ----
*/
+ static int
+ readchar ()
+ {
+ char buf[1];
+
+ buf[0] = '\0';
+ alarm(timeout);
+ read (remote_desc, buf, 1);
+ alarm(0);
+
+ /*
+ if (kiodebug > 1)
+ printf("[readchar] got '%c' (0x%x)\n", buf[0] & 0x7f, buf[0] & 0x7f);
+ */
+
+ return buf[0] & 0x7f;
+ }
+
/* Send the command in BUF to the remote machine,
and read the reply into BUF.
Report an error if we get an error reply. */
***************
*** 401,409 ****
int cnt = strlen (buf);
char *p;
- if (kiodebug)
- fprintf (stderr, "Sending packet: %s\n", buf);
-
/* Copy the packet into buffer BUF2, encapsulating it
and giving it a checksum. */
--- 441,446 ----
***************
*** 422,440 ****
/* Send it over and over until we get a positive ack. */
do {
write (remote_desc, buf2, p - buf2);
! read (remote_desc, buf3, 1);
! } while (buf3[0] != '+');
}
- static int
- readchar ()
- {
- char buf[1];
- while (read (remote_desc, buf, 1) != 1) ;
- return buf[0] & 0x7f;
- }
-
/* Read a packet from the remote machine, with error checking,
and store it in BUF. */
--- 459,472 ----
/* Send it over and over until we get a positive ack. */
do {
+ if (kiodebug) {
+ *p = '\0';
+ fprintf (stderr, "Sending packet: %s (%s)\n", buf2, buf);
+ }
write (remote_desc, buf2, p - buf2);
! } while (readchar() != '+');
}
/* Read a packet from the remote machine, with error checking,
and store it in BUF. */
***************
*** 444,450 ****
{
char *bp;
char csum = 0;
! int c, c1, c2;
extern kiodebug;
while (1)
--- 476,483 ----
{
char *bp;
char csum = 0;
! int c;
! unsigned char c1, c2;
extern kiodebug;
while (1)
***************
*** 452,457 ****
--- 485,491 ----
while ((c = readchar()) != '$');
bp = buf;
+ csum = 0;
while (1)
{
c = readchar ();
***************
*** 464,473 ****
c1 = fromhex (readchar ());
c2 = fromhex (readchar ());
! if (csum == (c1 << 4) + c2)
break;
printf ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
! (c1 << 4) + c2, csum, buf);
write (remote_desc, "-", 1);
}
--- 498,508 ----
c1 = fromhex (readchar ());
c2 = fromhex (readchar ());
! if ((csum & 0xff) == (c1 << 4) + c2)
break;
printf ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
! (c1 << 4) + c2, csum & 0xff, buf);
!
write (remote_desc, "-", 1);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads