From: Michael Snyder <msnyder@cygnus.com>
To: gdb-patches@sources.redhat.com
Cc: ezannoni@redhat.com, jimb@redhat.com
Subject: [RFA] symfile.c/generic_load cleanups
Date: Fri, 11 Jan 2002 14:36:00 -0000 [thread overview]
Message-ID: <200201112230.g0BMUx208454@reddwarf.cygnus.com> (raw)
Change some local variables to more appropriate types
(CORE_ADDR was used rather liberally), use a bfd access method
instead of grubbing around in the bfd structure directly, and
clean up some indentation and long lines.
OK to check in?
2002-01-11 Michael Snyder <msnyder@redhat.com>
* symfile.c (generic_load): Whitespace and long line cleanups.
(total_size): Not a CORE_ADDR, change to bfd_size_type.
(total_sent): Duplicates variable "data_count". Eliminate.
(size): Not a CORE_ADDR, change to bfd_size_type.
(block_size): Not a CORE_ADDR, change to bfd_size_type.
(sent): Not a CORE_ADDR, change to bfd_size_type.
(lma): Use bfd access method to get bfd member value.
(len): Not a CORE_ADDR -- int is sufficient.
(this_transfer): Not a CORE_ADDR, change to bfd_size_type.
(print_transfer_performance): Use %lu instead of %ld for ulongs.
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.46
diff -c -3 -p -r1.46 symfile.c
*** symfile.c 2002/01/08 02:09:31 1.46
--- symfile.c 2002/01/11 22:24:13
*************** generic_load (char *args, int from_tty)
*** 1182,1189 ****
char *filename;
struct cleanup *old_cleanups;
char *offptr;
! CORE_ADDR total_size = 0;
! CORE_ADDR total_sent = 0;
/* Parse the input argument - the user can specify a load offset as
a second argument. */
--- 1182,1188 ----
char *filename;
struct cleanup *old_cleanups;
char *offptr;
! bfd_size_type total_size = 0;
/* Parse the input argument - the user can specify a load offset as
a second argument. */
*************** generic_load (char *args, int from_tty)
*** 1194,1199 ****
--- 1193,1199 ----
if (offptr != NULL)
{
char *endptr;
+
load_offset = strtoul (offptr, &endptr, 0);
if (offptr == endptr)
error ("Invalid download offset:%s\n", offptr);
*************** generic_load (char *args, int from_tty)
*** 1231,1246 ****
{
if (s->flags & SEC_LOAD)
{
! CORE_ADDR size = bfd_get_section_size_before_reloc (s);
if (size > 0)
{
char *buffer;
struct cleanup *old_chain;
! CORE_ADDR lma = s->lma + load_offset;
! CORE_ADDR block_size;
int err;
const char *sect_name = bfd_get_section_name (loadfile_bfd, s);
! CORE_ADDR sent;
if (download_write_size > 0 && size > download_write_size)
block_size = download_write_size;
--- 1231,1247 ----
{
if (s->flags & SEC_LOAD)
{
! bfd_size_type size = bfd_get_section_size_before_reloc (s);
!
if (size > 0)
{
char *buffer;
struct cleanup *old_chain;
! CORE_ADDR lma = bfd_section_lma (loadfile_bfd, s) + load_offset;
! bfd_size_type block_size;
int err;
const char *sect_name = bfd_get_section_name (loadfile_bfd, s);
! bfd_size_type sent;
if (download_write_size > 0 && size > download_write_size)
block_size = download_write_size;
*************** generic_load (char *args, int from_tty)
*** 1253,1260 ****
/* Is this really necessary? I guess it gives the user something
to look at during a long download. */
#ifdef UI_OUT
! ui_out_message (uiout, 0, "Loading section %s, size 0x%s lma 0x%s\n",
! sect_name, paddr_nz (size), paddr_nz (lma));
#else
fprintf_unfiltered (gdb_stdout,
"Loading section %s, size 0x%s lma 0x%s\n",
--- 1254,1262 ----
/* Is this really necessary? I guess it gives the user something
to look at during a long download. */
#ifdef UI_OUT
! ui_out_message (uiout, 0,
! "Loading section %s, size 0x%s lma 0x%s\n",
! sect_name, paddr_nz (size), paddr_nz (lma));
#else
fprintf_unfiltered (gdb_stdout,
"Loading section %s, size 0x%s lma 0x%s\n",
*************** generic_load (char *args, int from_tty)
*** 1266,1273 ****
sent = 0;
do
{
! CORE_ADDR len;
! CORE_ADDR this_transfer = size - sent;
if (this_transfer >= block_size)
this_transfer = block_size;
len = target_write_memory_partial (lma, buffer,
--- 1268,1276 ----
sent = 0;
do
{
! int len;
! bfd_size_type this_transfer = size - sent;
!
if (this_transfer >= block_size)
this_transfer = block_size;
len = target_write_memory_partial (lma, buffer,
*************** generic_load (char *args, int from_tty)
*** 1285,1291 ****
that. remote.c could implement that method
using the ``qCRC'' packet. */
char *check = xmalloc (len);
! struct cleanup *verify_cleanups = make_cleanup (xfree, check);
if (target_read_memory (lma, check, len) != 0)
error ("Download verify read failed at 0x%s",
paddr (lma));
--- 1288,1296 ----
that. remote.c could implement that method
using the ``qCRC'' packet. */
char *check = xmalloc (len);
! struct cleanup *verify_cleanups = make_cleanup (xfree,
! check);
!
if (target_read_memory (lma, check, len) != 0)
error ("Download verify read failed at 0x%s",
paddr (lma));
*************** generic_load (char *args, int from_tty)
*** 1299,1317 ****
buffer += len;
write_count += 1;
sent += len;
- total_sent += len;
if (quit_flag
|| (ui_load_progress_hook != NULL
&& ui_load_progress_hook (sect_name, sent)))
error ("Canceled the download");
if (show_load_progress != NULL)
! show_load_progress (sect_name, sent, size, total_sent, total_size);
}
while (sent < size);
if (err != 0)
! error ("Memory access error while loading section %s.", sect_name);
do_cleanups (old_chain);
}
--- 1304,1323 ----
buffer += len;
write_count += 1;
sent += len;
if (quit_flag
|| (ui_load_progress_hook != NULL
&& ui_load_progress_hook (sect_name, sent)))
error ("Canceled the download");
if (show_load_progress != NULL)
! show_load_progress (sect_name, sent, size,
! data_count, total_size);
}
while (sent < size);
if (err != 0)
! error ("Memory access error while loading section %s.",
! sect_name);
do_cleanups (old_chain);
}
*************** generic_load (char *args, int from_tty)
*** 1320,1337 ****
end_time = time (NULL);
{
! CORE_ADDR entry;
! entry = bfd_get_start_address (loadfile_bfd);
#ifdef UI_OUT
! ui_out_text (uiout, "Start address ");
! ui_out_field_fmt (uiout, "address", "0x%s" , paddr_nz (entry));
! ui_out_text (uiout, ", load size ");
! ui_out_field_fmt (uiout, "load-size", "%ld" , data_count);
! ui_out_text (uiout, "\n");
#else
fprintf_unfiltered (gdb_stdout,
! "Start address 0x%s , load size %ld\n",
paddr_nz (entry), data_count);
#endif
/* We were doing this in remote-mips.c, I suspect it is right
--- 1326,1343 ----
end_time = time (NULL);
{
! CORE_ADDR entry = bfd_get_start_address (loadfile_bfd);
!
#ifdef UI_OUT
! ui_out_text (uiout, "Start address ");
! ui_out_field_fmt (uiout, "address", "0x%s", paddr_nz (entry));
! ui_out_text (uiout, ", load size ");
! ui_out_field_fmt (uiout, "load-size", "%lu", data_count);
! ui_out_text (uiout, "\n");
#else
fprintf_unfiltered (gdb_stdout,
! "Start address 0x%s, load size %lu\n",
paddr_nz (entry), data_count);
#endif
/* We were doing this in remote-mips.c, I suspect it is right
*************** void
*** 1361,1367 ****
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);
}
void
--- 1367,1374 ----
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);
}
void
*************** print_transfer_performance (struct ui_fi
*** 1374,1403 ****
ui_out_text (uiout, "Transfer rate: ");
if (time_count > 0)
{
! ui_out_field_fmt (uiout, "transfer-rate", "%ld",
(data_count * 8) / time_count);
ui_out_text (uiout, " bits/sec");
}
else
{
! ui_out_field_fmt (uiout, "transferred-bits", "%ld", (data_count * 8));
ui_out_text (uiout, " bits in <1 sec");
}
if (write_count > 0)
{
ui_out_text (uiout, ", ");
! ui_out_field_fmt (uiout, "write-rate", "%ld", data_count / write_count);
ui_out_text (uiout, " bytes/write");
}
ui_out_text (uiout, ".\n");
#else
fprintf_unfiltered (stream, "Transfer rate: ");
if (time_count > 0)
! fprintf_unfiltered (stream, "%ld bits/sec", (data_count * 8) / time_count);
else
! fprintf_unfiltered (stream, "%ld bits in <1 sec", (data_count * 8));
if (write_count > 0)
! fprintf_unfiltered (stream, ", %ld bytes/write", data_count / write_count);
fprintf_unfiltered (stream, ".\n");
#endif
}
--- 1381,1410 ----
ui_out_text (uiout, "Transfer rate: ");
if (time_count > 0)
{
! ui_out_field_fmt (uiout, "transfer-rate", "%lu",
(data_count * 8) / time_count);
ui_out_text (uiout, " bits/sec");
}
else
{
! ui_out_field_fmt (uiout, "transferred-bits", "%lu", (data_count * 8));
ui_out_text (uiout, " bits in <1 sec");
}
if (write_count > 0)
{
ui_out_text (uiout, ", ");
! ui_out_field_fmt (uiout, "write-rate", "%lu", data_count / write_count);
ui_out_text (uiout, " bytes/write");
}
ui_out_text (uiout, ".\n");
#else
fprintf_unfiltered (stream, "Transfer rate: ");
if (time_count > 0)
! fprintf_unfiltered (stream, "%lu bits/sec", (data_count * 8) / time_count);
else
! fprintf_unfiltered (stream, "%lu bits in <1 sec", (data_count * 8));
if (write_count > 0)
! fprintf_unfiltered (stream, ", %lu bytes/write", data_count / write_count);
fprintf_unfiltered (stream, ".\n");
#endif
}
next reply other threads:[~2002-01-11 22:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-11 14:36 Michael Snyder [this message]
2002-01-11 21:24 ` Elena Zannoni
2002-01-12 15:45 ` Michael Snyder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200201112230.g0BMUx208454@reddwarf.cygnus.com \
--to=msnyder@cygnus.com \
--cc=ezannoni@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox