This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
generic_load: Variable chunk size -> ``set download-write-size''
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: generic_load: Variable chunk size -> ``set download-write-size''
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 19 Oct 1999 01:34:56 +1000
- Organization: Cygnus Solutions
Hello,
This is the semi-last one. It replaces the macro GENERIC_LOAD_CHUNK
with the variable ``set download-write-size''.
Once issue I've noticed is that, for target protocols that have very
small packet size the ui_load_progress_hook is going to be called more
frequently. Code displaying visual download animations may want to make
a note of that.
Andrew
Mon Oct 18 17:32:51 1999 Andrew Cagney <cagney@b1.cygnus.com>
* symfile.c (generic_load): Rewrite. Make the size of each
chunk/block write a run-time option. Check for quit_flag.
Use target_write_memory_partial for downloads.
Index: symfile.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/symfile.c,v
retrieving revision 1.202
diff -p -r1.202 symfile.c
*** symfile.c 1999/10/18 14:39:09 1.202
--- symfile.c 1999/10/18 15:19:51
*************** load_command (arg, from_tty)
*** 1208,1214 ****
we don't want to run a subprocess. On the other hand, I'm not sure how
performance compares. */
! #define GENERIC_LOAD_CHUNK 256
static int validate_download = 0;
void
--- 1208,1214 ----
we don't want to run a subprocess. On the other hand, I'm not sure how
performance compares. */
! static int download_write_size = 512;
static int validate_download = 0;
void
*************** generic_load (char *args, int from_tty)
*** 1272,1284 ****
char *buffer;
struct cleanup *old_chain;
CORE_ADDR lma = s->lma + load_offset;
! unsigned long l = size;
int err;
const char *sect_name = bfd_get_section_name (loadfile_bfd, s);
- unsigned long sent;
- unsigned long len;
! l = l > GENERIC_LOAD_CHUNK ? GENERIC_LOAD_CHUNK : l;
buffer = xmalloc (size);
old_chain = make_cleanup (free, buffer);
--- 1272,1286 ----
char *buffer;
struct cleanup *old_chain;
CORE_ADDR lma = s->lma + load_offset;
! CORE_ADDR block_size;
! CORE_ADDR sent;
int err;
const char *sect_name = bfd_get_section_name (loadfile_bfd, s);
! if (download_write_size > 0 && size > download_write_size)
! block_size = download_write_size;
! else
! block_size = size;
buffer = xmalloc (size);
old_chain = make_cleanup (free, buffer);
*************** generic_load (char *args, int from_tty)
*** 1294,1305 ****
sent = 0;
do
{
! len = (size - sent) < l ? (size - sent) : l;
! sent += len;
! err = target_write_memory (lma, buffer, len);
! if (ui_load_progress_hook)
! if (ui_load_progress_hook (sect_name, sent))
! error ("Canceled the download");
if (err)
break;
if (validate_download)
--- 1296,1307 ----
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,
! this_transfer, &err);
if (err)
break;
if (validate_download)
*************** generic_load (char *args, int from_tty)
*** 1326,1332 ****
lma += len;
buffer += len;
write_count += 1;
! } /* od */
while (sent < size);
if (err != 0)
--- 1328,1339 ----
lma += len;
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");
! }
while (sent < size);
if (err != 0)
*************** Usage: set extension-language .foo bar",
*** 3317,3320 ****
--- 3324,3339 ----
add_info ("extensions", info_ext_lang_command,
"All filename extensions associated with a source language.");
+
+ add_show_from_set
+ (add_set_cmd ("download-write-size", class_obscure,
+ var_integer, (char *) &download_write_size,
+ "Set the write size used when downloading a program.\n"
+ "Only used when downloading a program onto a remote\n"
+ "target. Specify zero, or a negative value, to disable\n"
+ "blocked writes. The actual size of each transfer is also\n"
+ "limited by the size of the target packet and the memory\n"
+ "cache.\n",
+ &setlist),
+ &showlist);
}