This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH] specify arguments to debugee from commandline (second try)
- To: deephan at erols dot com
- Subject: Re: [PATCH] specify arguments to debugee from commandline (second try)
- From: Tom Tromey <tromey at redhat dot com>
- Date: 05 Apr 2001 22:20:56 -0600
- Cc: gdb-patches at sources dot redhat dot com
- References: <20010330005457.A21793@llamedos.org> <20010330163603.A27435@llamedos.org>
- Reply-To: tromey at redhat dot com
>>>>> "David" == David Deephanphongs <email@example.com> writes:
David> This patch allows the user to pass the arguments to the program
David> to be debugged on the command line.
I'm very interested in this functionality, so I looked at this patch.
David> I do this in two passes - the first pass calculates the length
David> of the argument string, the second pass strcpy and strcat's the
David> arguments into the buffer.
Unfortunately your patch doesn't do this in a safe way.
Suppose I invoke: gdb --run foo "arg with space" bar
My reading of the code is that the inferior arguments will be set to
`arg with space bar' -- which will yield a different result than what
I believe for this to work properly the code that calls
set_inferior_arg() must quote the strings for the shell. This isn't
too hard to do -- simply put a `\' before each special character. The
list of special characters is relatively shell-independent (weirdly
enough); using a superset won't hurt.