public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: add --model-info helper option
@ 2010-04-16  7:32 Mike Frysinger
  2010-04-18  7:47 ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2010-04-16  7:32 UTC (permalink / raw)
  To: gdb-patches

There is an architecture-info flag for listing possible arch values, but
there is on equivalent for listing possible model values.  So add the
equivalent for models.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

2010-04-16  Mike Frysinger  <vapier@gentoo.org>

	* sim-model.c (OPTION_MODEL): Convert to enum.
	(OPTION_MODEL_INFO): New enum.
	(model_options): Add model-info/info-model entries.
	(model_option_handler): Handle OPTION_MODEL_INFO.
---
 sim/common/sim-model.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
index ddcb2de..5e7284c 100644
--- a/sim/common/sim-model.c
+++ b/sim/common/sim-model.c
@@ -32,12 +32,23 @@ static DECLARE_OPTION_HANDLER (model_option_handler);
 
 static MODULE_INIT_FN sim_model_init;
 
-#define OPTION_MODEL (OPTION_START + 0)
+enum {
+  OPTION_MODEL = OPTION_START,
+  OPTION_MODEL_INFO,
+};
 
 static const OPTION model_options[] = {
   { {"model", required_argument, NULL, OPTION_MODEL},
       '\0', "MODEL", "Specify model to simulate",
       model_option_handler, NULL },
+
+  { {"model-info", no_argument, NULL, OPTION_MODEL_INFO},
+      '\0', NULL, "List selectable models",
+      model_option_handler, NULL },
+  { {"info-model", no_argument, NULL, OPTION_MODEL_INFO},
+      '\0', NULL, "List selectable models",
+      model_option_handler, NULL },
+
   { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL, NULL }
 };
 
@@ -58,6 +69,22 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
 	sim_model_set (sd, cpu, model);
 	break;
       }
+
+    case OPTION_MODEL_INFO :
+      {
+	const MACH **machp;
+	const MODEL *model;
+	for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+	  {
+	    sim_io_printf (sd, "Models for architecture `%s':\n",
+			   MACH_NAME (*machp));
+	    for (model = MACH_MODELS (*machp); MODEL_NAME (model) != NULL;
+		 ++model)
+	      sim_io_printf (sd, " %s", MODEL_NAME (model));
+	  }
+	sim_io_printf (sd, "\n");
+	break;
+      }
     }
 
   return SIM_RC_OK;
-- 
1.7.0.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sim: add --model-info helper option
  2010-04-16  7:32 [PATCH] sim: add --model-info helper option Mike Frysinger
@ 2010-04-18  7:47 ` Doug Evans
  2010-04-19 18:41   ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2010-04-18  7:47 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

On Fri, Apr 16, 2010 at 12:31 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> There is an architecture-info flag for listing possible arch values, but
> there is on equivalent for listing possible model values.  So add the
> equivalent for models.
>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
>
> 2010-04-16  Mike Frysinger  <vapier@gentoo.org>
>
>        * sim-model.c (OPTION_MODEL): Convert to enum.
>        (OPTION_MODEL_INFO): New enum.
>        (model_options): Add model-info/info-model entries.
>        (model_option_handler): Handle OPTION_MODEL_INFO.
> ---
>  sim/common/sim-model.c |   29 ++++++++++++++++++++++++++++-
>  1 files changed, 28 insertions(+), 1 deletions(-)
>
> diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
> index ddcb2de..5e7284c 100644
> --- a/sim/common/sim-model.c
> +++ b/sim/common/sim-model.c
> @@ -32,12 +32,23 @@ static DECLARE_OPTION_HANDLER (model_option_handler);
>
>  static MODULE_INIT_FN sim_model_init;
>
> -#define OPTION_MODEL (OPTION_START + 0)
> +enum {
> +  OPTION_MODEL = OPTION_START,
> +  OPTION_MODEL_INFO,
> +};
>
>  static const OPTION model_options[] = {
>   { {"model", required_argument, NULL, OPTION_MODEL},
>       '\0', "MODEL", "Specify model to simulate",
>       model_option_handler, NULL },
> +
> +  { {"model-info", no_argument, NULL, OPTION_MODEL_INFO},
> +      '\0', NULL, "List selectable models",
> +      model_option_handler, NULL },
> +  { {"info-model", no_argument, NULL, OPTION_MODEL_INFO},
> +      '\0', NULL, "List selectable models",
> +      model_option_handler, NULL },
> +
>   { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL, NULL }
>  };
>
> @@ -58,6 +69,22 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
>        sim_model_set (sd, cpu, model);
>        break;
>       }
> +
> +    case OPTION_MODEL_INFO :
> +      {
> +       const MACH **machp;
> +       const MODEL *model;
> +       for (machp = & sim_machs[0]; *machp != NULL; ++machp)
> +         {
> +           sim_io_printf (sd, "Models for architecture `%s':\n",
> +                          MACH_NAME (*machp));
> +           for (model = MACH_MODELS (*machp); MODEL_NAME (model) != NULL;
> +                ++model)
> +             sim_io_printf (sd, " %s", MODEL_NAME (model));
> +         }
> +       sim_io_printf (sd, "\n");
> +       break;
> +      }
>     }
>
>   return SIM_RC_OK;
> --
> 1.7.0.2
>
>

Hi.

I believe you want NULL for the doc member of "info-model":

 +  { {"info-model", no_argument, NULL, OPTION_MODEL_INFO},
 +      '\0', NULL, "List selectable models",

"List selectable models" should be NULL.
At least according to sim-options.h:

     If DOC is NULL, this option name is listed as a synonym for the
     previous option.

Also, I think you want the last printf of "\n" inside the outer for loop:

 +       sim_io_printf (sd, "\n");

This patch is ok with these changes.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sim: add --model-info helper option
  2010-04-18  7:47 ` Doug Evans
@ 2010-04-19 18:41   ` Mike Frysinger
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2010-04-19 18:41 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 669 bytes --]

On Sunday 18 April 2010 03:47:34 Doug Evans wrote:
> I believe you want NULL for the doc member of "info-model":
> 
>  +  { {"info-model", no_argument, NULL, OPTION_MODEL_INFO},
>  +      '\0', NULL, "List selectable models",
> 
> "List selectable models" should be NULL.
> At least according to sim-options.h:
> 
>      If DOC is NULL, this option name is listed as a synonym for the
>      previous option.

cool, i wasnt aware of this feature

> Also, I think you want the last printf of "\n" inside the outer for loop:
> 
>  +       sim_io_printf (sd, "\n");

indeed

> This patch is ok with these changes.

OK, committed then, thanks
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-19 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-16  7:32 [PATCH] sim: add --model-info helper option Mike Frysinger
2010-04-18  7:47 ` Doug Evans
2010-04-19 18:41   ` Mike Frysinger

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 read-only IMAP folder(s) and NNTP newsgroup(s).