From: Tom Tromey <tromey@redhat.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: PATCH: gdb --args
Date: Thu, 11 Oct 2001 10:14:00 -0000 [thread overview]
Message-ID: <87y9mixezm.fsf@creche.redhat.com> (raw)
In-Reply-To: <3BC5BB72.9040300@cygnus.com>
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
prev parent reply other threads:[~2001-10-11 10:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-10 15:28 Tom Tromey
2001-10-11 1:02 ` Eli Zaretskii
2001-10-11 8:32 ` Andrew Cagney
2001-10-11 9:56 ` Eli Zaretskii
2001-10-11 10:24 ` Andrew Cagney
2001-10-11 10:29 ` Tom Tromey
2001-10-11 10:49 ` Andrew Cagney
2001-10-11 10:14 ` Tom Tromey [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y9mixezm.fsf@creche.redhat.com \
--to=tromey@redhat.com \
--cc=ac131313@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox