diff options
author | Daniel Jacobowitz <dan@debian.org> | 2005-08-02 03:02:05 +0000 |
---|---|---|
committer | Daniel Jacobowitz <dan@debian.org> | 2005-08-02 03:02:05 +0000 |
commit | 8f31aaf668842126962a3e4850795aa203af0429 (patch) | |
tree | a47e4a6e118370a938d110e81230c5156734a63f | |
parent | 1218a857d6e76779c931684caf58ccac675b761f (diff) | |
download | gdb-8f31aaf668842126962a3e4850795aa203af0429.tar.gz |
Suggested by Shaun Jackman <sjackman@gmail.com>:
* defs.h (print_transfer_performance): Update prototype.
* m32r-rom.c (m32r_load, m32r_upload_command): Use gettimeofday
for print_transfer_performance.
* remote-m32r-sdi.c (m32r_load): Likewise.
* symfile.c (generic_load): Likewise.
(report_transfer_performance): Create a dummy struct timeval.
(print_transfer_performance): Use a more accurate measure
of performance.
-rw-r--r-- | gdb/ChangeLog | 12 | ||||
-rw-r--r-- | gdb/defs.h | 4 | ||||
-rw-r--r-- | gdb/m32r-rom.c | 25 | ||||
-rw-r--r-- | gdb/remote-m32r-sdi.c | 10 | ||||
-rw-r--r-- | gdb/symfile.c | 33 |
5 files changed, 57 insertions, 27 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4e124dea0ab..084f01b208b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2005-08-01 Daniel Jacobowitz <dan@codesourcery.com> + + Suggested by Shaun Jackman <sjackman@gmail.com>: + * defs.h (print_transfer_performance): Update prototype. + * m32r-rom.c (m32r_load, m32r_upload_command): Use gettimeofday + for print_transfer_performance. + * remote-m32r-sdi.c (m32r_load): Likewise. + * symfile.c (generic_load): Likewise. + (report_transfer_performance): Create a dummy struct timeval. + (print_transfer_performance): Use a more accurate measure + of performance. + 2005-08-01 Fred Fish <fnf@specifix.com> * stack.c (parse_frame_specification_1): Remove use of obsolete diff --git a/gdb/defs.h b/gdb/defs.h index 7548455664f..1880bc0708d 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -552,10 +552,12 @@ extern void symbol_file_command (char *, int); extern void generic_load (char *name, int from_tty); /* Summarise a download */ +struct timeval; extern void print_transfer_performance (struct ui_file *stream, unsigned long data_count, unsigned long write_count, - unsigned long time_count); + const struct timeval *start_time, + const struct timeval *end_time); /* From top.c */ diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c index f9cc5e0a7f9..a6c70e86fe4 100644 --- a/gdb/m32r-rom.c +++ b/gdb/m32r-rom.c @@ -1,8 +1,8 @@ /* Remote debugging interface to m32r and mon2000 ROM monitors for GDB, the GNU debugger. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2004 Free Software - Foundation, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2004, 2005 + Free Software Foundation, Inc. Adapted by Michael Snyder of Cygnus Support. @@ -35,6 +35,7 @@ #include "command.h" #include "gdbcmd.h" #include "symfile.h" /* for generic load */ +#include <sys/time.h> #include <time.h> /* for time_t */ #include "gdb_string.h" #include "objfiles.h" /* for ALL_OBJFILES etc. */ @@ -119,7 +120,7 @@ m32r_load (char *filename, int from_tty) bfd *abfd; asection *s; unsigned int i, data_count = 0; - time_t start_time, end_time; /* for timing of download */ + struct timeval start_time, end_time; if (filename == NULL || filename[0] == 0) filename = get_exec_file (1); @@ -129,7 +130,7 @@ m32r_load (char *filename, int from_tty) error (_("Unable to open file %s."), filename); if (bfd_check_format (abfd, bfd_object) == 0) error (_("File is not an object file.")); - start_time = time (NULL); + gettimeofday (&start_time, NULL); #if 0 for (s = abfd->sections; s; s = s->next) if (s->flags & SEC_LOAD) @@ -163,10 +164,10 @@ m32r_load (char *filename, int from_tty) return; } #endif - end_time = time (NULL); + gettimeofday (&end_time, NULL); printf_filtered ("Start address 0x%lx\n", bfd_get_start_address (abfd)); - print_transfer_performance (gdb_stdout, data_count, 0, - end_time - start_time); + print_transfer_performance (gdb_stdout, data_count, 0, &start_time, + &end_time); /* Finally, make the PC point at the start address */ if (exec_bfd) @@ -405,7 +406,7 @@ m32r_upload_command (char *args, int from_tty) { bfd *abfd; asection *s; - time_t start_time, end_time; /* for timing of download */ + struct timeval start_time, end_time; int resp_len, data_count = 0; char buf[1024]; struct hostent *hostent; @@ -467,7 +468,7 @@ m32r_upload_command (char *args, int from_tty) ("Need to know default download path (use 'set download-path')"); } - start_time = time (NULL); + gettimeofday (&start_time, NULL); monitor_printf ("uhip %s\r", server_addr); resp_len = monitor_expect_prompt (buf, sizeof (buf)); /* parse result? */ monitor_printf ("ulip %s\r", board_addr); @@ -491,7 +492,7 @@ m32r_upload_command (char *args, int from_tty) else printf_filtered (" -- Ethernet load complete.\n"); - end_time = time (NULL); + gettimeofday (&end_time, NULL); abfd = bfd_openr (args, 0); if (abfd != NULL) { /* Download is done -- print section statistics */ @@ -517,8 +518,8 @@ m32r_upload_command (char *args, int from_tty) /* Finally, make the PC point at the start address */ write_pc (bfd_get_start_address (abfd)); printf_filtered ("Start address 0x%lx\n", bfd_get_start_address (abfd)); - print_transfer_performance (gdb_stdout, data_count, 0, - end_time - start_time); + print_transfer_performance (gdb_stdout, data_count, 0, &start_time, + &end_time); } inferior_ptid = null_ptid; /* No process now */ diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index 4fa797dd168..9471c115381 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -1213,7 +1213,7 @@ m32r_load (char *args, int from_tty) char *filename; int quiet; int nostart; - time_t start_time, end_time; /* Start and end times of download */ + struct timeval start_time, end_time; unsigned long data_count; /* Number of bytes transferred to memory */ int ret; static RETSIGTYPE (*prev_sigint) (); @@ -1263,7 +1263,7 @@ m32r_load (char *args, int from_tty) error (_("\"%s\" is not an object file: %s"), filename, bfd_errmsg (bfd_get_error ())); - start_time = time (NULL); + gettimeofday (&start_time, NULL); data_count = 0; interrupted = 0; @@ -1349,7 +1349,7 @@ m32r_load (char *args, int from_tty) interrupted = 0; signal (SIGINT, prev_sigint); - end_time = time (NULL); + gettimeofday (&end_time, NULL); /* Make the PC point at the start address */ if (exec_bfd) @@ -1373,8 +1373,8 @@ m32r_load (char *args, int from_tty) printf_unfiltered ("[Starting %s at 0x%lx]\n", filename, entry); } - print_transfer_performance (gdb_stdout, data_count, 0, - end_time - start_time); + print_transfer_performance (gdb_stdout, data_count, 0, &start_time, + &end_time); do_cleanups (old_chain); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 43eb28fef3e..971c530beb4 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1,7 +1,7 @@ /* Generic symbol file reading for the GNU debugger, GDB. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Contributed by Cygnus Support, using pieces from other GDB modules. @@ -57,6 +57,7 @@ #include "gdb_stat.h" #include <ctype.h> #include <time.h> +#include <sys/time.h> #ifndef O_BINARY #define O_BINARY 0 @@ -1600,7 +1601,7 @@ generic_load (char *args, int from_tty) { asection *s; bfd *loadfile_bfd; - time_t start_time, end_time; /* Start and end times of download */ + struct timeval start_time, end_time; char *filename; struct cleanup *old_cleanups; char *offptr; @@ -1652,11 +1653,11 @@ generic_load (char *args, int from_tty) bfd_map_over_sections (loadfile_bfd, add_section_size_callback, (void *) &cbdata.total_size); - start_time = time (NULL); + gettimeofday (&start_time, NULL); bfd_map_over_sections (loadfile_bfd, load_section_callback, &cbdata); - end_time = time (NULL); + gettimeofday (&end_time, NULL); entry = bfd_get_start_address (loadfile_bfd); ui_out_text (uiout, "Start address "); @@ -1675,7 +1676,7 @@ generic_load (char *args, int from_tty) others don't (or didn't - perhaps they have all been deleted). */ print_transfer_performance (gdb_stdout, cbdata.data_count, - cbdata.write_count, end_time - start_time); + cbdata.write_count, &start_time, &end_time); do_cleanups (old_cleanups); } @@ -1690,21 +1691,35 @@ void report_transfer_performance (unsigned long data_count, time_t start_time, time_t end_time) { - print_transfer_performance (gdb_stdout, data_count, - end_time - start_time, 0); + struct timeval start, end; + + start.tv_sec = start_time; + start.tv_usec = 0; + end.tv_sec = end_time; + end.tv_usec = 0; + + print_transfer_performance (gdb_stdout, data_count, 0, &start, &end); } void print_transfer_performance (struct ui_file *stream, unsigned long data_count, unsigned long write_count, - unsigned long time_count) + const struct timeval *start_time, + const struct timeval *end_time) { + unsigned long time_count; + + /* Compute the elapsed time in milliseconds, as a tradeoff between + accuracy and overflow. */ + time_count = (end_time->tv_sec - start_time->tv_sec) * 1000; + time_count += (end_time->tv_usec - start_time->tv_usec) / 1000; + ui_out_text (uiout, "Transfer rate: "); if (time_count > 0) { ui_out_field_fmt (uiout, "transfer-rate", "%lu", - (data_count * 8) / time_count); + 1000 * (data_count * 8) / time_count); ui_out_text (uiout, " bits/sec"); } else |