Re: use MIPS NewABI register names when disassembling NewABI code

Andrew Cagney
2003-04-08T07:35:53Z

> mips-opc.c:_print_insn_mips decides which register naming convention
> to use obtaining a pointer to the bfd from the first symbol in the
> symbols field from the disassemble_info argument, and then looking for
> ABI information in the ELF headers. Unfortunately, gdb doesn't set up
> symbols, so we end up always using the o32 register naming
> convention. This patch arranges for the information the disassembler
> uses to be passed to it, in an admittedly ugly, but effective way.

Ugly? This bit:
> + static asymbol *symbols = NULL;
is wrong. There is more than one instance of an architecture. The
symbols lifetime is different to that of the architecture (assuming that
the symbol's lifetime is tied to the corresponding bfd).

How does objdump manage to correctly disassemble something like an
srecord? GDB should be using that same mechanism.

Andrew

> Index: gdb/ChangeLog
> from Alexandre Oliva <aoliva@redhat.com>
>
> * mips-tdep.c (mips_gdbarch_init): Set tm_print_insn_info.symbols
> to at least an empty symbol.
>
> Index: gdb/mips-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mips-tdep.c,v
> retrieving revision 1.185
> diff -u -p -r1.185 mips-tdep.c
> --- gdb/mips-tdep.c 7 Apr 2003 18:38:04 -0000 1.185
> +++ gdb/mips-tdep.c 8 Apr 2003 02:26:04 -0000
> @@ -5656,6 +5656,24 @@ mips_gdbarch_init (struct gdbarch_info i
>
> if (info.abfd)
> {
> + static asymbol *symbols = NULL;
> +
> + /* The disassembler uses *info.symbols to get to the bfd elf
> + flags, which it uses to tell the executable ABI, so we have
> + to give it at least one symbol. */
> + if (tm_print_insn_info.symbols == NULL
> + || tm_print_insn_info.symbols == &symbols)
> + {
> + /* It would be nice if we could bfd_release the previous
> + symbol, but we'd need a pointer to its bfd then. */
> + symbols = bfd_make_empty_symbol (info.abfd);
> + if (symbols != NULL)
> + {
> + tm_print_insn_info.symbols = &symbols;
> + tm_print_insn_info.num_symbols = 0;
> + }
> + }
> +
> /* First of all, extract the elf_flags, if available. */
> if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
> elf_flags = elf_elfheader (info.abfd)->e_flags;
>
>