aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-07-03 15:32:20 +0000
committerDaniel Jacobowitz <drow@false.org>2007-07-03 15:32:20 +0000
commit9f43d28cb0b3e1e8fa7c4017c81b9ef81843ab4d (patch)
treedc72db2ac681c6d830630e589c6c2c1386bb045a /gdb/symfile.c
parent3cfad14c4a2b29ed8939e8e749b2a1c2f2b15f9e (diff)
downloadgdb-9f43d28cb0b3e1e8fa7c4017c81b9ef81843ab4d.zip
gdb-9f43d28cb0b3e1e8fa7c4017c81b9ef81843ab4d.tar.gz
gdb-9f43d28cb0b3e1e8fa7c4017c81b9ef81843ab4d.tar.bz2
2007-07-03 Ilko Iliev <iliev@ronetix.at>
Daniel Jacobowitz <dan@codesourcery.com> * symfile.c (print_transfer_performance): Avoid integer overflow. Use larger units.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index f513dfa..8e4e03d 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1947,7 +1947,7 @@ print_transfer_performance (struct ui_file *stream,
const struct timeval *start_time,
const struct timeval *end_time)
{
- unsigned long time_count;
+ ULONGEST time_count;
/* Compute the elapsed time in milliseconds, as a tradeoff between
accuracy and overflow. */
@@ -1957,9 +1957,23 @@ print_transfer_performance (struct ui_file *stream,
ui_out_text (uiout, "Transfer rate: ");
if (time_count > 0)
{
- ui_out_field_fmt (uiout, "transfer-rate", "%lu",
- 1000 * (data_count * 8) / time_count);
- ui_out_text (uiout, " bits/sec");
+ unsigned long rate = ((ULONGEST) data_count * 1000) / time_count;
+
+ if (ui_out_is_mi_like_p (uiout))
+ {
+ ui_out_field_fmt (uiout, "transfer-rate", "%lu", rate * 8);
+ ui_out_text (uiout, " bits/sec");
+ }
+ else if (rate < 1024)
+ {
+ ui_out_field_fmt (uiout, "transfer-rate", "%lu", rate);
+ ui_out_text (uiout, " bytes/sec");
+ }
+ else
+ {
+ ui_out_field_fmt (uiout, "transfer-rate", "%lu", rate / 1024);
+ ui_out_text (uiout, " KB/sec");
+ }
}
else
{