Restore DW_AT_abstract_origin for cross-unit call sites
authorPierre-Marie de Rodat <derodat@adacore.com>
Thu, 11 Jun 2015 12:40:10 +0000 (12:40 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Thu, 11 Jun 2015 12:40:10 +0000 (12:40 +0000)
PR debug/66503

gcc/ChangeLog:
* debug.h (struct gcc_debug_hooks): Add a
register_main_translation_unit hook.
* debug.c (do_nothing_debug_hooks): Provide a function for this
new hook.
* dbxout.c (dbx_debug_hooks): Likewise.
* sdbout.c (sdb_debug_hooks): Likewise.
* vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
* dwarf2out.c (main_translation_unit): New global variable.
(dwarf2out_register_main_translation_unit): New function
implementing the new hook.
(dwarf2_debug_hooks): Assign
dwarf2out_register_main_translation_unit to this new hook.
(dwarf2out_init): Associate any main translation unit to
comp_unit_die ().
* c/c-decl.c (pop_scope): Register the main translation unit
through the new debug hook.
* cp/decl.c (cxx_init_decl_processing): Likewise.

gcc/ada/ChangeLog:
* gcc-interface/utils.c (get_global_context): Register the main
translation unit through the new debug hook.

gcc/fortran/ChangeLog:
* f95-lang.c (gfc_create_decls): Register the main translation
unit through the new debug hook.

From-SVN: r224371

13 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils.c
gcc/c/c-decl.c
gcc/cp/decl.c
gcc/dbxout.c
gcc/debug.c
gcc/debug.h
gcc/dwarf2out.c
gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/sdbout.c
gcc/vmsdbgout.c

index 6327ef5aeff14af821ecaa6ec8d4cc24e1206c29..902f708140bef336ba8e0d98b3675c58b9fa2d2b 100644 (file)
@@ -1,3 +1,23 @@
+2015-06-11  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * debug.h (struct gcc_debug_hooks): Add a
+       register_main_translation_unit hook.
+       * debug.c (do_nothing_debug_hooks): Provide a function for this
+       new hook.
+       * dbxout.c (dbx_debug_hooks): Likewise.
+       * sdbout.c (sdb_debug_hooks): Likewise.
+       * vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
+       * dwarf2out.c (main_translation_unit): New global variable.
+       (dwarf2out_register_main_translation_unit): New function
+       implementing the new hook.
+       (dwarf2_debug_hooks): Assign
+       dwarf2out_register_main_translation_unit to this new hook.
+       (dwarf2out_init): Associate any main translation unit to
+       comp_unit_die ().
+       * c/c-decl.c (pop_scope): Register the main translation unit
+       through the new debug hook.
+        * cp/decl.c (cxx_init_decl_processing): Likewise.
+
 2015-06-11  Marek Polacek  <polacek@redhat.com>
 
        * match.pd ((x & y) ^ (x | y) -> x ^ y): New pattern.
index ad509e0c009861d750ca10d92f8b9a398618bd25..4eeb13e4844fdf096e920771e8b7b471b10ec965 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-11  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * gcc-interface/utils.c (get_global_context): Register the main
+       translation unit through the new debug hook.
+
 2015-06-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/misc.c: Remove duplicate include directives.
index 9076529e05b3406a482444e6502a89af9f532dbf..655bfa1b8d50ba19b276fda240f3e21024e71295 100644 (file)
@@ -667,7 +667,10 @@ static tree
 get_global_context (void)
 {
   if (!global_context)
-    global_context = build_translation_unit_decl (NULL_TREE);
+    {
+      global_context = build_translation_unit_decl (NULL_TREE);
+      debug_hooks->register_main_translation_unit (global_context);
+    }
   return global_context;
 }
 
index 7fd662d34f357a41cf59139982d34f9b0f64eb07..3fde22fba94831bccbb9d36b17c811a052c4786a 100644 (file)
@@ -1196,6 +1196,7 @@ pop_scope (void)
     {
       tree file_decl = build_translation_unit_decl (NULL_TREE);
       context = file_decl;
+      debug_hooks->register_main_translation_unit (file_decl);
     }
   else
     context = block;
index 3bed53826002151e7951ed9a8ee534bcc1e38fef..ffd068aadebe0e6e2bcfcb6984576dfe04ad5850 100644 (file)
@@ -3831,6 +3831,8 @@ cxx_init_decl_processing (void)
   global_namespace = build_lang_decl (NAMESPACE_DECL, global_scope_name,
                                      void_type_node);
   DECL_CONTEXT (global_namespace) = build_translation_unit_decl (NULL_TREE);
+  debug_hooks->register_main_translation_unit
+    (DECL_CONTEXT (global_namespace));
   TREE_PUBLIC (global_namespace) = 1;
   begin_scope (sk_namespace, global_namespace);
 
index 48b5065e615569d47542af3347cac3c6ed08267b..94fac4273b1686679b942c13549277ee048b32c0 100644 (file)
@@ -380,6 +380,7 @@ const struct gcc_debug_hooks dbx_debug_hooks =
   debug_nothing_tree,                   /* begin_function */
 #endif
   debug_nothing_int,                    /* end_function */
+  debug_nothing_tree,                   /* register_main_translation_unit */
   dbxout_function_decl,
   dbxout_early_global_decl,             /* early_global_decl */
   dbxout_late_global_decl,              /* late_global_decl */
index 9c621f82884d44937da1a844910f88f9c23083b9..ab92cc870cb4daf0f1e8784d5df25b38b3a82953 100644 (file)
@@ -46,6 +46,7 @@ const struct gcc_debug_hooks do_nothing_debug_hooks =
   debug_nothing_int_charstar,           /* end_epilogue */
   debug_nothing_tree,                   /* begin_function */
   debug_nothing_int,                    /* end_function */
+  debug_nothing_tree,                   /* register_main_translation_unit */
   debug_nothing_tree,                   /* function_decl */
   debug_nothing_tree,                   /* early_global_decl */
   debug_nothing_tree,                   /* late_global_decl */
index e7e1334c1549b74344f8e98d729bdd6875b1c2bd..269c4d83f171da31a124e771e7f2bb6f86775c7a 100644 (file)
@@ -89,6 +89,10 @@ struct gcc_debug_hooks
   /* Record end of function.  LINE is highest line number in function.  */
   void (* end_function) (unsigned int line);
 
+  /* Register UNIT as the main translation unit.  Called from front-ends when
+     they create their main translation unit.  */
+  void (* register_main_translation_unit) (tree);
+
   /* Debug information for a function DECL.  This might include the
      function name (a symbol), its parameters, and the block that
      makes up the function's body, and the local variables of the
index ee2bcb11a3b06e82dfb9054339a23c17ff77c5b9..8a36fe8db355b9f151415f7031a53e6af1248b54 100644 (file)
@@ -2446,6 +2446,7 @@ static void dwarf2out_abstract_function (tree);
 static void dwarf2out_var_location (rtx_insn *);
 static void dwarf2out_begin_function (tree);
 static void dwarf2out_end_function (unsigned int);
+static void dwarf2out_register_main_translation_unit (tree unit);
 static void dwarf2out_set_name (tree, tree);
 
 /* The debug hooks structure.  */
@@ -2475,6 +2476,7 @@ const struct gcc_debug_hooks dwarf2_debug_hooks =
   dwarf2out_end_epilogue,
   dwarf2out_begin_function,
   dwarf2out_end_function,      /* end_function */
+  dwarf2out_register_main_translation_unit,
   dwarf2out_function_decl,     /* function_decl */
   dwarf2out_early_global_decl,
   dwarf2out_late_global_decl,
@@ -22505,6 +22507,26 @@ dwarf2out_end_function (unsigned int)
   maybe_at_text_label_p = false;
 }
 
+/* Temporary holder for dwarf2out_register_main_translation_unit.  Used to let
+   front-ends register a translation unit even before dwarf2out_init is
+   called.  */
+static tree main_translation_unit = NULL_TREE;
+
+/* Hook called by front-ends after they built their main translation unit.
+   Associate comp_unit_die to UNIT.  */
+
+static void
+dwarf2out_register_main_translation_unit (tree unit)
+{
+  gcc_assert (TREE_CODE (unit) == TRANSLATION_UNIT_DECL
+             && main_translation_unit == NULL_TREE);
+  main_translation_unit = unit;
+  /* If dwarf2out_init has not been called yet, it will perform the association
+     itself looking at main_translation_unit.  */
+  if (decl_die_table != NULL)
+    equate_decl_number_to_die (unit, comp_unit_die ());
+}
+
 /* Add OPCODE+VAL as an entry at the end of the opcode array in TABLE.  */
 
 static void
@@ -23242,6 +23264,11 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
   /* Make sure the line number table for .text always exists.  */
   text_section_line_info = new_line_info_table ();
   text_section_line_info->end_label = text_end_label;
+
+  /* If front-ends already registered a main translation unit but we were not
+     ready to perform the association, do this now.  */
+  if (main_translation_unit != NULL_TREE)
+    equate_decl_number_to_die (main_translation_unit, comp_unit_die ());
 }
 
 /* Called before compile () starts outputtting functions, variables
index d77cc1a43951c2dce561c1164f75a1d4ff9f4702..57a9997ad90bdb784a0ce97058bf11ee836ecd73 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-11  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * f95-lang.c (gfc_create_decls): Register the main translation unit
+       through the new debug hook.
+
 2015-06-08  Andrew MacLeod  <amacleod@redhat.com>
 
        * convert.c : Adjust include files.
index 6daac8399b65e0e6634fb8ed6533c5f610ad9102..2c055f59d3d950abd0e4e52d1302d8ce72aebe86 100644 (file)
@@ -204,6 +204,7 @@ gfc_create_decls (void)
 
   /* Build our translation-unit decl.  */
   current_translation_unit = build_translation_unit_decl (NULL_TREE);
+  debug_hooks->register_main_translation_unit (current_translation_unit);
 }
 
 
index f5671c65315b37ce35a9bf76349f2a54f7f25ba3..033886a675e8ba3635a35c856b1cb998ea831c1b 100644 (file)
@@ -296,6 +296,7 @@ const struct gcc_debug_hooks sdb_debug_hooks =
   sdbout_end_epilogue,                  /* end_epilogue */
   sdbout_begin_function,                /* begin_function */
   sdbout_end_function,                  /* end_function */
+  debug_nothing_tree,                   /* register_main_translation_unit */
   debug_nothing_tree,                   /* function_decl */
   sdbout_early_global_decl,             /* early_global_decl */
   sdbout_late_global_decl,              /* late_global_decl */
index 8297e025b17e12d5d3d979fef1415f1211c38aba..8c917e07d7975ffec9c96c0cca69ca378cc2d5e0 100644 (file)
@@ -194,6 +194,7 @@ const struct gcc_debug_hooks vmsdbg_debug_hooks
    vmsdbgout_end_epilogue,
    vmsdbgout_begin_function,
    vmsdbgout_end_function,
+   debug_nothing_tree,           /* register_main_translation_unit */
    vmsdbgout_function_decl,
    vmsdbgout_early_global_decl,
    vmsdbgout_late_global_decl,