re PR debug/20253 (Macro debug info broken due to lexer change)
authorDaniel Berlin <dberlin@dberlin.org>
Fri, 4 Mar 2005 03:08:10 +0000 (03:08 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Fri, 4 Mar 2005 03:08:10 +0000 (03:08 +0000)
2005-03-03  Daniel Berlin <dberlin@dbrelin.org>

Fix PR debug/20253

* c-opts.c (c_common_parse_file): Call start_source_file
and end_source_file at the approriate times.

* dwarf2out.c (dwarf2out_finish): Don't auto-end
the main file, it will be done for us now.

From-SVN: r95872

gcc/ChangeLog
gcc/c-opts.c
gcc/dwarf2out.c
gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2-macro.c [new file with mode: 0644]

index 23672a3486cd93979f089886edab1a909e924c94..b6765aca02cbf346ce2ac8a7b6c5d85b5b09a992 100644 (file)
@@ -1,3 +1,13 @@
+2005-03-03  Daniel Berlin <dberlin@dbrelin.org>
+
+       Fix PR debug/20253
+       
+       * c-opts.c (c_common_parse_file): Call start_source_file
+       and end_source_file at the approriate times.
+
+       * dwarf2out.c (dwarf2out_finish): Don't auto-end
+       the main file, it will be done for us now.
+       
 2005-03-04  Kazu Hirata  <kazu@cs.umass.edu>
 
        * fold-const.c (fold_ternary): New.
index 575ff4d485b72cc0754097f1be94ff36309f0510..d2abeb527b6e7f0cd8f398839520c4b27f95e2f1 100644 (file)
@@ -1089,13 +1089,16 @@ c_common_parse_file (int set_yydebug)
   i = 0;
   for (;;)
     {
+      /* Start the main input file */
+      (*debug_hooks->start_source_file) (0, this_input_filename);
       finish_options ();
       pch_init ();
       push_file_scope ();
       c_parse_file ();
       finish_file ();
       pop_file_scope ();
-
+      /* And end the main input file. */
+      (*debug_hooks->end_source_file) (0);
       if (++i >= num_in_fnames)
        break;
       cpp_undef_all (parse_in);
index 76661ba6d8b78d19341ed23935f4bff39ca9b965..5157ae358bcc2a8180efbdb3b15c99c4340340f1 100644 (file)
@@ -10497,8 +10497,12 @@ add_abstract_origin_attribute (dw_die_ref die, tree origin)
 
       if (TYPE_P (fn))
        fn = TYPE_STUB_DECL (fn);
+      
+      /* TYPE_STUB_DECL may have given us a NULL, which decl_function_context
+        won't like.  */
+      if (fn)  
+       fn = decl_function_context (fn);
 
-      fn = decl_function_context (fn);
       if (fn)
        dwarf2out_abstract_function (fn);
     }
@@ -13795,11 +13799,10 @@ dwarf2out_finish (const char *filename)
       output_ranges ();
     }
 
-  /* Have to end the primary source file.  */
+  /* Have to end the macro section.  */
   if (debug_info_level >= DINFO_LEVEL_VERBOSE)
     {
       named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
-      dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
       dw2_asm_output_data (1, 0, "End compilation unit");
     }
 
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2-macro.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2-macro.c
new file mode 100644 (file)
index 0000000..45e9373
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test to make sure the mcaro info includes a start file command for the main source */
+/* { dg-do compile */
+/* { dg-options "-g3 -gdwarf-2 -dA -fverbose-asm" } */
+/* { dg-final { scan-assembler "Start new file" } } */
+
+#define ADD(x) (M + x)
+
+int main (void)
+{
+#define N 28
+#define M 42
+   return ADD(N);
+}