From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Tromey To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: PATCH: gdb --args Date: Thu, 11 Oct 2001 10:14:00 -0000 Message-id: <87y9mixezm.fsf@creche.redhat.com> References: <87ofnfm80i.fsf@creche.redhat.com> <3BC5BB72.9040300@cygnus.com> X-SW-Source: 2001-10/msg00135.html Tom> * target.c (find_default_construct_inferior_arguments): New Tom> function. Andrew> Is this an architecture (well OS) or target method? Andrew> At present there is the target method: Andrew> to_create_inferior(char *exec_file, char *args, char **env) Andrew> where ARGS are assumed to be in an OS dependant form but Andrew> typically ready to plonk onto the end of ``exec EXEC_FILE''. Andrew> The plonk might be performed locally (fork/exec) or remotely. As I understood it, to_create_inferior assumed that ARGS was properly quoted for the target. To me this implies that the transformation from argv[] to string must be done in a target-dependent way -- that is, in a way that matches what the corresponding to_create_inferior expects. Andrew> Given an argv[], I think the code should call on the Andrew> architecture (OS) and not the target to perform the Andrew> transformation into ARGS. I think this will do the wrong thing in some situations. Here's a hypothetical situation. Suppose you can somehow debug a Unix program from a Windows machine. In this Windows gdb you can use "run" and some server on the Unix box will use the code in fork-inferior.c to run a new inferior. In this case, quoting based on the host would be incorrectly quoted -- it would be quoted by Windows conventions but the target would be expecting Unix conventions. I dug around in the code a bit and came up with a real example. Suppose I am debugging a remote VxWorks process using a gdb running on my Linux box. remote-vx.c:parse_args() does some very simple command-line processing. It just splits the command-line at whitespace. If you run an argv[] through the Unix stringizer, you'll get the wrong result for this target -- for instance, if an argument has a space the "right" result would be an error message: "you can't do that". But the result you'd actually get would have added trailing backslashes to various arguments. Another similar example is that the simulators use buildargv (from libiberty) to turn a string into an argument vector. The simulators can be used on any host, but the argv[]->string step must create a string which buildargv will parse back into the same argv[]. This also implies that the stringizing must be done on a per-target basis. Tom