From: Daniel Jacobowitz <drow@mvista.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: ``set mips abi''
Date: Tue, 18 Jun 2002 14:34:00 -0000 [thread overview]
Message-ID: <20020618213416.GA2881@nevyn.them.org> (raw)
In-Reply-To: <3D0FA494.3040706@cygnus.com>
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
next prev parent reply other threads:[~2002-06-18 21:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-13 11:51 Daniel Jacobowitz
2002-06-18 14:22 ` Andrew Cagney
2002-06-18 14:34 ` Daniel Jacobowitz [this message]
2002-06-18 15:26 ` Andrew Cagney
2002-06-18 15:34 ` Daniel Jacobowitz
2002-06-19 2:00 ` Andreas Schwab
2002-06-19 9:45 ` Daniel Jacobowitz
2002-06-19 11:43 ` Andrew Cagney
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=20020618213416.GA2881@nevyn.them.org \
--to=drow@mvista.com \
--cc=ac131313@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
/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