* 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 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
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 */
/* 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.
#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. */
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);
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)
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)
{
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;
("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);
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 */
/* 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 */
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) ();
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;
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)
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);
}
/* 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.
#include "gdb_stat.h"
#include <ctype.h>
#include <time.h>
+#include <sys/time.h>
#ifndef O_BINARY
#define O_BINARY 0
{
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;
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 ");
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);
}
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