All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liviu Ionescu <ilg@livius.net>
To: Matthew Fortune <Matthew.Fortune@imgtec.com>
Cc: "peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	Leon Alrae <Leon.Alrae@imgtec.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"christopher.covington@linaro.org"
	<christopher.covington@linaro.org>
Subject: Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument
Date: Thu, 2 Apr 2015 19:47:01 +0300	[thread overview]
Message-ID: <1741D364-48FC-4682-B660-82A5B48F8DE4@livius.net> (raw)
In-Reply-To: <6D39441BF12EF246A7ABCE6654B023532101BA54@LEMAIL01.le.imgtec.org>


> On 02 Apr 2015, at 17:27, Matthew Fortune <Matthew.Fortune@imgtec.com> wrote:
> 
> Liviu Ionescu <ilg@livius.net> writes:
>> for completeness:
>> 
>> ilg-mbp:gnuarmeclipse-qemu.git ilg$ "/Applications/GNU ARM
>> Eclipse/QEMU/2.2.91-201504021111-dev/bin/qemu-system-gnuarmeclipse" -
>> verbose -machine STM32-H103 -gdb tcp::1234 -semihosting-config
>> enable=on,target=native,cmdline='n "1 a" 2 3'
> 
> I see here that you have switched quotes because you know that you are
> providing a double quoted argument within the string.

my code works both ways symmetrically:

ilg-mbp:~ ilg$ "/Applications/GNU ARM Eclipse"/QEMU/2.2.91-201504021111-dev/bin/qemu-system-gnuarmeclipse -verbose -machine STM32-H103 -gdb tcp::1234 -semihosting-config enable=on,target=native,cmdline="name 1 '2 a' 3"

GNU ARM Eclipse QEMU v2.2.91 (qemu-system-gnuarmeclipse).
Board: 'STM32-H103' (Olimex Header Board for STM32F103RBT6 (Experimental)).
Device: 'STM32F103RB' (cortex-m3, MPU), Flash: 128 KB, RAM: 20 KB.
Command line: 'name 1 '2 a' 3' (14 bytes).
GDB Server listening on: 'tcp::1234'...
... connection accepted from 127.0.0.1.

Execute 'mon system_reset'.
main(argc=4, argv=["name", "1", "2 a", "3"]);
Hello ARM World!

in other words, after being delivered by SYS_GET_CMDLINE to the application, the startup parser uses either single or double quotes to split the string into arguments, similarly to a real life shell.

> The root of all
> argument passing issues tends to boil down to how to quote and or escape
> characters appropriately. Because you know the arguments you can quote
> correctly but for an unknown user-provided set of arguments (where they
> do not know how their arguments will flow down to an application) then
> the appropriate quoting and escaping becomes harder.
> 
> The problem characters are obviously single and double quotes. Having
> different quoting rules for any of the layers between a user and
> the emulated program is always going to cause some confusion so when
> quoting is necessary I have always found that following the standard
> argument passing rules of the native application is the least
> problematic.

I guess you are generally right, but in this case any quoting is perfectly fine.

> qemu-system... -semihosting-config "arg=foo bar" -semihosting-config "arg=second"
> 
> This should give an argv of ["foo bar", "second"]

yes, but for the casual user the above syntax is already not natural and even more confusing: should I use "arg=foo bar" or arg="foo bar"? should I repeat -semihosting-config for each argument, or I can group all together (-semihosting-config arg="foo bar",arg="second")?


if for your use cases this syntax is acceptable, ok, go for it.


my first use of qemu is as a background GDB server started by an Eclipse plug-in. the plug-in will have a single edit field, where the user can enter the semihosting command line args. for args that include spaces, the user should use either single or double quotes, as in any other field.

my preferred implemention for this would be the original -semihosting-cmdline "some string".

both proposed implementations (-semihosting-config cmdline="some-string") and even worse for the multiple (-semihosting-config arg=some-string), are way more complicated to use in my Eclipse plug-in, requiring special precautions for passing single/double quotes, commas and possibly equals.

with the -semihosting-cmdline some-string, the only thing I have to do is to pass [-semihosting-cmdline] in one string array element, and the unmodified [some-string], regardless the quoting used, as the next string array element, and call exec().

given the above reasons, there are good chances that in my qemu fork (GNU ARM Eclipse QEMU) I'll have to use the separate -semihosting-cmdline option; if you'll accept my patches in the main trunk, ok, if not... no problem; 

as a conclusion, if you like arg=, go for it, but just be aware that this solution does not cover all use cases properly.


regards,

Liviu

  reply	other threads:[~2015-04-02 16:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 13:18 [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument Leon Alrae
2015-04-01 15:21 ` Liviu Ionescu
2015-04-01 16:12   ` Matthew Fortune
2015-04-02  7:56   ` Leon Alrae
2015-04-02  8:29     ` Liviu Ionescu
2015-04-02  9:14       ` Leon Alrae
2015-04-02 10:36         ` Leon Alrae
2015-04-02 12:36           ` Liviu Ionescu
2015-04-02 14:27             ` Matthew Fortune
2015-04-02 16:47               ` Liviu Ionescu [this message]
2015-04-03 15:33                 ` Liviu Ionescu
2015-04-08 16:20                 ` Leon Alrae
2015-04-14 17:42                   ` Liviu Ionescu
2015-04-15  9:09                     ` Liviu Ionescu
2015-04-15 11:53                       ` Leon Alrae
2015-04-15 12:02                         ` Matthew Fortune
2015-04-15 12:06                         ` Liviu Ionescu
2015-04-15 12:49                           ` Leon Alrae
2015-04-15 16:08                             ` Liviu Ionescu
2015-04-16  9:27                               ` Leon Alrae
2015-04-17 17:45                                 ` Liviu Ionescu
2015-04-16 14:22                       ` Peter Maydell
2015-04-21 13:34                         ` Leon Alrae
2015-04-21 15:14                           ` Liviu Ionescu
2015-04-21 15:55                             ` Peter Maydell
2015-04-21 16:21                               ` Liviu Ionescu
2015-04-21 16:23                                 ` Peter Maydell
2015-04-21 16:51                                   ` Liviu Ionescu
2015-04-21 17:50                                     ` Peter Maydell
2015-04-21 16:48                               ` Eric Blake
2015-04-21 16:54                                 ` Peter Maydell
2015-04-21 17:22                                   ` Eric Blake
2015-04-21 17:49                                   ` Liviu Ionescu
2015-04-21 18:08                           ` Liviu Ionescu
2015-04-23 11:55                             ` Leon Alrae
2015-04-23 12:07                               ` Liviu Ionescu
2015-04-01 15:45 ` Christopher Covington
2015-04-01 16:24   ` Liviu Ionescu
2015-04-04 15:20 ` Liviu Ionescu

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=1741D364-48FC-4682-B660-82A5B48F8DE4@livius.net \
    --to=ilg@livius.net \
    --cc=Leon.Alrae@imgtec.com \
    --cc=Matthew.Fortune@imgtec.com \
    --cc=christopher.covington@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.