From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29375 invoked by alias); 18 Jun 2002 21:34:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 29071 invoked from network); 18 Jun 2002 21:34:23 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 18 Jun 2002 21:34:23 -0000 Received: from 01-023.118.popsite.net ([66.19.120.23] helo=nevyn.them.org) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 17KQcE-0003mk-00; Tue, 18 Jun 2002 16:34:19 -0500 Received: from drow by nevyn.them.org with local (Exim 3.35 #1 (Debian)) id 17KQcD-0000nw-00; Tue, 18 Jun 2002 17:34:17 -0400 Date: Tue, 18 Jun 2002 14:34:00 -0000 From: Daniel Jacobowitz To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: ``set mips abi'' Message-ID: <20020618213416.GA2881@nevyn.them.org> Mail-Followup-To: Andrew Cagney , gdb-patches@sources.redhat.com References: <20020613185151.GA352@nevyn.them.org> <3D0FA494.3040706@cygnus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D0FA494.3040706@cygnus.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2002-06/txt/msg00336.txt.bz2 On Tue, Jun 18, 2002 at 05:22:28PM -0400, Andrew Cagney wrote: > >2002-06-13 Daniel Jacobowitz > > > > * mips-tdep.c (enum mips_abi): Explicitly start at 0. > > (mips_abi_string, mips_abi_strings): New. > > (struct gdbarch_tdep): Remove mips_abi_string, add found_abi. > > (mips_gdbarch_init): Set tdep->found_abi. Don't set > > tdep->mips_abi_string. Honor mips_abi_string. Default to > > O32 if no ABI is found. > > (mips_dump_tdep): Use mips_abi_strings. > > (mips_abi_update): New function. > > (_initialize_mips_tdep): Initialize mips_abi_string. Add > > ``set mips abi'' and ``show mips abi''. > > > > I think the way to construct this table: > > >+static const char *mips_abi_string; > >+static const char *mips_abi_strings[] = { > >+ "auto", > >+ "n32", > >+ "o32", > >+ "o64", > >+ "eabi32", > >+ "eabi64", > >+ NULL > >+}; > > is like: > > >/* Various MIPS ISA options (related to stack analysis) can be > > overridden dynamically. Establish an enum/array for managing > > them. */ > > > >static const char size_auto[] = "auto"; > >static const char size_32[] = "32"; > >static const char size_64[] = "64"; > > > >static const char *size_enums[] = { > > size_auto, > > size_32, > > size_64, > > 0 > >}; > > and then: > > >static unsigned int > >mips_saved_regsize (void) > >{ > > if (mips_saved_regsize_string == size_auto) > > return MIPS_DEFAULT_SAVED_REGSIZE; > > else if (mips_saved_regsize_string == size_64) > > return 8; > > else /* if (mips_saved_regsize_string == size_32) */ > > return 4; > >} > > > > That avoids needing to keep the enum and string in sync. If we didn't already have and need the enum all over that file, I'd agree with you. I don't see a point in all the extra globals. But hey, I don't mind. > (Having an enum mechanism that bound a number to a name would be nice). You can do it very easily with designated initializers, but they are not adequately portable. You can do it very easily building the array at runtime but why bother? Keeping two lists in sync is not the most complicated thing in the world. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer