diff options
author | Tom Tromey <tromey@redhat.com> | 2001-11-22 00:23:13 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2001-11-22 00:23:13 +0000 |
commit | 552c04a7423afb694bd4948e8896b3c4cc4be816 (patch) | |
tree | d8dc2eb4aa8f8fcaafcd69d55584e295a99541f3 /gdb/infcmd.c | |
parent | aa26fa3a7e8aaec115e103eaf2108e7023e658c2 (diff) | |
download | gdb-552c04a7423afb694bd4948e8896b3c4cc4be816.zip gdb-552c04a7423afb694bd4948e8896b3c4cc4be816.tar.gz gdb-552c04a7423afb694bd4948e8896b3c4cc4be816.tar.bz2 |
Fix for PR gdb/209, PR gdb/156:
* gdbarch.c, gdbarch.h: Rebuilt.
* gdbarch.sh: Added `construct_inferior_arguments'.
* cli/cli-decode.h (cmd_list_element): Added pre_show_hook.
Typo fix.
* cli/cli-setshow.c (do_setshow_command): Call the pre_show_hook.
* infcmd.c (_initialize_infcmd): Set sfunc on `set args' command.
(inferior_argc, inferior_argv): New globals.
(notice_args_set): New function.
(set_inferior_args): Clear inferior_argc and inferior_argv.
(set_inferior_args_vector): New function.
(get_inferior_args): Handle inferior argument vector.
(run_command): Use get_inferior_args().
(notice_args_read): New function.
(_initialize_infcmd): Don't call set_inferior_args.
* command.h: Typo fix.
(cmd_list_element): Added pre_show_hook.
* main.c (captured_main): Added --args option.
(print_gdb_help): Document --args.
* inferior.h (construct_inferior_arguments): Declare.
(set_inferior_args_vector): Likewise.
* fork-child.c (construct_inferior_arguments): New function.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r-- | gdb/infcmd.c | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 67c57d0..b0d74ee 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -123,6 +123,12 @@ static void breakpoint_auto_delete_contents (PTR); static char *inferior_args; +/* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero, + then we must compute INFERIOR_ARGS from this (via the target). */ + +static int inferior_argc; +static char **inferior_argv; + /* File name for default use for standard in/out in the inferior. */ char *inferior_io_terminal; @@ -199,6 +205,19 @@ struct environ *inferior_environ; char * get_inferior_args (void) { + if (inferior_argc != 0) + { + char *n, *old; + + n = gdbarch_construct_inferior_arguments (current_gdbarch, + inferior_argc, inferior_argv); + old = set_inferior_args (n); + xfree (old); + } + + if (inferior_args == NULL) + inferior_args = xstrdup (""); + return inferior_args; } @@ -208,10 +227,37 @@ set_inferior_args (char *newargs) char *saved_args = inferior_args; inferior_args = newargs; + inferior_argc = 0; + inferior_argv = 0; return saved_args; } +void +set_inferior_args_vector (int argc, char **argv) +{ + inferior_argc = argc; + inferior_argv = argv; +} + +/* Notice when `set args' is run. */ +static void +notice_args_set (char *args, int from_tty, struct cmd_list_element *c) +{ + inferior_argc = 0; + inferior_argv = 0; +} + +/* Notice when `show args' is run. */ +static void +notice_args_read (struct cmd_list_element *c) +{ + /* Might compute the value. */ + get_inferior_args (); +} + + + /* This function detects whether or not a '&' character (indicating background execution) has been added as *the last* of the arguments ARGS of a command. If it has, it removes it and returns 1. Otherwise it @@ -331,7 +377,9 @@ Start it from the beginning? ")) if (exec_file) ui_out_field_string (uiout, "execfile", exec_file); ui_out_spaces (uiout, 1); - ui_out_field_string (uiout, "infargs", inferior_args); + /* We call get_inferior_args() because we might need to compute + the value now. */ + ui_out_field_string (uiout, "infargs", get_inferior_args ()); ui_out_text (uiout, "\n"); ui_out_flush (uiout); #else @@ -339,13 +387,17 @@ Start it from the beginning? ")) if (exec_file) puts_filtered (exec_file); puts_filtered (" "); - puts_filtered (inferior_args); + /* We call get_inferior_args() because we might need to compute + the value now. */ + puts_filtered (get_inferior_args ()); puts_filtered ("\n"); gdb_flush (gdb_stdout); #endif } - target_create_inferior (exec_file, inferior_args, + /* We call get_inferior_args() because we might need to compute + the value now. */ + target_create_inferior (exec_file, get_inferior_args (), environ_vector (inferior_environ)); } @@ -1785,8 +1837,10 @@ _initialize_infcmd (void) "Set argument list to give program being debugged when it is started.\n\ Follow this command with any number of args, to be passed to the program.", &setlist); - add_show_from_set (c, &showlist); c->completer = filename_completer; + c->function.sfunc = notice_args_set; + c = add_show_from_set (c, &showlist); + c->pre_show_hook = notice_args_read; c = add_cmd ("environment", no_class, environment_info, @@ -1952,7 +2006,6 @@ Register name as argument means describe only that register."); add_info ("float", float_info, "Print the status of the floating point unit\n"); - set_inferior_args (xstrdup ("")); /* Initially no args */ inferior_environ = make_environ (); init_environ (inferior_environ); } |