From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Tromey To: deephan@erols.com Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] specify arguments to debugee from commandline (second try) Date: Thu, 05 Apr 2001 21:12:00 -0000 Message-id: <87pueqirpz.fsf@creche.redhat.com> References: <20010330005457.A21793@llamedos.org> <20010330163603.A27435@llamedos.org> X-SW-Source: 2001-04/msg00047.html >>>>> "David" == David Deephanphongs 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