mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 18:14:13 +08:00
2008-10-03 Paul Pluzhnikov <ppluzhnikov@google.com>
* utils.c, defs.h (gdb_buildargv): New fn. Wrap buildargv and check for out-of-memory condition. * exec.c (exec_file_command): Call it. * infrun.c (handle_command, xdb_handle_command): Likewise. * interps.c (interpreter_exec_cmd): Likewise. * linux-nat.c (linux_nat_info_proc_cmd): Likewise. * procfs.c (info_proc_cmd): Likewise. * remote-mips.c (common_open): Likewise. * remote-sim.c (gdbsim_kill, gdbsim_create_inferior) (gdbsim_open): Likewise. * remote.c (extended_remote_run, remote_put_command) (remote_get_command, remote_delete_command): Likewise. * ser-mingw.c (pipe_windows_open): Likesise. * source.c (add_path, show_substitute_path_command) (unset_substitute_path_command, set_substitute_path_command): Likewise. * stack.c (backtrace_command): Likewise. * symfile.c (symbol_file_command, generic_load) (add_symbol_file_command): Likesise. * symmisc.c (maintenance_print_symbols, maintenance_print_psymbols) (maintenance_print_msymbols): Likewise.
This commit is contained in:
parent
388853f746
commit
d1a4106143
@ -1,3 +1,27 @@
|
||||
2008-10-03 Paul Pluzhnikov <ppluzhnikov@google.com>
|
||||
|
||||
* utils.c, defs.h (gdb_buildargv): New fn. Wrap buildargv
|
||||
and check for out-of-memory condition.
|
||||
* exec.c (exec_file_command): Call it.
|
||||
* infrun.c (handle_command, xdb_handle_command): Likewise.
|
||||
* interps.c (interpreter_exec_cmd): Likewise.
|
||||
* linux-nat.c (linux_nat_info_proc_cmd): Likewise.
|
||||
* procfs.c (info_proc_cmd): Likewise.
|
||||
* remote-mips.c (common_open): Likewise.
|
||||
* remote-sim.c (gdbsim_kill, gdbsim_create_inferior)
|
||||
(gdbsim_open): Likewise.
|
||||
* remote.c (extended_remote_run, remote_put_command)
|
||||
(remote_get_command, remote_delete_command): Likewise.
|
||||
* ser-mingw.c (pipe_windows_open): Likesise.
|
||||
* source.c (add_path, show_substitute_path_command)
|
||||
(unset_substitute_path_command, set_substitute_path_command):
|
||||
Likewise.
|
||||
* stack.c (backtrace_command): Likewise.
|
||||
* symfile.c (symbol_file_command, generic_load)
|
||||
(add_symbol_file_command): Likesise.
|
||||
* symmisc.c (maintenance_print_symbols, maintenance_print_psymbols)
|
||||
(maintenance_print_msymbols): Likewise.
|
||||
|
||||
2008-10-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
Replace TYPE_ARRAY_{UPPER,LOWER}_BOUND_TYPE by a bit if {un,}defined.
|
||||
|
@ -405,6 +405,8 @@ ULONGEST strtoulst (const char *num, const char **trailer, int base);
|
||||
|
||||
char *ldirname (const char *filename);
|
||||
|
||||
char **gdb_buildargv (const char *);
|
||||
|
||||
/* From demangle.c */
|
||||
|
||||
extern void set_demangling_style (char *);
|
||||
|
@ -302,10 +302,7 @@ exec_file_command (char *args, int from_tty)
|
||||
/* Scan through the args and pick up the first non option arg
|
||||
as the filename. */
|
||||
|
||||
argv = buildargv (args);
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
for (; (*argv != NULL) && (**argv == '-'); argv++)
|
||||
|
15
gdb/infrun.c
15
gdb/infrun.c
@ -4070,11 +4070,7 @@ handle_command (char *args, int from_tty)
|
||||
|
||||
/* Break the command line up into args. */
|
||||
|
||||
argv = buildargv (args);
|
||||
if (argv == NULL)
|
||||
{
|
||||
nomem (0);
|
||||
}
|
||||
argv = gdb_buildargv (args);
|
||||
old_chain = make_cleanup_freeargv (argv);
|
||||
|
||||
/* Walk through the args, looking for signal oursigs, signal names, and
|
||||
@ -4231,13 +4227,12 @@ xdb_handle_command (char *args, int from_tty)
|
||||
char **argv;
|
||||
struct cleanup *old_chain;
|
||||
|
||||
if (args == NULL)
|
||||
error_no_arg (_("xdb command"));
|
||||
|
||||
/* Break the command line up into args. */
|
||||
|
||||
argv = buildargv (args);
|
||||
if (argv == NULL)
|
||||
{
|
||||
nomem (0);
|
||||
}
|
||||
argv = gdb_buildargv (args);
|
||||
old_chain = make_cleanup_freeargv (argv);
|
||||
if (argv[1] != (char *) NULL)
|
||||
{
|
||||
|
@ -371,20 +371,15 @@ interpreter_exec_cmd (char *args, int from_tty)
|
||||
unsigned int i;
|
||||
int old_quiet, use_quiet;
|
||||
|
||||
prules = buildargv (args);
|
||||
if (prules == NULL)
|
||||
{
|
||||
error (_("unable to parse arguments"));
|
||||
}
|
||||
if (args == NULL)
|
||||
error_no_arg (_("interpreter-exec command"));
|
||||
|
||||
prules = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (prules);
|
||||
|
||||
nrules = 0;
|
||||
if (prules != NULL)
|
||||
{
|
||||
for (trule = prules; *trule != NULL; trule++)
|
||||
{
|
||||
nrules++;
|
||||
}
|
||||
}
|
||||
for (trule = prules; *trule != NULL; trule++)
|
||||
nrules++;
|
||||
|
||||
if (nrules < 2)
|
||||
error (_("usage: interpreter-exec <interpreter> [ <command> ... ]"));
|
||||
|
@ -3591,10 +3591,8 @@ linux_nat_info_proc_cmd (char *args, int from_tty)
|
||||
if (args)
|
||||
{
|
||||
/* Break up 'args' into an argv array. */
|
||||
if ((argv = buildargv (args)) == NULL)
|
||||
nomem (0);
|
||||
else
|
||||
make_cleanup_freeargv (argv);
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
}
|
||||
while (argv != NULL && *argv != NULL)
|
||||
{
|
||||
|
@ -5853,10 +5853,8 @@ info_proc_cmd (char *args, int from_tty)
|
||||
old_chain = make_cleanup (null_cleanup, 0);
|
||||
if (args)
|
||||
{
|
||||
if ((argv = buildargv (args)) == NULL)
|
||||
nomem (0);
|
||||
else
|
||||
make_cleanup_freeargv (argv);
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
}
|
||||
while (argv != NULL && *argv != NULL)
|
||||
{
|
||||
|
@ -1490,8 +1490,7 @@ device is attached to the target board (e.g., /dev/ttya).\n"
|
||||
|
||||
/* Parse the serial port name, the optional TFTP name, and the
|
||||
optional local TFTP name. */
|
||||
if ((argv = buildargv (name)) == NULL)
|
||||
nomem (0);
|
||||
argv = gdb_buildargv (name);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
serial_port_name = xstrdup (argv[0]);
|
||||
|
@ -406,12 +406,13 @@ gdbsim_kill (void)
|
||||
static void
|
||||
gdbsim_load (char *args, int fromtty)
|
||||
{
|
||||
char **argv = buildargv (args);
|
||||
char **argv;
|
||||
char *prog;
|
||||
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
if (args == NULL)
|
||||
error_no_arg (_("program to load"));
|
||||
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
prog = tilde_expand (argv[0]);
|
||||
@ -472,7 +473,7 @@ gdbsim_create_inferior (char *exec_file, char *args, char **env, int from_tty)
|
||||
strcat (arg_buf, exec_file);
|
||||
strcat (arg_buf, " ");
|
||||
strcat (arg_buf, args);
|
||||
argv = buildargv (arg_buf);
|
||||
argv = gdb_buildargv (arg_buf);
|
||||
make_cleanup_freeargv (argv);
|
||||
}
|
||||
else
|
||||
@ -546,9 +547,7 @@ gdbsim_open (char *args, int from_tty)
|
||||
strcat (arg_buf, " "); /* 1 */
|
||||
strcat (arg_buf, args);
|
||||
}
|
||||
argv = buildargv (arg_buf);
|
||||
if (argv == NULL)
|
||||
error (_("Insufficient memory available to allocate simulator arg list."));
|
||||
argv = gdb_buildargv (arg_buf);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
init_callbacks ();
|
||||
|
24
gdb/remote.c
24
gdb/remote.c
@ -5546,13 +5546,14 @@ extended_remote_run (char *args)
|
||||
error (_("Remote file name too long for run packet"));
|
||||
len += 2 * bin2hex ((gdb_byte *) remote_exec_file, rs->buf + len, 0);
|
||||
|
||||
gdb_assert (args != NULL);
|
||||
if (*args)
|
||||
{
|
||||
struct cleanup *back_to;
|
||||
int i;
|
||||
char **argv;
|
||||
|
||||
argv = buildargv (args);
|
||||
argv = gdb_buildargv (args);
|
||||
back_to = make_cleanup ((void (*) (void *)) freeargv, argv);
|
||||
for (i = 0; argv[i] != NULL; i++)
|
||||
{
|
||||
@ -7491,9 +7492,10 @@ remote_put_command (char *args, int from_tty)
|
||||
struct cleanup *back_to;
|
||||
char **argv;
|
||||
|
||||
argv = buildargv (args);
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
if (args == NULL)
|
||||
error_no_arg (_("file to put"));
|
||||
|
||||
argv = gdb_buildargv (args);
|
||||
back_to = make_cleanup_freeargv (argv);
|
||||
if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
|
||||
error (_("Invalid parameters to remote put"));
|
||||
@ -7509,9 +7511,10 @@ remote_get_command (char *args, int from_tty)
|
||||
struct cleanup *back_to;
|
||||
char **argv;
|
||||
|
||||
argv = buildargv (args);
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
if (args == NULL)
|
||||
error_no_arg (_("file to get"));
|
||||
|
||||
argv = gdb_buildargv (args);
|
||||
back_to = make_cleanup_freeargv (argv);
|
||||
if (argv[0] == NULL || argv[1] == NULL || argv[2] != NULL)
|
||||
error (_("Invalid parameters to remote get"));
|
||||
@ -7527,9 +7530,10 @@ remote_delete_command (char *args, int from_tty)
|
||||
struct cleanup *back_to;
|
||||
char **argv;
|
||||
|
||||
argv = buildargv (args);
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
if (args == NULL)
|
||||
error_no_arg (_("file to delete"));
|
||||
|
||||
argv = gdb_buildargv (args);
|
||||
back_to = make_cleanup_freeargv (argv);
|
||||
if (argv[0] == NULL || argv[1] != NULL)
|
||||
error (_("Invalid parameters to remote delete"));
|
||||
|
@ -818,12 +818,15 @@ pipe_windows_open (struct serial *scb, const char *name)
|
||||
struct pipe_state *ps;
|
||||
FILE *pex_stderr;
|
||||
|
||||
char **argv = buildargv (name);
|
||||
if (name == NULL)
|
||||
error_no_arg (_("child command"));
|
||||
|
||||
char **argv = gdb_buildargv (name);
|
||||
struct cleanup *back_to = make_cleanup_freeargv (argv);
|
||||
|
||||
if (! argv[0] || argv[0][0] == '\0')
|
||||
error ("missing child command");
|
||||
|
||||
|
||||
ps = make_pipe_state ();
|
||||
make_cleanup (cleanup_pipe_state, ps);
|
||||
|
||||
|
11
gdb/source.c
11
gdb/source.c
@ -428,12 +428,9 @@ add_path (char *dirname, char **which_path, int parse_separators)
|
||||
/* This will properly parse the space and tab separators
|
||||
and any quotes that may exist. DIRNAME_SEPARATOR will
|
||||
be dealt with later. */
|
||||
argv = buildargv (dirname);
|
||||
argv = gdb_buildargv (dirname);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
|
||||
arg = argv[0];
|
||||
}
|
||||
else
|
||||
@ -1813,7 +1810,7 @@ show_substitute_path_command (char *args, int from_tty)
|
||||
char **argv;
|
||||
char *from = NULL;
|
||||
|
||||
argv = buildargv (args);
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
/* We expect zero or one argument. */
|
||||
@ -1846,7 +1843,7 @@ static void
|
||||
unset_substitute_path_command (char *args, int from_tty)
|
||||
{
|
||||
struct substitute_path_rule *rule = substitute_path_rules;
|
||||
char **argv = buildargv (args);
|
||||
char **argv = gdb_buildargv (args);
|
||||
char *from = NULL;
|
||||
int rule_found = 0;
|
||||
|
||||
@ -1899,7 +1896,7 @@ set_substitute_path_command (char *args, int from_tty)
|
||||
char **argv;
|
||||
struct substitute_path_rule *rule;
|
||||
|
||||
argv = buildargv (args);
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
if (argv == NULL || argv[0] == NULL || argv [1] == NULL)
|
||||
|
@ -1282,7 +1282,7 @@ backtrace_command (char *arg, int from_tty)
|
||||
char **argv;
|
||||
int i;
|
||||
|
||||
argv = buildargv (arg);
|
||||
argv = gdb_buildargv (arg);
|
||||
old_chain = make_cleanup_freeargv (argv);
|
||||
argc = 0;
|
||||
for (i = 0; argv[i]; i++)
|
||||
|
@ -1483,14 +1483,11 @@ symbol_file_command (char *args, int from_tty)
|
||||
}
|
||||
else
|
||||
{
|
||||
char **argv = buildargv (args);
|
||||
char **argv = gdb_buildargv (args);
|
||||
int flags = OBJF_USERLOADED;
|
||||
struct cleanup *cleanups;
|
||||
char *name = NULL;
|
||||
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
|
||||
cleanups = make_cleanup_freeargv (argv);
|
||||
while (*argv != NULL)
|
||||
{
|
||||
@ -1924,11 +1921,10 @@ generic_load (char *args, int from_tty)
|
||||
|
||||
make_cleanup (clear_memory_write_data, &cbdata.requests);
|
||||
|
||||
argv = buildargv (args);
|
||||
|
||||
if (argv == NULL)
|
||||
nomem(0);
|
||||
if (args == NULL)
|
||||
error_no_arg (_("file to load"));
|
||||
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
filename = tilde_expand (argv[0]);
|
||||
@ -2117,12 +2113,9 @@ add_symbol_file_command (char *args, int from_tty)
|
||||
if (args == NULL)
|
||||
error (_("add-symbol-file takes a file name and an address"));
|
||||
|
||||
argv = buildargv (args);
|
||||
argv = gdb_buildargv (args);
|
||||
make_cleanup_freeargv (argv);
|
||||
|
||||
if (argv == NULL)
|
||||
nomem (0);
|
||||
|
||||
for (arg = argv[0], argcnt = 0; arg != NULL; arg = argv[++argcnt])
|
||||
{
|
||||
/* Process the argument. */
|
||||
|
@ -526,10 +526,7 @@ maintenance_print_symbols (char *args, int from_tty)
|
||||
error (_("\
|
||||
Arguments missing: an output file name and an optional symbol file name"));
|
||||
}
|
||||
else if ((argv = buildargv (args)) == NULL)
|
||||
{
|
||||
nomem (0);
|
||||
}
|
||||
argv = gdb_buildargv (args);
|
||||
cleanups = make_cleanup_freeargv (argv);
|
||||
|
||||
if (argv[0] != NULL)
|
||||
@ -739,10 +736,7 @@ maintenance_print_psymbols (char *args, int from_tty)
|
||||
{
|
||||
error (_("print-psymbols takes an output file name and optional symbol file name"));
|
||||
}
|
||||
else if ((argv = buildargv (args)) == NULL)
|
||||
{
|
||||
nomem (0);
|
||||
}
|
||||
argv = gdb_buildargv (args);
|
||||
cleanups = make_cleanup_freeargv (argv);
|
||||
|
||||
if (argv[0] != NULL)
|
||||
@ -878,10 +872,7 @@ maintenance_print_msymbols (char *args, int from_tty)
|
||||
{
|
||||
error (_("print-msymbols takes an output file name and optional symbol file name"));
|
||||
}
|
||||
else if ((argv = buildargv (args)) == NULL)
|
||||
{
|
||||
nomem (0);
|
||||
}
|
||||
argv = gdb_buildargv (args);
|
||||
cleanups = make_cleanup_freeargv (argv);
|
||||
|
||||
if (argv[0] != NULL)
|
||||
|
14
gdb/utils.c
14
gdb/utils.c
@ -3349,3 +3349,17 @@ ldirname (const char *filename)
|
||||
dirname[base - filename] = '\0';
|
||||
return dirname;
|
||||
}
|
||||
|
||||
/* Call libiberty's buildargv, and return the result.
|
||||
If buildargv fails due to out-of-memory, call nomem.
|
||||
Therefore, the returned value is guaranteed to be non-NULL,
|
||||
unless the parameter itself is NULL. */
|
||||
|
||||
char **
|
||||
gdb_buildargv (const char *s)
|
||||
{
|
||||
char **argv = buildargv (s);
|
||||
if (s != NULL && argv == NULL)
|
||||
nomem (0);
|
||||
return argv;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user