MIPS_STABS_ELF is now broken

H . J . Lu hjl@lucon.org
Tue Jun 11 13:19:00 GMT 2002
On Tue, Jun 11, 2002 at 01:01:40PM -0700, H . J . Lu wrote:
> 
> But it is not an excuse to break the existing gcc binaries. Here is a
> new patch. It basically treats
> 
> 	.file 1 "foo.c"
> 
> like
> 
> 	.file 1 "foo.c"
> 	.file "foo.c"
> 
> for MIPS_STABS_ELF.
> 

Oops. I left out one ChangeLog entry:

	(dwarf2_finish): Never output dwarf debug info if all_segs
	is NULL.

Is that 100% safe? When do we want to output dwarf debug when all_segs
is NULL? If so, can we do

	if (all_segs == NULL && files_in_use <= 2)
	  return;


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

	* dwarf2dbg.h (dwarf2_directive_file): Return char *.

	* dwarf2dbg.c (dwarf2_directive_file): Return filename.
	(dwarf2_finish): Never output dwarf debug info if all_segs
	is NULL.

	* config/tc-mips.c (s_mips_file): Call elf_file_symbol with
	filename in the first .file directive for MIPS_STABS_ELF.

--- gas/config/tc-mips.c.stabs	Sat Jun  8 20:36:18 2002
+++ gas/config/tc-mips.c	Tue Jun 11 12:54:34 2002
@@ -13372,13 +13372,29 @@ static void
 s_mips_file (x)
      int x ATTRIBUTE_UNUSED;
 {
+  static int first_file_directive;
+
   if (ECOFF_DEBUGGING)
     {
       get_number ();
       s_app_file (0);
     }
   else
-    dwarf2_directive_file (0);
+    {
+      char *filename;
+
+      filename = dwarf2_directive_file (0);
+      /* For the first .file directive we see, we don't know for sure
+	 it is dwarf or stabs. We do both.  */
+      if (! first_file_directive)
+	{
+	  first_file_directive = 1;
+#ifdef MIPS_STABS_ELF
+	  if (filename)
+	    elf_file_symbol (filename);
+#endif
+	}
+    }
 }
 
 /* The .loc directive, implying DWARF-2.  */
--- gas/dwarf2dbg.c.stabs	Thu May 23 08:22:30 2002
+++ gas/dwarf2dbg.c	Tue Jun 11 12:22:34 2002
@@ -346,7 +346,7 @@ get_filenum (filename)
 
 /* Handle the .file directive.  */
 
-void
+char *
 dwarf2_directive_file (dummy)
      int dummy ATTRIBUTE_UNUSED;
 {
@@ -359,7 +359,7 @@ dwarf2_directive_file (dummy)
   if (*input_line_pointer == '"')
     {
       s_app_file (0);
-      return;
+      return NULL;
     }
 
   num = get_absolute_expression ();
@@ -369,13 +369,13 @@ dwarf2_directive_file (dummy)
   if (num < 1)
     {
       as_bad (_("file number less than one"));
-      return;
+      return NULL;
     }
 
   if (num < (int) files_in_use && files[num].filename != 0)
     {
       as_bad (_("file number %ld already allocated"), (long) num);
-      return;
+      return NULL;
     }
 
   if (num >= (int) files_allocated)
@@ -393,6 +393,8 @@ dwarf2_directive_file (dummy)
   files[num].filename = filename;
   files[num].dir = 0;
   files_in_use = num + 1;
+
+  return filename;
 }
 
 void
@@ -1243,7 +1245,7 @@ dwarf2_finish ()
   struct line_seg *s;
 
   /* If no debug information was recorded, nothing to do.  */
-  if (all_segs == NULL && files_in_use <= 1)
+  if (all_segs == NULL)
     return;
 
   /* Calculate the size of an address for the target machine.  */
--- gas/dwarf2dbg.h.stabs	Fri Mar  9 11:16:40 2001
+++ gas/dwarf2dbg.h	Tue Jun 11 12:20:12 2002
@@ -36,7 +36,7 @@ struct dwarf2_line_info {
 /* Implements the .file FILENO "FILENAME" directive.  FILENO can be 0
    to indicate that no file number has been assigned.  All real file
    number must be >0.  */
-extern void dwarf2_directive_file PARAMS ((int dummy));
+extern char *dwarf2_directive_file PARAMS ((int dummy));
 
 /* Implements the .loc FILENO LINENO [COLUMN] directive.  FILENO is
    the file number, LINENO the line number and the (optional) COLUMN


More information about the Binutils mailing list