From 688991e6f813a3fcc831a9a1e7f9d5c62808a62b Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Tue, 12 Sep 2000 17:20:09 +0000 Subject: [PATCH] Replace hardwired timeouts in remote-mips.c with ``remote_timeout'' variable. --- gdb/ChangeLog | 12 +++++++++ gdb/remote-mips.c | 63 ++++++++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c4563bfea51..9c91bbe69e0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +Wed Sep 13 03:08:32 2000 Andrew Cagney + + * 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. + 2000-09-12 Alexandre Oliva * MAINTAINERS: Added myself. diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index e2faeacc521..82eccd57df3 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -598,7 +598,7 @@ mips_expect_timeout (const char *string, int timeout) int mips_expect (const char *string) { - return mips_expect_timeout (string, 2); + return mips_expect_timeout (string, remote_timeout); } /* Read the required number of characters into the given buffer (which @@ -612,7 +612,7 @@ mips_getstring (char *string, int n) immediate_quit++; while (n > 0) { - c = SERIAL_READCHAR (mips_desc, 2); + c = SERIAL_READCHAR (mips_desc, remote_timeout); if (c == SERIAL_TIMEOUT) { @@ -928,7 +928,7 @@ mips_send_packet (const char *s, int get_ack) { int rch; - rch = mips_readchar (2); + rch = mips_readchar (remote_timeout); if (rch == SYN) { ch = SYN; @@ -940,7 +940,8 @@ mips_send_packet (const char *s, int get_ack) } if (i == len) - (void) mips_receive_trailer (trlr, &garbage, &ch, 2); + (void) mips_receive_trailer (trlr, &garbage, &ch, + remote_timeout); /* We don't bother checking the checksum, or providing an ACK to the packet. */ @@ -2308,7 +2309,7 @@ pmon_insert_breakpoint (CORE_ADDR addr, char *contents_cache) mips_expect ("Bpt "); - if (!mips_getstring (tbuff, 2)) + if (!mips_getstring (tbuff, remote_timeout)) return 1; tbuff[2] = '\0'; /* terminate the string */ if (sscanf (tbuff, "%d", &bpnum) != 1) @@ -2776,7 +2777,7 @@ send_srec (char *srec, int len, CORE_ADDR addr) SERIAL_WRITE (mips_desc, srec, len); - ch = mips_readchar (2); + ch = mips_readchar (remote_timeout); switch (ch) { @@ -3133,7 +3134,8 @@ pmon_check_ack (char *mesg) if (!tftp_in_use) { - c = SERIAL_READCHAR (udp_in_use ? udp_desc : mips_desc, 2); + c = SERIAL_READCHAR (udp_in_use ? udp_desc : mips_desc, + remote_timeout); if ((c == SERIAL_TIMEOUT) || (c != 0x06)) { fprintf_unfiltered (gdb_stderr, @@ -3180,6 +3182,26 @@ mips_expect_download (char *string) return 1; } +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) { @@ -3220,24 +3242,21 @@ pmon_end_download (int final, int bintotal) /* 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) + 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"); - mips_expect_timeout ("Entry address is ", tftp_in_use ? 15 : 2); + if (!pmon_check_total (bintotal)) + return; + break; } - 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 */ -- 2.30.2