This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] fix disassembly function for ppc
- From: Elena Zannoni <ezannoni at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 15 Jul 2002 11:08:58 -0400
- Subject: Re: [RFA] fix disassembly function for ppc
- References: <15631.36102.469641.244332@localhost.redhat.com>
I am committing this, after approval from Kevin. (private e-mail).
Elena
Elena Zannoni writes:
>
> If you do
>
> set architecture rs6000
> set architecture powerpc:common
> set architecture rs6000
>
> The disassembly function gets set to the rs6000 one, then changes to the
> powerpc one, but it doesn't get changed back to the rs6000 one with
> the last architecture switch. This is because the rs6000 architecture
> was saved, and instead of being recreated, it is reused.
> The variable print_insn doesn't get to change.
>
> This change creates a new function, gdb_print_insn_powerpc, that is used
> for the powerpc case and deals with the endianness. Note that
> the endiannes is determined by the endiannes of the target at the moment
> the function is called. This keeps into accound the possibility of a user
> doing the 'set endian' command.
>
> Elena
>
> 2002-06-18 Elena Zannoni <ezannoni@redhat.com>
>
> * rs6000-tdep.c (rs6000_gdbarch_init): Remove variable print_insn
> and its setting. Set gdbarch instruction printing functions
> directly. For non-rs6000 case use new function
> gdb_print_insn_powerpc.
> (gdb_print_insn_powerpc): New function.
>
> Index: rs6000-tdep.c
> ===================================================================
> RCS file: /cvs/uberbaum/gdb/rs6000-tdep.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 rs6000-tdep.c
> --- rs6000-tdep.c 17 Jun 2002 23:32:33 -0000 1.68
> +++ rs6000-tdep.c 18 Jun 2002 19:40:25 -0000
> @@ -2402,6 +2402,15 @@ find_variant_by_arch (enum bfd_architect
>
> return NULL;
> }
> +
> +static int
> +gdb_print_insn_powerpc (bfd_vma memaddr, disassemble_info *info)
> +{
> + if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
> + return print_insn_big_powerpc (memaddr, info);
> + else
> + return print_insn_little_powerpc (memaddr, info);
> +}
> ^L
> /* Initialize the current architecture based on INFO. If possible, re-use an
> architecture from ARCHES, which is a list of architectures already created
> @@ -2423,7 +2432,6 @@ rs6000_gdbarch_init (struct gdbarch_info
> bfd abfd;
> int sysv_abi;
> enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
> - gdbarch_print_insn_ftype *print_insn;
>
> from_xcoff_exec = info.abfd && info.abfd->format == bfd_object &&
> bfd_get_flavour (info.abfd) == bfd_target_xcoff_flavour;
> @@ -2558,12 +2566,9 @@ rs6000_gdbarch_init (struct gdbarch_info
>
> /* Select instruction printer. */
> if (arch == power)
> - print_insn = print_insn_rs6000;
> - else if (info.byte_order == BFD_ENDIAN_BIG)
> - print_insn = print_insn_big_powerpc;
> + set_gdbarch_print_insn (gdbarch, print_insn_rs6000);
> else
> - print_insn = print_insn_little_powerpc;
> - set_gdbarch_print_insn (gdbarch, print_insn);
> + set_gdbarch_print_insn (gdbarch, gdb_print_insn_powerpc);
>
> set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
> set_gdbarch_write_pc (gdbarch, generic_target_write_pc);