This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] specify arguments to debugee from commandline (second try)


>>>>> "David" == David Deephanphongs <deephan@erols.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
is desired.

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.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]