This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFC: Inferior command line arguments
- To: Michael Snyder <msnyder at cygnus dot com>
- Subject: Re: RFC: Inferior command line arguments
- From: Tom Tromey <tromey at redhat dot com>
- Date: 28 Sep 2001 12:43:24 -0600
- Cc: gdb-patches at sources dot redhat dot com
- References: <87zo7gq7gb.fsf@creche.redhat.com> <3BB4C04D.22C3DAB5@cygnus.com>
- Reply-To: tromey at redhat dot com
>>>>> "Michael" == Michael Snyder <msnyder@cygnus.com> writes:
>> gdb --args program arg1 arg2 ... argN
>> gdb program --args arg1 arg2 ... argN
Michael> Without having read thru your patch, how are you able to
Michael> distinguish between args that are intended for GDB (such as
Michael> "program" above), and args that are intended for the
Michael> inferior? You have "program" appearing both before and after
Michael> the "--args" flag. How are you picking it out as special?
Michael> How will you pick out other args that are intended for GDB
Michael> and not for the inferior, such as "-nw"?
In my current code, `--args' changes the interpretation of non-option
arguments. It doesn't stop argument processing. If you want that
then you have to use `--' as well.
So:
gdb --args gdb -nw
is a confusing way of writing:
gdb -nw --args gdb
This happens because GNU getopt reorders options as it processes the
command line.
It might be possible to have `--args' stop all other argument
processing. I haven't investigated that.
I think most people, especially script writers, will end up using
`--':
gdb --args -- gdb -nw
This invokes gdb on `gdb -nw'. The `--' processing is a built-in
feature of GNU getopt. It seemed easiest to take advantage of it,
since it already exists and is standard across tools.
I'm happy to change this to whatever we can agree is reasonable. My
primary desire is to have a way to add something to the start of a
command line (in a script or elsewhere) that will cause gdb to use the
remaining arguments as the program. Right now that is spelled `gdb
--args --', but other approaches would be fine by me.
Tom