This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] remote-mips.c - eliminate hard-wired two seconds
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [patch] remote-mips.c - eliminate hard-wired two seconds
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Wed, 13 Sep 2000 04:15:33 +1100
FYI,
The attched patch changes remote-mips.c so that it recognizes the
``(gdb) set remote timeout ...'' command. It replaces lots of hardwired
``2''s.
One slightly annoying side effect is that the default timeout is now
significantly biger (~20 vs ~2). For me its perfect, some people may
find it annoying.
enjoy,
Andrew
Wed Sep 13 03:08:32 2000 Andrew Cagney <cagney@b1.cygnus.com>
* remote-mips.c (mips_expect, mips_getstring, mips_send_packet,
mips_send_packet, pmon_insert_breakpoint, send_srec,
pmon_check_ack, pmon_check_entry_address,
_initialize_remote_mips): Replace the magic two seconds with
``remote_timeout''.
(pmon_check_entry_address, pmon_check_total): New functions. Use
``remote_timeout'' instead of magic two seconds.
(pmon_end_download): Rewrite. Use pmon_check_entry_address and
pmon_check_total.
Index: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.9
diff -p -r1.9 remote-mips.c
*** remote-mips.c 2000/09/01 00:12:10 1.9
--- remote-mips.c 2000/09/12 16:26:58
*************** mips_expect_timeout (const char *string,
*** 598,604 ****
int
mips_expect (const char *string)
{
! return mips_expect_timeout (string, 2);
}
/* Read the required number of characters into the given buffer (which
--- 598,604 ----
int
mips_expect (const char *string)
{
! return mips_expect_timeout (string, remote_timeout);
}
/* Read the required number of characters into the given buffer (which
*************** mips_getstring (char *string, int n)
*** 612,618 ****
immediate_quit++;
while (n > 0)
{
! c = SERIAL_READCHAR (mips_desc, 2);
if (c == SERIAL_TIMEOUT)
{
--- 612,618 ----
immediate_quit++;
while (n > 0)
{
! c = SERIAL_READCHAR (mips_desc, remote_timeout);
if (c == SERIAL_TIMEOUT)
{
*************** mips_send_packet (const char *s, int get
*** 928,934 ****
{
int rch;
! rch = mips_readchar (2);
if (rch == SYN)
{
ch = SYN;
--- 928,934 ----
{
int rch;
! rch = mips_readchar (remote_timeout);
if (rch == SYN)
{
ch = SYN;
*************** mips_send_packet (const char *s, int get
*** 940,946 ****
}
if (i == len)
! (void) mips_receive_trailer (trlr, &garbage, &ch, 2);
/* We don't bother checking the checksum, or providing an
ACK to the packet. */
--- 940,947 ----
}
if (i == len)
! (void) mips_receive_trailer (trlr, &garbage, &ch,
! remote_timeout);
/* We don't bother checking the checksum, or providing an
ACK to the packet. */
*************** pmon_insert_breakpoint (CORE_ADDR addr,
*** 2308,2314 ****
mips_expect ("Bpt ");
! if (!mips_getstring (tbuff, 2))
return 1;
tbuff[2] = '\0'; /* terminate the string */
if (sscanf (tbuff, "%d", &bpnum) != 1)
--- 2309,2315 ----
mips_expect ("Bpt ");
! if (!mips_getstring (tbuff, remote_timeout))
return 1;
tbuff[2] = '\0'; /* terminate the string */
if (sscanf (tbuff, "%d", &bpnum) != 1)
*************** send_srec (char *srec, int len, CORE_ADD
*** 2776,2782 ****
SERIAL_WRITE (mips_desc, srec, len);
! ch = mips_readchar (2);
switch (ch)
{
--- 2777,2783 ----
SERIAL_WRITE (mips_desc, srec, len);
! ch = mips_readchar (remote_timeout);
switch (ch)
{
*************** pmon_check_ack (char *mesg)
*** 3133,3139 ****
if (!tftp_in_use)
{
! c = SERIAL_READCHAR (udp_in_use ? udp_desc : mips_desc, 2);
if ((c == SERIAL_TIMEOUT) || (c != 0x06))
{
fprintf_unfiltered (gdb_stderr,
--- 3134,3141 ----
if (!tftp_in_use)
{
! c = SERIAL_READCHAR (udp_in_use ? udp_desc : mips_desc,
! remote_timeout);
if ((c == SERIAL_TIMEOUT) || (c != 0x06))
{
fprintf_unfiltered (gdb_stderr,
*************** mips_expect_download (char *string)
*** 3181,3186 ****
--- 3183,3208 ----
}
static void
+ pmon_check_entry_address (char *entry_address, int final)
+ {
+ char hexnumber[9]; /* includes '\0' space */
+ mips_expect_timeout (entry_address, tftp_in_use ? 15 : remote_timeout);
+ sprintf (hexnumber, "%x", final);
+ mips_expect (hexnumber);
+ mips_expect ("\r\n");
+ }
+
+ static int
+ pmon_check_total (int bintotal)
+ {
+ char hexnumber[9]; /* includes '\0' space */
+ mips_expect ("\r\ntotal = 0x");
+ sprintf (hexnumber, "%x", bintotal);
+ mips_expect (hexnumber);
+ return mips_expect_download (" bytes\r\n");
+ }
+
+ static void
pmon_end_download (int final, int bintotal)
{
char hexnumber[9]; /* includes '\0' space */
*************** pmon_end_download (int final, int bintot
*** 3220,3243 ****
/* Wait for the stuff that PMON prints after the load has completed.
The timeout value for use in the tftp case (15 seconds) was picked
arbitrarily but might be too small for really large downloads. FIXME. */
! if (mips_monitor == MON_LSI)
{
pmon_check_ack ("termination");
! mips_expect_timeout ("Entry address is ", tftp_in_use ? 15 : 2);
}
- else
- mips_expect_timeout ("Entry Address = ", tftp_in_use ? 15 : 2);
-
- sprintf (hexnumber, "%x", final);
- mips_expect (hexnumber);
- mips_expect ("\r\n");
- if (mips_monitor != MON_LSI)
- pmon_check_ack ("termination");
- mips_expect ("\r\ntotal = 0x");
- sprintf (hexnumber, "%x", bintotal);
- mips_expect (hexnumber);
- if (!mips_expect_download (" bytes\r\n"))
- return;
if (tftp_in_use)
remove (tftp_localname); /* Remove temporary file */
--- 3242,3262 ----
/* Wait for the stuff that PMON prints after the load has completed.
The timeout value for use in the tftp case (15 seconds) was picked
arbitrarily but might be too small for really large downloads. FIXME. */
! switch (mips_monitor)
{
+ case MON_LSI:
+ pmon_check_ack ("termination");
+ pmon_check_entry_address ("Entry address is ", final);
+ if (!pmon_check_total (bintotal))
+ return;
+ break;
+ default:
+ pmon_check_entry_address ("Entry Address = ", final);
pmon_check_ack ("termination");
! if (!pmon_check_total (bintotal))
! return;
! break;
}
if (tftp_in_use)
remove (tftp_localname); /* Remove temporary file */