[committed] MIPS: Define aliases for MSYMBOL_TARGET_FLAG macros

Maciej W. Rozycki
2014-12-12T16:38:52Z

On Mon, 6 Oct 2014, Maciej W. Rozycki wrote:

> > Just some minor comments below:
> >
> > > gdb-mips16-isa-bit.diff
> > > Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
> > > ===================================================================
> > > --- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c 2012-05-14 16:00:33.000000000 +0100
> > > +++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c 2012-05-14 16:02:02.235560558 +0100
> > > @@ -358,9 +358,15 @@ mips_elf_make_msymbol_special (asymbol *
> > > return;
> > >
> > > if (ELF_ST_IS_MICROMIPS (elfsym->internal_elf_sym.st_other))
> > > - MSYMBOL_TARGET_FLAG_2 (msym) = 1;
> > > + {
> > > + MSYMBOL_TARGET_FLAG_2 (msym) = 1;
> > > + SYMBOL_VALUE_ADDRESS (msym) |= 1;
> > > + }
> > > else if (ELF_ST_IS_MIPS16 (elfsym->internal_elf_sym.st_other))
> > > - MSYMBOL_TARGET_FLAG_1 (msym) = 1;
> > > + {
> > > + MSYMBOL_TARGET_FLAG_1 (msym) = 1;
> > > + SYMBOL_VALUE_ADDRESS (msym) |= 1;
> > > + }
> >
> > This remark is not to be considered as part of this patch's review,
> > since this is already an established practice, but I think we could do
> > better than using magic numbers for those flags. I understand they have
> > to be that way in the common code, but perhaps mips-tdep could define
> > aliases? Something like MSYMBOL_MIPS_TARGET_FLAG_BLAH?
>
> Good point, I'll push such a change as a followup; I have it ready now.

I have committed this change now.

2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>

gdb/
* mips-tdep.h (MSYMBOL_TARGET_FLAG_MIPS16): New macro.
(MSYMBOL_TARGET_FLAG_MICROMIPS): Likewise.
* mips-tdep.c (mips_elf_make_msymbol_special): Use the new
macros.
(msymbol_is_mips, msymbol_is_mips16, msymbol_is_micromips):
Likewise.

Maciej

gdb-mips-msymbol-target-flag.diff
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c 2014-10-03 14:50:26.398945943 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c 2014-10-03 14:50:26.398945943 +0100
@@ -379,12 +379,12 @@ mips_elf_make_msymbol_special (asymbol *

if (ELF_ST_IS_MICROMIPS (st_other))
{
- MSYMBOL_TARGET_FLAG_2 (msym) = 1;
+ MSYMBOL_TARGET_FLAG_MICROMIPS (msym) = 1;
SET_MSYMBOL_VALUE_ADDRESS (msym, MSYMBOL_VALUE_RAW_ADDRESS (msym) | 1);
}
else if (ELF_ST_IS_MIPS16 (st_other))
{
- MSYMBOL_TARGET_FLAG_1 (msym) = 1;
+ MSYMBOL_TARGET_FLAG_MIPS16 (msym) = 1;
SET_MSYMBOL_VALUE_ADDRESS (msym, MSYMBOL_VALUE_RAW_ADDRESS (msym) | 1);
}
}
@@ -394,7 +394,8 @@ mips_elf_make_msymbol_special (asymbol *
static int
msymbol_is_mips (struct minimal_symbol *msym)
{
- return !(MSYMBOL_TARGET_FLAG_1 (msym) | MSYMBOL_TARGET_FLAG_2 (msym));
+ return !(MSYMBOL_TARGET_FLAG_MIPS16 (msym)
+ | MSYMBOL_TARGET_FLAG_MICROMIPS (msym));
}

/* Return one iff MSYM refers to MIPS16 code. */
@@ -402,7 +403,7 @@ msymbol_is_mips (struct minimal_symbol *
static int
msymbol_is_mips16 (struct minimal_symbol *msym)
{
- return MSYMBOL_TARGET_FLAG_1 (msym);
+ return MSYMBOL_TARGET_FLAG_MIPS16 (msym);
}

/* Return one iff MSYM refers to microMIPS code. */
@@ -410,7 +411,7 @@ msymbol_is_mips16 (struct minimal_symbol
static int
msymbol_is_micromips (struct minimal_symbol *msym)
{
- return MSYMBOL_TARGET_FLAG_2 (msym);
+ return MSYMBOL_TARGET_FLAG_MICROMIPS (msym);
}

/* Set the ISA bit in the main symbol too, complementing the corresponding
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.h
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.h 2014-10-03 14:50:26.398945943 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.h 2014-10-03 14:50:26.398945943 +0100
@@ -48,6 +48,10 @@ enum mips_isa
ISA_MICROMIPS
};

+/* Corresponding MSYMBOL_TARGET_FLAG aliases. */
+#define MSYMBOL_TARGET_FLAG_MIPS16 MSYMBOL_TARGET_FLAG_1
+#define MSYMBOL_TARGET_FLAG_MICROMIPS MSYMBOL_TARGET_FLAG_2
+
/* Return the MIPS ISA's register size. Just a short cut to the BFD
architecture's word size. */
extern int mips_isa_regsize (struct gdbarch *gdbarch);