This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: ``set mips abi''


On Tue, Jun 18, 2002 at 05:22:28PM -0400, Andrew Cagney wrote:
> >2002-06-13  Daniel Jacobowitz  <drow@mvista.com>
> >
> >	* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]