PATCH: Fix mips debug (Re: MIPS_STABS_ELF is now broken)

H . J . Lu hjl@lucon.org
Thu Jun 13 10:05:00 GMT 2002


On Thu, Jun 13, 2002 at 09:04:02AM -0700, H . J . Lu wrote:
> On Thu, Jun 13, 2002 at 11:49:11AM -0400, Daniel Jacobowitz wrote:
> > > 
> > > I am having the second thought. The gas change is too big for me. May
> > > I propose to do these:
> > > 
> > > 1. Modify the mips gas to take either
> > > 
> > > 	.file "foo.c"
> > > or
> > > 
> > > 	.file 1 "foo.c"
> > > 
> > > as the first line for stabs, dwarf and mdebug.
> > > 
> > > 2. Modify gcc 3 to emit
> > > 
> > > 	.file "foo.c"
> > > 
> > > as the first line for stabs, dwarf and mdebug.
> > > 
> > > In this way, the new gas will still work with the existing compiler
> > > and the dwarf/stabs output will be very similar to x86. That means you
> > > have to use the new gas for gcc 3. I will post my gas/gcc changes
> > > shortly.
> > 
> > What advantage do you claim this has over the patches I posted (which
> 
> My gas change will be very small and the dwarf/stabs asm output will be
> very similar to x86, which is well tested.
> 
> > have already gone in on the GCC side, and which do not make GCC3
> > require a new binutils version for stabs output)?
> 
> What is wrong to require a new binutils for a new gcc? Also if you do
> 
> # .../configure
> # make bootstrap
> 
> you will need a new binutils for mips anyway.
> 
> > 
> > Also, your patch will be incompatible with traditional MIPS assemblers
> > and their use of .file.  All the world is not GNU as!
> > 
> 
> You haven't seen my gcc patch. How do you know it isn't compatible
> with non gas?

Here are 2 patches for mips debug, one for gas and the other for gcc.


H.J.
-------------- next part --------------
2002-06-13  H.J. Lu <hjl@gnu.org>

	* config/mips/mips.h (ASM_OUTPUT_FILENAME): Add FIRST. Don't
	emit the file number for GAS if FIRST is not zero.

	* config/mips/iris6.h (ASM_OUTPUT_FILENAME): Add FIRST.

	* config/mips/mips.c (mips_output_filename): Always emit the
	first .file directive. Pass first_time as FIRST to
	ASM_OUTPUT_FILENAME.

--- gcc/config/mips/iris6.h.gas	Wed Jun 12 11:18:50 2002
+++ gcc/config/mips/iris6.h	Thu Jun 13 09:35:17 2002
@@ -369,7 +369,7 @@ current_section_flags ()						\
    Sometimes as succeeds, but then we get a linker error. (cmds.c in 072.sc)
    Getting rid of .file solves both problems.  */
 #undef ASM_OUTPUT_FILENAME
-#define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
+#define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME, FIRST) \
 do								\
   {								\
     fprintf (STREAM, "\t#.file\t%d ", NUM_SOURCE_FILENAMES);	\
--- gcc/config/mips/mips.c.gas	Wed Jun 12 11:09:56 2002
+++ gcc/config/mips/mips.c	Thu Jun 13 09:36:31 2002
@@ -5916,19 +5916,15 @@ mips_output_filename (stream, name)
   static int first_time = 1;
   char ltext_label_name[100];
 
-  /* If we are emitting DWARF-2, let dwarf2out handle the ".file"
-     directives.  */
-  if (write_symbols == DWARF2_DEBUG)
-    return;
-  else if (first_time)
+  if (first_time)
     {
-      first_time = 0;
       SET_FILE_NUMBER ();
       current_function_file = name;
-      ASM_OUTPUT_FILENAME (stream, num_source_filenames, name);
+      ASM_OUTPUT_FILENAME (stream, num_source_filenames, name, first_time);
       /* This tells mips-tfile that stabs will follow.  */
       if (!TARGET_GAS && write_symbols == DBX_DEBUG)
 	fprintf (stream, "\t#@stabs\n");
+      first_time = 0;
     }
 
   else if (write_symbols == DBX_DEBUG)
@@ -5955,7 +5951,7 @@ mips_output_filename (stream, name)
 	{
 	  SET_FILE_NUMBER ();
 	  current_function_file = name;
-	  ASM_OUTPUT_FILENAME (stream, num_source_filenames, name);
+	  ASM_OUTPUT_FILENAME (stream, num_source_filenames, name, first_time);
 	}
     }
 }
--- gcc/config/mips/mips.h.gas	Wed Jun 12 11:18:50 2002
+++ gcc/config/mips/mips.h	Thu Jun 13 09:34:48 2002
@@ -4330,10 +4330,13 @@ while (0)
   mips_output_filename (STREAM, NAME)
 
 /* This is defined so that it can be overridden in iris6.h.  */
-#define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
+#define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME, FIRST) \
 do								\
   {								\
-    fprintf (STREAM, "\t.file\t%d ", NUM_SOURCE_FILENAMES);	\
+    if (TARGET_GAS && FIRST)					\
+      fputs ("\t.file\t", STREAM);				\
+    else							\
+      fprintf (STREAM, "\t.file\t%d ", NUM_SOURCE_FILENAMES);	\
     output_quoted_string (STREAM, NAME);			\
     fputs ("\n", STREAM);					\
   }								\
-------------- next part --------------
2002-06-13  H.J. Lu <hjl@gnu.org>

	* config/tc-mips.c (s_mips_file): Take the first .file
	directive with or without a number. Always pass the rest to
	dwarf2_directive_file.

--- gas/config/tc-mips.c.stabs	Sat Jun  8 20:36:18 2002
+++ gas/config/tc-mips.c	Thu Jun 13 09:15:39 2002
@@ -13372,10 +13372,19 @@ static void
 s_mips_file (x)
      int x ATTRIBUTE_UNUSED;
 {
-  if (ECOFF_DEBUGGING)
+  static int first_file_directive;
+
+  if (! first_file_directive)
     {
-      get_number ();
+      /* The first .file directive may or may not have a number. We try
+	 both.  */
+
+      SKIP_WHITESPACE ();
+      if (*input_line_pointer != '"')
+	get_number ();
       s_app_file (0);
+
+      first_file_directive = 1;
     }
   else
     dwarf2_directive_file (0);


More information about the Binutils mailing list