This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] specify arguments to debugee from commandline
- To: gdb-patches at sources dot redhat dot com
- Subject: [PATCH] specify arguments to debugee from commandline
- From: David Deephanphongs <deephan at erols dot com>
- Date: Fri, 30 Mar 2001 00:54:57 -0500
- Reply-To: deephan at erols dot com
This patch will add the option --args=<args> to gdb.
It assumes that <args> is one argument (i.e., is in quotes, or has the
spaces escaped).
--args acts just like calling 'set args <args>' does from the gdb prompt:
gdb --args '--color=never -l gdb' /bin/ls
is equivalent to:
gdb /bin/ls
gdb> set args --color=never -l gdb
It also adds a description of --args when 'gdb -h' is run,
and adds a description of --args to the manpage.
The patch is against the 20010327 snapshot.
======= Changelog =========
2001-03-30 David Deephanphongs <david@llamedos.org>
* main.c:
(set_inferior_args): Added extern prototype of set_inferior_args.
(captured_main): Add --args option to gdb.
* infcmd.c:
(inferior_args): initialize to zero.
(_initialize_infcmd): only call set_inferior_args (xtrdup (""))
if inferior_args is set to zero.
* gdb.1, main.c (print_gdb_help):
Document --args option
====== Patch =======
diff -c3p gdb-orig/gdb.1 gdb/gdb.1
*** gdb-orig/gdb.1 Tue Mar 6 03:21:07 2001
--- gdb/gdb.1 Fri Mar 30 00:22:00 2001
*************** gdb \- The GNU Debugger
*** 38,43 ****
--- 38,46 ----
.RB "[\|" "\-d "\c
.I dir\c
\&\|]
+ .RB "[\|" "\-args "\c
+ .I args\c
+ \&\|]
.RB "[\|" \c
.I prog\c
.RB "[\|" \c
*************** Execute GDB commands from file \c
*** 264,269 ****
--- 267,280 ----
Add \c
.I directory\c
\& to the path to search for source files.
+
+
+ .TP
+ .BI "\-args=" "args"\c
+ \&
+ Set \c
+ .I args\c
+ \& as the default arguments for the program to be debugged.
.PP
.TP
diff -c3p gdb-orig/infcmd.c gdb/infcmd.c
*** gdb-orig/infcmd.c Wed Mar 21 11:42:38 2001
--- gdb/infcmd.c Thu Mar 29 23:27:07 2001
*************** static void breakpoint_auto_delete_conte
*** 121,127 ****
/* String containing arguments to give to the program, separated by spaces.
Empty string (pointer to '\0') means no args. */
! static char *inferior_args;
/* File name for default use for standard in/out in the inferior. */
--- 121,127 ----
/* String containing arguments to give to the program, separated by spaces.
Empty string (pointer to '\0') means no args. */
! static char *inferior_args = 0;
/* File name for default use for standard in/out in the inferior. */
*************** Register name as argument means describe
*** 1967,1973 ****
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);
}
--- 1967,1974 ----
add_info ("float", float_info,
"Print the status of the floating point unit\n");
! if (inferior_args == 0)
! set_inferior_args (xstrdup ("")); /* Initially no args */
inferior_environ = make_environ ();
init_environ (inferior_environ);
}
diff -c3p gdb-orig/main.c gdb/main.c
*** gdb-orig/main.c Tue Mar 6 03:21:10 2001
--- gdb/main.c Fri Mar 30 00:14:39 2001
*************** static void print_gdb_help (struct ui_fi
*** 89,94 ****
--- 89,98 ----
extern int enable_external_editor;
extern char *external_editor_command;
+ /* Used to set the arguments to the inferior program (i.e., the program that
+ is being debugged.) */
+ extern char *set_inferior_args (char *newargs);
+
#ifdef __CYGWIN__
#include <windows.h> /* for MAX_PATH */
#include <sys/cygwin.h> /* for cygwin32_conv_to_posix_path */
*************** captured_main (void *data)
*** 284,289 ****
--- 288,294 ----
{"windows", no_argument, &use_windows, 1},
{"statistics", no_argument, 0, 13},
{"write", no_argument, &write_files, 1},
+ {"args", required_argument, 0, 14},
/* Allow machine descriptions to add more options... */
#ifdef ADDITIONAL_OPTIONS
ADDITIONAL_OPTIONS
*************** captured_main (void *data)
*** 325,330 ****
--- 330,339 ----
display_time = 1;
display_space = 1;
break;
+ case 14:
+ /* Set the arguments for the inferior program. */
+ set_inferior_args ( xstrdup (optarg) );
+ break;
case 'f':
annotation_level = 1;
/* We have probably been invoked from emacs. Disable window interface. */
*************** Options:\n\n\
*** 824,829 ****
--- 833,841 ----
-w Use a window interface.\n\
--write Set writing into executable and core files.\n\
--xdb XDB compatibility mode.\n\
+ ", stream);
+ fputs_unfiltered ("\
+ --args=args Set arguments to give debugged program when it is run.\n\
", stream);
#ifdef ADDITIONAL_OPTION_HELP
fputs_unfiltered (ADDITIONAL_OPTION_HELP, stream);