diff options
author | Steve Chamberlain <sac@cygnus> | 1993-11-15 23:21:29 +0000 |
---|---|---|
committer | Steve Chamberlain <sac@cygnus> | 1993-11-15 23:21:29 +0000 |
commit | bf2429ab86d69f5bfe715c6272e2999575df587f (patch) | |
tree | b731f58e30f2b66cd738410fe0b5255ba280f4c8 /gdb | |
parent | 1c50f634d14cd8c95634dccae39b3c74c6ceb98d (diff) | |
download | gdb-bf2429ab86d69f5bfe715c6272e2999575df587f.zip gdb-bf2429ab86d69f5bfe715c6272e2999575df587f.tar.gz gdb-bf2429ab86d69f5bfe715c6272e2999575df587f.tar.bz2 |
* remote-utils.c, remote-utils.h (gr_load_image): New function to
download to target.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/remote-utils.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/gdb/remote-utils.c b/gdb/remote-utils.c index 5189bbd..9504320 100644 --- a/gdb/remote-utils.c +++ b/gdb/remote-utils.c @@ -37,8 +37,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ * a pass through mode a la kermit or telnet. * autobaud. * ask remote to change his baud rate. - * put generic load here. - */ #include <ctype.h> @@ -620,6 +618,63 @@ gr_store_word (addr, word) dcache_poke (gr_get_dcache(), addr, word); } +/* general purpose load a file specified on the command line + into target memory. */ + +void +gr_load_image (args, fromtty) + char *args; + int fromtty; +{ + bfd *abfd; + + asection *s; + struct cleanup *old_cleanups; + int delta = 4096; + char *buffer = xmalloc (delta); + + abfd = bfd_openr (args, (char *) 0); + + if (!abfd) + perror_with_name (args); + + old_cleanups = make_cleanup (bfd_close, abfd); + + QUIT; + immediate_quit++; + + if (!bfd_check_format (abfd, bfd_object)) + error ("It doesn't seem to be an object file.\n"); + + for (s = abfd->sections; s; s = s->next) + { + if (bfd_get_section_flags (abfd, s) & SEC_LOAD) + { + int i; + printf_filtered ("%s\t: 0x%4x .. 0x%4x ", + s->name, s->vma, s->vma + s->_raw_size); + for (i = 0; i < s->_raw_size; i += delta) + { + int sub_delta = delta; + if (sub_delta > s->_raw_size - i) + sub_delta = s->_raw_size - i; + + bfd_get_section_contents (abfd, s, buffer, i, sub_delta); + target_write_memory (s->vma + i, buffer, sub_delta); + printf_filtered ("*"); + fflush (stdout); + } + printf_filtered ("\n"); + } + } + immediate_quit--; + free (buffer); + write_pc (bfd_get_start_address (abfd)); + bfd_close (abfd); + discard_cleanups (old_cleanups); +} + + void _initialize_sr_support () { |