mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 12:03:41 +08:00
Harmonize this monitor_load with generic_load.
Harmonize this old-looking code with generic_load, which fixes several issues. 2013-02-19 Pedro Alves <palves@redhat.com> PR gdb/15161 Harmonize with generic_load. * monitor.c: Include "readline/readline.h". (monitor_load): Rename parameter 'file' to 'args'. Use build_argv instead of sscanf. Use CORE_ADDR/strtoulst instead of unsigned long/strtol for the 'load_offset' local. Error out if no argument is given or if too many arguments are given. Tilde expand the passed in file name.
This commit is contained in:
parent
5c111e3769
commit
40e397df34
@ -1,3 +1,16 @@
|
||||
2013-02-19 Pedro Alves <palves@redhat.com>
|
||||
|
||||
PR gdb/15161
|
||||
|
||||
Harmonize with generic_load.
|
||||
|
||||
* monitor.c: Include "readline/readline.h".
|
||||
(monitor_load): Rename parameter 'file' to 'args'. Use build_argv
|
||||
instead of sscanf. Use CORE_ADDR/strtoulst instead of unsigned
|
||||
long/strtol for the 'load_offset' local. Error out if no argument
|
||||
is given or if too many arguments are given. Tilde expand the
|
||||
passed in file name.
|
||||
|
||||
2013-02-19 Kai Tietz <ktietz@redhat.com>
|
||||
|
||||
PR gdb/15161
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "srec.h"
|
||||
#include "regcache.h"
|
||||
#include "gdbthread.h"
|
||||
#include "readline/readline.h"
|
||||
|
||||
static char *dev_name;
|
||||
static struct target_ops *targ_ops;
|
||||
@ -2175,35 +2176,56 @@ monitor_wait_srec_ack (void)
|
||||
/* monitor_load -- download a file. */
|
||||
|
||||
static void
|
||||
monitor_load (char *file, int from_tty)
|
||||
monitor_load (char *args, int from_tty)
|
||||
{
|
||||
monitor_debug ("MON load\n");
|
||||
|
||||
if (current_monitor->load_routine)
|
||||
current_monitor->load_routine (monitor_desc, file, hashmark);
|
||||
current_monitor->load_routine (monitor_desc, args, hashmark);
|
||||
else
|
||||
{ /* The default is ascii S-records. */
|
||||
int n;
|
||||
unsigned long load_offset;
|
||||
char buf[128];
|
||||
CORE_ADDR load_offset = 0;
|
||||
char **argv;
|
||||
struct cleanup *old_cleanups;
|
||||
char *filename;
|
||||
|
||||
if (args == NULL)
|
||||
error_no_arg (_("file to load"));
|
||||
|
||||
argv = gdb_buildargv (args);
|
||||
old_cleanups = make_cleanup_freeargv (argv);
|
||||
|
||||
filename = tilde_expand (argv[0]);
|
||||
make_cleanup (xfree, filename);
|
||||
|
||||
/* Enable user to specify address for downloading as 2nd arg to load. */
|
||||
n = sscanf (file, "%s 0x%lx", buf, &load_offset);
|
||||
if (n > 1)
|
||||
file = buf;
|
||||
else
|
||||
load_offset = 0;
|
||||
if (argv[1] != NULL)
|
||||
{
|
||||
const char *endptr;
|
||||
|
||||
load_offset = strtoulst (argv[1], &endptr, 0);
|
||||
|
||||
/* If the last word was not a valid number then
|
||||
treat it as a file name with spaces in. */
|
||||
if (argv[1] == endptr)
|
||||
error (_("Invalid download offset:%s."), argv[1]);
|
||||
|
||||
if (argv[2] != NULL)
|
||||
error (_("Too many parameters."));
|
||||
}
|
||||
|
||||
monitor_printf (current_monitor->load);
|
||||
if (current_monitor->loadresp)
|
||||
monitor_expect (current_monitor->loadresp, NULL, 0);
|
||||
|
||||
load_srec (monitor_desc, file, (bfd_vma) load_offset,
|
||||
load_srec (monitor_desc, filename, load_offset,
|
||||
32, SREC_ALL, hashmark,
|
||||
current_monitor->flags & MO_SREC_ACK ?
|
||||
monitor_wait_srec_ack : NULL);
|
||||
|
||||
monitor_expect_prompt (NULL, 0);
|
||||
|
||||
do_cleanups (old_cleanups);
|
||||
}
|
||||
|
||||
/* Finally, make the PC point at the start address. */
|
||||
|
Loading…
Reference in New Issue
Block a user