qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Leon Alrae <leon.alrae@imgtec.com>
Cc: Liviu Ionescu <ilg@livius.net>,
	Christopher Covington <christopher.covington@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Matthew Fortune <matthew.fortune@imgtec.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/2] semihosting: add --semihosting-config arg sub-argument
Date: Thu, 7 May 2015 14:02:22 +0100	[thread overview]
Message-ID: <CAFEAcA8bGU8dw9sabZb46C+paKJBPC0xK1bX8Wq6wGAHrGpeFA@mail.gmail.com> (raw)
In-Reply-To: <1430999376-16601-3-git-send-email-leon.alrae@imgtec.com>

On 7 May 2015 at 12:49, Leon Alrae <leon.alrae@imgtec.com> wrote:
> Add new "arg" sub-argument to the --semihosting-config allowing to pass
> multiple input argument separately. It is required for example by UHI
> semihosting to construct argc and argv.

> diff --git a/qemu-options.hx b/qemu-options.hx
> index ec356f6..ed2a7e8 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3296,14 +3296,16 @@ STEXI
>  Enable semihosting mode (ARM, M68K, Xtensa only).
>  ETEXI
>  DEF("semihosting-config", HAS_ARG, QEMU_OPTION_semihosting_config,
> -    "-semihosting-config [enable=on|off,]target=native|gdb|auto   semihosting configuration\n",
> +    "-semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]\n" \
> +    "                semihosting configuration\n",
>  QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32)
>  STEXI
> -@item -semihosting-config [enable=on|off,]target=native|gdb|auto
> +@item -semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]
>  @findex -semihosting-config
>  Enable semihosting and define where the semihosting calls will be addressed,
>  to QEMU (@code{native}) or to GDB (@code{gdb}). The default is @code{auto}, which means
> -@code{gdb} during debug sessions and @code{native} otherwise (ARM, M68K, Xtensa only).
> +@code{gdb} during debug sessions and @code{native} otherwise. The @var{arg} allows to
> +pass input arguments, can be used multiple times to build up a list (ARM, M68K, Xtensa only)

This makes it sound like the var{arg} bit is arm/m68k/xtensa only, whereas it's
the whole semihosting-config that that applies to. I'd suggest that now we
have more than one subargument to this we should rephrase it to:

 Enable and configure semihosting (ARM, M68K, Xtensa only).
 @var{target} defines where the semihosting calls will be addressed [etc]
 @var{arg} allows [etc]

PS: avoid "allows to", which isn't idiomatic English.

You also need to document how {arg} interacts with the old-style
-kernel/-append method of passing a command line to semihosting.

>  ETEXI
>  DEF("old-param", 0, QEMU_OPTION_old_param,
>      "-old-param      old param mode\n", QEMU_ARCH_ARM)
> diff --git a/vl.c b/vl.c
> index f3319a9..c8ac1e6 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -486,6 +486,9 @@ static QemuOptsList qemu_semihosting_config_opts = {
>          }, {
>              .name = "target",
>              .type = QEMU_OPT_STRING,
> +        }, {
> +            .name = "arg",
> +            .type = QEMU_OPT_STRING,
>          },
>          { /* end of list */ }
>      },
> @@ -1230,6 +1233,8 @@ static void configure_msg(QemuOpts *opts)
>  typedef struct SemihostingConfig {
>      bool enabled;
>      SemihostingTarget target;
> +    const char **argv;
> +    int argc;
>  } SemihostingConfig;
>
>  static SemihostingConfig semihosting;
> @@ -1244,6 +1249,31 @@ SemihostingTarget semihosting_get_target(void)
>      return semihosting.target;
>  }
>
> +const char *semihosting_get_arg(int i)
> +{
> +    if (i >= semihosting.argc) {
> +        return NULL;
> +    }
> +
> +    return semihosting.argv[i];
> +}
> +
> +int semihosting_get_argc(void)
> +{
> +    return semihosting.argc;
> +}
> +
> +static int add_semihosting_arg(const char *name, const char *val, void *opaque)
> +{
> +    SemihostingConfig *s = opaque;
> +    if (strcmp(name, "arg") == 0) {
> +        s->argc++;
> +        s->argv = g_realloc(s->argv, s->argc * sizeof(void *));
> +        s->argv[s->argc - 1] = val;
> +    }

Consider using a glib pointer array? Then this is just
a call to g_pointer_array_add().

(If not, then I agree that this is entirely fine and it's
more self-contained and maintainable to just realloc here
than to add code to the option-parsing first-pass loop.)

thanks
-- PMM

  reply	other threads:[~2015-05-07 13:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07 11:49 [Qemu-devel] [PATCH v2 0/2] semihosting: clean up and add --semihosting-config arg Leon Alrae
2015-05-07 11:49 ` [Qemu-devel] [PATCH v2 1/2] semihosting: create SemihostingConfig structure and semihost.h Leon Alrae
2015-05-07 12:40   ` Peter Maydell
2015-05-07 11:49 ` [Qemu-devel] [PATCH v2 2/2] semihosting: add --semihosting-config arg sub-argument Leon Alrae
2015-05-07 13:02   ` Peter Maydell [this message]
2015-05-07 16:18     ` Leon Alrae

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=CAFEAcA8bGU8dw9sabZb46C+paKJBPC0xK1bX8Wq6wGAHrGpeFA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=christopher.covington@linaro.org \
    --cc=ilg@livius.net \
    --cc=leon.alrae@imgtec.com \
    --cc=matthew.fortune@imgtec.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).