From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8595 invoked by alias); 18 Apr 2010 07:47:43 -0000 Received: (qmail 8586 invoked by uid 22791); 18 Apr 2010 07:47:43 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SARE_MSGID_LONG45,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Apr 2010 07:47:38 +0000 Received: from kpbe11.cbf.corp.google.com (kpbe11.cbf.corp.google.com [172.25.105.75]) by smtp-out.google.com with ESMTP id o3I7lae3009467 for ; Sun, 18 Apr 2010 00:47:36 -0700 Received: from pwj2 (pwj2.prod.google.com [10.241.219.66]) by kpbe11.cbf.corp.google.com with ESMTP id o3I7lYi6004454 for ; Sun, 18 Apr 2010 02:47:35 -0500 Received: by pwj2 with SMTP id 2so2627379pwj.3 for ; Sun, 18 Apr 2010 00:47:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.247.17 with HTTP; Sun, 18 Apr 2010 00:47:34 -0700 (PDT) In-Reply-To: <1271403092-21679-1-git-send-email-vapier@gentoo.org> References: <1271403092-21679-1-git-send-email-vapier@gentoo.org> Date: Sun, 18 Apr 2010 07:47:00 -0000 Received: by 10.140.248.8 with SMTP id v8mr3202272rvh.9.1271576854510; Sun, 18 Apr 2010 00:47:34 -0700 (PDT) Message-ID: Subject: Re: [PATCH] sim: add --model-info helper option From: Doug Evans To: Mike Frysinger Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00543.txt.bz2 On Fri, Apr 16, 2010 at 12:31 AM, Mike Frysinger wrote: > There is an architecture-info flag for listing possible arch values, but > there is on equivalent for listing possible model values. =A0So add the > equivalent for models. > > Signed-off-by: Mike Frysinger > > 2010-04-16 =A0Mike Frysinger =A0 > > =A0 =A0 =A0 =A0* sim-model.c (OPTION_MODEL): Convert to enum. > =A0 =A0 =A0 =A0(OPTION_MODEL_INFO): New enum. > =A0 =A0 =A0 =A0(model_options): Add model-info/info-model entries. > =A0 =A0 =A0 =A0(model_option_handler): Handle OPTION_MODEL_INFO. > --- > =A0sim/common/sim-model.c | =A0 29 ++++++++++++++++++++++++++++- > =A01 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); > > =A0static MODULE_INIT_FN sim_model_init; > > -#define OPTION_MODEL (OPTION_START + 0) > +enum { > + =A0OPTION_MODEL =3D OPTION_START, > + =A0OPTION_MODEL_INFO, > +}; > > =A0static const OPTION model_options[] =3D { > =A0 { {"model", required_argument, NULL, OPTION_MODEL}, > =A0 =A0 =A0 '\0', "MODEL", "Specify model to simulate", > =A0 =A0 =A0 model_option_handler, NULL }, > + > + =A0{ {"model-info", no_argument, NULL, OPTION_MODEL_INFO}, > + =A0 =A0 =A0'\0', NULL, "List selectable models", > + =A0 =A0 =A0model_option_handler, NULL }, > + =A0{ {"info-model", no_argument, NULL, OPTION_MODEL_INFO}, > + =A0 =A0 =A0'\0', NULL, "List selectable models", > + =A0 =A0 =A0model_option_handler, NULL }, > + > =A0 { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL, NULL } > =A0}; > > @@ -58,6 +69,22 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int o= pt, > =A0 =A0 =A0 =A0sim_model_set (sd, cpu, model); > =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 } > + > + =A0 =A0case OPTION_MODEL_INFO : > + =A0 =A0 =A0{ > + =A0 =A0 =A0 const MACH **machp; > + =A0 =A0 =A0 const MODEL *model; > + =A0 =A0 =A0 for (machp =3D & sim_machs[0]; *machp !=3D NULL; ++machp) > + =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 sim_io_printf (sd, "Models for architecture `%s':\n= ", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MACH_NAME (*machp)); > + =A0 =A0 =A0 =A0 =A0 for (model =3D MACH_MODELS (*machp); MODEL_NAME (mo= del) !=3D NULL; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0++model) > + =A0 =A0 =A0 =A0 =A0 =A0 sim_io_printf (sd, " %s", MODEL_NAME (model)); > + =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 sim_io_printf (sd, "\n"); > + =A0 =A0 =A0 break; > + =A0 =A0 =A0} > =A0 =A0 } > > =A0 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.