This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix up .debug_macinfo


Hi!

The DWARF3 standard in 6.3.3 (and DWARF4 too, in the same section) say
that DW_MACINFO_{define,undef} macinfo entries for predefined macros
and macros defined on the command line should precede the first
DW_MACINFO_start_file entry (and should have line number 0).
GCC emits them after DW_MACINFO_start_file though.

The following patch fixes it.  GDB older than 7.0 doesn't handle it
well, but in GCC 4.5 GDB 7.0 or later is needed anyway to debug code,
otherwise line info isn't parsed well, there are problems with epilogue
unwinding etc.

Ok for trunk?

2010-04-28  Jakub Jelinek  <jakub@redhat.com>

	* c-opts.c (c_common_parse_file): If start_end_main_source_file,
	don't call start_source_file debug hook here...
	(finish_options): ... but here, after outputting predefined and
	command line defines and undefs.

--- gcc/c-opts.c.jj	2009-01-28 12:57:50.000000000 +0100
+++ gcc/c-opts.c	2009-02-11 13:55:47.000000000 +0100
@@ -1239,9 +1239,6 @@ c_common_parse_file (int set_yydebug)
   i = 0;
   for (;;)
     {
-      /* Start the main input file, if the debug writer wants it. */
-      if (debug_hooks->start_end_main_source_file)
-	(*debug_hooks->start_source_file) (0, this_input_filename);
       finish_options ();
       pch_init ();
       push_file_scope ();
@@ -1498,6 +1495,11 @@ finish_options (void)
 	    }
 	}
 
+      /* Start the main input file, if the debug writer wants it. */
+      if (debug_hooks->start_end_main_source_file
+	  && !flag_preprocess_only)
+	(*debug_hooks->start_source_file) (0, this_input_filename);
+
       /* Handle -imacros after -D and -U.  */
       for (i = 0; i < deferred_count; i++)
 	{
@@ -1512,8 +1514,16 @@ finish_options (void)
 	    }
 	}
     }
-  else if (cpp_opts->directives_only)
-    cpp_init_special_builtins (parse_in);
+  else
+    {
+      if (cpp_opts->directives_only)
+	cpp_init_special_builtins (parse_in);
+
+      /* Start the main input file, if the debug writer wants it. */
+      if (debug_hooks->start_end_main_source_file
+	  && !flag_preprocess_only)
+	(*debug_hooks->start_source_file) (0, this_input_filename);
+    }
 
   include_cursor = 0;
   push_command_line_include ();


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]