Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: Andrew Cagney <ac131313@redhat.com>
Cc: gdb-patches@sources.redhat.com, binutils@sources.redhat.com
Subject: Re: use MIPS NewABI register names when disassembling NewABI code
Date: Fri, 11 Apr 2003 05:43:00 -0000	[thread overview]
Message-ID: <ord6jtd1y2.fsf@free.redhat.lsd.ic.unicamp.br> (raw)
In-Reply-To: <3E94339A.8030405@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

On Apr  9, 2003, Andrew Cagney <ac131313@redhat.com> wrote:

> An architecture can't point at anything tied to the lifetime of an
> instance of a BFD.

tm_print_insn_info doesn't seem to be very tied to a gdbarch, anyway.
To wit, note the bug fix in this revised patch.  Explicitly setting
the ABI to a non-default one, then back, then the non-default one
again, would result the wrong tm_print_insn_info settings.  This works
now, and also disassembles in accordance with gdb's notion of the
current ABI.  Assuming tm_print_insn_info is actually the right thing
to use, of course.  Ok to install?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mips-gdb-abi-disassemble.patch --]
[-- Type: text/x-patch, Size: 4930 bytes --]

Index: opcodes/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* mips-dis.c (_print_insn_mips): Override reg_names from
	disassembler_options.

Index: opcodes/mips-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/mips-dis.c,v
retrieving revision 1.43
diff -u -p -r1.43 mips-dis.c
--- opcodes/mips-dis.c 8 Apr 2003 07:14:47 -0000 1.43
+++ opcodes/mips-dis.c 11 Apr 2003 05:39:20 -0000
@@ -1157,6 +1157,14 @@ _print_insn_mips (memaddr, info, endiann
     return print_insn_mips16 (memaddr, info);
 #endif
 
+  if (info->disassembler_options)
+    {
+      if (strcmp (info->disassembler_options, "NewABI") == 0)
+	reg_names = mips64_reg_names;
+      else
+	reg_names = mips32_reg_names;
+    }
+
   status = (*info->read_memory_func) (memaddr, buffer, INSNLEN, info);
   if (status == 0)
     {
Index: gdb/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* Makefile.in (libbfd_h): Added missing setting.
	* mips-tdep.c (mips_gdbarch_init): Set disassembler_options
	according to the selected ABI.

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.361
diff -u -p -r1.361 Makefile.in
--- gdb/Makefile.in 10 Apr 2003 13:15:50 -0000 1.361
+++ gdb/Makefile.in 11 Apr 2003 05:39:25 -0000
@@ -574,6 +574,7 @@ elf_sh_h =	$(INCLUDE_DIR)/elf/sh.h
 elf_arm_h =	$(INCLUDE_DIR)/elf/arm.h $(elf_reloc_macros_h)
 elf_bfd_h =	$(BFD_SRC)/elf-bfd.h
 libaout_h =	$(BFD_SRC)/libaout.h
+libbfd_h =	$(BFD_SRC)/libbfd.h
 remote_sim_h =	$(INCLUDE_DIR)/gdb/remote-sim.h
 demangle_h =    $(INCLUDE_DIR)/demangle.h
 obstack_h =     $(INCLUDE_DIR)/obstack.h
Index: gdb/mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.187
diff -u -p -r1.187 mips-tdep.c
--- gdb/mips-tdep.c 8 Apr 2003 19:21:15 -0000 1.187
+++ gdb/mips-tdep.c 11 Apr 2003 05:39:29 -0000
@@ -5731,6 +5731,31 @@ mips_gdbarch_init (struct gdbarch_info i
   if (wanted_abi != MIPS_ABI_UNKNOWN)
     mips_abi = wanted_abi;
 
+  /* We have to set tm_print_insn_info before looking for a
+     pre-existing architecture, otherwise we may return before we get
+     a chance to set it up.  */
+  if (mips_abi == MIPS_ABI_N32 || mips_abi == MIPS_ABI_N64)
+    {
+      /* Set up the disassembler info, so that we get the right
+	 register names from libopcodes.  */
+      tm_print_insn_info.disassembler_options = "NewABI";
+      tm_print_insn_info.flavour = bfd_target_elf_flavour;
+      tm_print_insn_info.arch = bfd_arch_mips;
+      if (info.bfd_arch_info != NULL
+	  && info.bfd_arch_info->arch == bfd_arch_mips
+	  && info.bfd_arch_info->mach)
+	tm_print_insn_info.mach = info.bfd_arch_info->mach;
+      else
+	tm_print_insn_info.mach = bfd_mach_mips8000;
+    }
+  else
+    /* This string is not recognized explicitly by the disassembler,
+       but it tells the disassembler to not try to guess the ABI from
+       the bfd elf headers, such that, if the user overrides the ABI
+       of a program linked as NewABI, the disassembly will follow the
+       register naming conventions specified by the user.  */
+    tm_print_insn_info.disassembler_options = "OldABI";
+
   if (gdbarch_debug)
     {
       fprintf_unfiltered (gdb_stdlog,
@@ -5875,18 +5900,6 @@ mips_gdbarch_init (struct gdbarch_info i
       set_gdbarch_long_bit (gdbarch, 32);
       set_gdbarch_ptr_bit (gdbarch, 32);
       set_gdbarch_long_long_bit (gdbarch, 64);
-
-      /* Set up the disassembler info, so that we get the right
-	 register names from libopcodes.  */
-      tm_print_insn_info.flavour = bfd_target_elf_flavour;
-      tm_print_insn_info.arch = bfd_arch_mips;
-      if (info.bfd_arch_info != NULL
-	  && info.bfd_arch_info->arch == bfd_arch_mips
-	  && info.bfd_arch_info->mach)
-	tm_print_insn_info.mach = info.bfd_arch_info->mach;
-      else
-	tm_print_insn_info.mach = bfd_mach_mips8000;
-
       set_gdbarch_use_struct_convention (gdbarch, 
 					 mips_n32n64_use_struct_convention);
       set_gdbarch_reg_struct_has_addr (gdbarch, 
@@ -5906,18 +5919,6 @@ mips_gdbarch_init (struct gdbarch_info i
       set_gdbarch_long_bit (gdbarch, 64);
       set_gdbarch_ptr_bit (gdbarch, 64);
       set_gdbarch_long_long_bit (gdbarch, 64);
-
-      /* Set up the disassembler info, so that we get the right
-	 register names from libopcodes.  */
-      tm_print_insn_info.flavour = bfd_target_elf_flavour;
-      tm_print_insn_info.arch = bfd_arch_mips;
-      if (info.bfd_arch_info != NULL
-	  && info.bfd_arch_info->arch == bfd_arch_mips
-	  && info.bfd_arch_info->mach)
-	tm_print_insn_info.mach = info.bfd_arch_info->mach;
-      else
-	tm_print_insn_info.mach = bfd_mach_mips8000;
-
       set_gdbarch_use_struct_convention (gdbarch, 
 					 mips_n32n64_use_struct_convention);
       set_gdbarch_reg_struct_has_addr (gdbarch, 

[-- Attachment #3: Type: text/plain, Size: 289 bytes --]


-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

  reply	other threads:[~2003-04-11  5:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-08  2:31 Alexandre Oliva
2003-04-08  7:35 ` Andrew Cagney
2003-04-08 11:59   ` Alexandre Oliva
2003-04-08 21:03     ` Andrew Cagney
2003-04-09  3:45       ` Alexandre Oliva
2003-04-09 13:57         ` Daniel Jacobowitz
2003-04-09 14:52         ` Andrew Cagney
2003-04-11  5:43           ` Alexandre Oliva [this message]
     [not found]             ` <mailpost.1050039798.9718@news-sj1-1>
2003-04-11  6:03               ` cgd
2003-04-11  7:47                 ` Alexandre Oliva
2003-04-11 15:06                   ` Andrew Cagney
2003-04-12  0:31                     ` Alexandre Oliva
2003-04-28 21:13                       ` 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=ord6jtd1y2.fsf@free.redhat.lsd.ic.unicamp.br \
    --to=aoliva@redhat.com \
    --cc=ac131313@redhat.com \
    --cc=binutils@sources.redhat.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