Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Fred Fish <fnf@specifix.com>
To: Richard Sandiford <richard@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org, gdb-patches@sourceware.org, 	fnf@specifix.com
Subject: Re: [RFC] Passing MIPS debug hints between gcc and gdb
Date: Mon, 12 Jun 2006 10:10:00 -0000	[thread overview]
Message-ID: <200606120611.32335.fnf@specifix.com> (raw)
In-Reply-To: <87y7x9aw12.fsf@talisman.home>

On Thursday 11 May 2006 02:57, Richard Sandiford wrote:

> Since both EABI and o64 are basically GNU inventions, I'd be OK with
> relaxing the condition to EABI || o64 if it's o64 you need this for.

OK, here is a gcc patch to do that, and a matching gdb patch to use 
it.

If the gcc patch is approved, please check it in as I don't currently
have gcc write access.

-Fred


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2006-06-12  Fred Fish  <fnf@specifix.com>

	* config/mips/mips.c (mips_file_start): Create special section
	".gcc_compiled_longXX" for o64 ABI as well as EABI.

Index: config/mips/mips.c
===================================================================
RCS file: /cvsroots/latest/src/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.1.1.9
diff -u -p -r1.1.1.9 mips.c
--- config/mips/mips.c	11 May 2006 18:41:03 -0000	1.1.1.9
+++ config/mips/mips.c	11 Jun 2006 18:01:07 -0000
@@ -5831,7 +5831,8 @@ mips_file_start (void)
       /* There is no ELF header flag to distinguish long32 forms of the
 	 EABI from long64 forms.  Emit a special section to help tools
 	 such as GDB.  */
-      if (mips_abi == ABI_EABI)
+      if (mips_abi == ABI_EABI
+	  || mips_abi == ABI_O64)
 	fprintf (asm_out_file, "\t.section .gcc_compiled_long%d\n",
 		 TARGET_LONG64 ? 64 : 32);
 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


2006-06-12  Fred Fish  <fnf@specifix.com>

	* mips-tdep.c (mips_find_long_section): New function.
	(mips_gdbarch_init): Use it to set long and pointer sizes.

Index: mips-tdep.c
===================================================================
RCS file: /cvsroots/latest/src/gdb/gdb/mips-tdep.c,v
retrieving revision 1.1.1.8
diff -c -p -r1.1.1.8 mips-tdep.c
*** mips-tdep.c	10 Jun 2006 03:32:42 -0000	1.1.1.8
--- mips-tdep.c	11 Jun 2006 18:11:09 -0000
*************** mips_find_abi_section (bfd *abfd, asecti
*** 4690,4695 ****
--- 4690,4709 ----
      warning (_("unsupported ABI %s."), name + 8);
  }
  
+ static void
+ mips_find_long_section (bfd *abfd, asection *sect, void *obj)
+ {
+   int *lbp = (int *) obj;
+   const char *name = bfd_get_section_name (abfd, sect);
+ 
+   if (strncmp (name, ".gcc_compiled_long32", 20) == 0)
+     *lbp = 32;
+   else if (strncmp (name, ".gcc_compiled_long64", 20) == 0)
+     *lbp = 64;
+   else if (strncmp (name, ".gcc_compiled_long", 18) == 0)
+     warning (_("unrecognized .gcc_compiled_longXX"));
+ }
+ 
  static enum mips_abi
  global_mips_abi (void)
  {
*************** mips_gdbarch_init (struct gdbarch_info i
*** 5009,5014 ****
--- 5023,5080 ----
        internal_error (__FILE__, __LINE__, _("unknown ABI in switch"));
      }
  
+   /* GCC creates a pseudo-section whose name specifies the size of
+      longs, since -mlong32 or -mlong64 may be used independent of
+      other options.  How those options affect pointer sizes is ABI and
+      architecture dependent, so use them to override the default sizes
+      set by the ABI.  This table shows the relationship between ABI,
+      -mlongXX, and size of pointers:
+ 
+      ABI		-mlongXX	ptr bits
+      ---		--------	--------
+      o32		32		32
+      o32		64		32
+      n32		32		32
+      n32		64		64
+      o64		32		32
+      o64		64		64
+      n64		32		32
+      n64		64		64
+      eabi32		32		32
+      eabi32		64		32
+      eabi64		32		32
+      eabi64		64		64
+ 
+     Note that for o32 and eabi32, pointers are always 32 bits
+     regardless of any -mlongXX option.  For all others, pointers and
+     longs are the same, as set by -mlongXX or set by defaults.
+  */
+ 
+   if (info.abfd != NULL)
+     {
+       int long_bit = 0;
+ 
+       bfd_map_over_sections (info.abfd, mips_find_long_section, &long_bit);
+       if (long_bit)
+ 	{
+ 	  set_gdbarch_long_bit (gdbarch, long_bit);
+ 	  switch (mips_abi)
+ 	    {
+ 	    case MIPS_ABI_O32:
+ 	    case MIPS_ABI_EABI32:
+ 	      break;
+ 	    case MIPS_ABI_N32:
+ 	    case MIPS_ABI_O64:
+ 	    case MIPS_ABI_N64:
+ 	    case MIPS_ABI_EABI64:
+ 	      set_gdbarch_ptr_bit (gdbarch, long_bit);
+ 	      break;
+ 	    default:
+ 	      internal_error (__FILE__, __LINE__, _("unknown ABI in switch"));
+ 	    }
+ 	}
+     }
+ 
    /* FIXME: jlarmour/2000-04-07: There *is* a flag EF_MIPS_32BIT_MODE
       that could indicate -gp32 BUT gas/config/tc-mips.c contains the
       comment:


  parent reply	other threads:[~2006-06-12 10:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-10 16:05 Fred Fish
2006-05-11  6:57 ` Richard Sandiford
2006-05-11 10:16   ` Fred Fish
2006-05-17 20:32   ` Fred Fish
2006-05-18  0:04     ` Mark Mitchell
2006-05-18 16:53       ` Richard Sandiford
2006-06-12 10:10   ` Fred Fish [this message]
2006-06-12 11:07     ` Richard Sandiford
2006-06-13 16:08     ` Fred Fish
2006-06-13 17:42       ` Daniel Jacobowitz

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=200606120611.32335.fnf@specifix.com \
    --to=fnf@specifix.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=richard@codesourcery.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