]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR debug/39267 (gdb testsuite regressions)
authorJan Hubicka <jh@suse.cz>
Sat, 28 Feb 2009 21:34:23 +0000 (22:34 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 28 Feb 2009 21:34:23 +0000 (21:34 +0000)
PR debug/39267
* cgraph.h (varpool_output_debug_info): Remove.
* cgraphunit.c (varpool_output_debug_info): Remove.
* dwarf2out.c (deferred_locations_struct): New struct
(deferred_locations): New type.
(deferred_locations_list): New static var.
(deffer_location): New function.
(gen_variable_die): Use it.
(decls_for_scope): Output info on local static vars.
(dwarf2out_finish): Process deferred locations.
* varpool.c (varpool_output_debug_info): Remove.

From-SVN: r144496

gcc/ChangeLog
gcc/cgraph.h
gcc/cgraphunit.c
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/dwarf2/static1.c [new file with mode: 0644]
gcc/varpool.c

index 330da7c4a37be09065ded3cab7130bf6dc6cafb6..8acc502d8c96e66e147e9ff9f35de7e9a2f57023 100644 (file)
@@ -1,3 +1,17 @@
+2009-02-27  Jan Hubicka  <jh@suse.cz>
+
+       PR debug/39267
+       * cgraph.h (varpool_output_debug_info): Remove.
+       * cgraphunit.c (varpool_output_debug_info): Remove.
+       * dwarf2out.c (deferred_locations_struct): New struct
+       (deferred_locations): New type.
+       (deferred_locations_list): New static var.
+       (deffer_location): New function.
+       (gen_variable_die): Use it.
+       (decls_for_scope): Output info on local static vars.
+       (dwarf2out_finish): Process deferred locations.
+       * varpool.c (varpool_output_debug_info): Remove.
+
 2009-02-27  Jan Hubicka  <jh@suse.cz>
 
        PR debug/39267
index 782580466dd5e2851a3f96b9a9cef30e5d4e1172..57d4772cdd529e89ae87705e33a90cafd549784c 100644 (file)
@@ -413,7 +413,6 @@ enum availability cgraph_variable_initializer_availability (struct varpool_node
 bool varpool_assemble_pending_decls (void);
 bool varpool_assemble_decl (struct varpool_node *node);
 bool varpool_analyze_pending_decls (void);
-void varpool_output_debug_info (void);
 void varpool_remove_unreferenced_decls (void);
 void varpool_empty_needed_queue (void);
 
index 00a1bc26f1a15d66f500ebf20aa54cee41a15627..07998d4af8c17369acb34d079eeb64a1cdee71f1 100644 (file)
@@ -1313,7 +1313,6 @@ cgraph_optimize (void)
 
       varpool_assemble_pending_decls ();
     }
-  varpool_output_debug_info ();
   cgraph_process_new_functions ();
   cgraph_state = CGRAPH_STATE_FINISHED;
 
index 9d39a455e855419eeb1c5edff2413441d572b00a..48178b7cbcb6d497334406247c1a5020acdebc92 100644 (file)
@@ -3405,6 +3405,17 @@ typedef const struct die_struct *const_dw_die_ref;
 typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
 typedef struct dw_loc_list_struct *dw_loc_list_ref;
 
+typedef struct deferred_locations_struct GTY(()) 
+{
+  tree variable;
+  dw_die_ref die;
+} deferred_locations;
+
+DEF_VEC_O(deferred_locations);
+DEF_VEC_ALLOC_O(deferred_locations,gc);
+
+static GTY(()) VEC(deferred_locations, gc) *deferred_locations_list;
+
 /* Each DIE may have a series of attribute/value pairs.  Values
    can take on several forms.  The forms that are used in this
    implementation are listed below.  */
@@ -11858,6 +11869,17 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl,
   tree_add_const_value_attribute (die, decl);
 }
 
+/* Add VARIABLE and DIE into deferred locations list.  */
+
+static void
+defer_location (tree variable, dw_die_ref die)
+{
+  deferred_locations entry;
+  entry.variable = variable;
+  entry.die = die;
+  VEC_safe_push (deferred_locations, gc, deferred_locations_list, &entry);
+}
+
 /* Helper function for tree_add_const_value_attribute.  Natively encode
    initializer INIT into an array.  Return true if successful.  */
 
@@ -14054,7 +14076,11 @@ gen_variable_die (tree decl, dw_die_ref context_die)
 
   if (! declaration && ! DECL_ABSTRACT (decl))
     {
-      add_location_or_const_value_attribute (var_die, decl, DW_AT_location);
+      if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
+          && !TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
+       defer_location (decl, var_die);
+      else
+        add_location_or_const_value_attribute (var_die, decl, DW_AT_location);
       add_pubname (decl, var_die);
     }
   else
@@ -14934,16 +14960,6 @@ decls_for_scope (tree stmt, dw_die_ref context_die, int depth)
 
          if (die != NULL && die->die_parent == NULL)
            add_child_die (context_die, die);
-         /* Do not produce debug information for static variables since
-            these might be optimized out.  We are called for these later
-            in varpool_analyze_pending_decls.
-
-            But *do* produce it for Fortran COMMON variables because,
-            even though they are static, their names can differ depending
-            on the scope, which we need to preserve.  */
-         if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
-             && !(is_fortran () && TREE_PUBLIC (decl)))
-           ;
          else if (TREE_CODE (decl) == IMPORTED_DECL)
            dwarf2out_imported_module_or_decl_1 (decl, DECL_NAME (decl),
                                                 stmt, context_die);
@@ -16443,6 +16459,7 @@ dwarf2out_finish (const char *filename)
 {
   limbo_die_node *node, *next_node;
   dw_die_ref die = 0;
+  unsigned int i;
 
   /* Add the name for the main input file now.  We delayed this from
      dwarf2out_init to avoid complications with PCH.  */
@@ -16457,6 +16474,14 @@ dwarf2out_finish (const char *filename)
        add_comp_dir_attribute (comp_unit_die);
     }
 
+  for (i = 0; i < VEC_length (deferred_locations, deferred_locations_list); i++)
+    {
+      add_location_or_const_value_attribute (
+        VEC_index (deferred_locations, deferred_locations_list, i)->die,
+        VEC_index (deferred_locations, deferred_locations_list, i)->variable,
+       DW_AT_location);
+    }
+
   /* Traverse the limbo die list, and add parent/child links.  The only
      dies without parents that should be here are concrete instances of
      inline functions, and the comp_unit_die.  We can ignore the comp_unit_die.
index d86d2d56fd3f5f3549ec9c85344c8dc1a0abb004..1793202de412a416e1bfeab1369346a6f7fc7bcc 100644 (file)
@@ -1,3 +1,17 @@
+2009-02-26  Jan Hubicka  <jh@suse.cz>
+
+       PR debug/39267
+       * cgraph.h (varpool_output_debug_info): Remove.
+       * cgraphunit.c (varpool_output_debug_info): Remove.
+       * dwarf2out.c (deferred_locations_struct): New struct
+       (deferred_locations): New type.
+       (deferred_locations_list): New static var.
+       (deffer_location): New function.
+       (gen_variable_die): Use it.
+       (decls_for_scope): Output info on local static vars.
+       (dwarf2out_finish): Process deferred locations.
+       * varpool.c (varpool_output_debug_info): Remove.
+
 2009-02-26  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR c++/37789
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/static1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/static1.c
new file mode 100644 (file)
index 0000000..b9b5d0b
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -gdwarf-2" } */
+void
+main(void)
+{
+ static int unused_local_var;
+}
+/* { dg-final { scan-assembler "unused_local_var" } } */
index 8b9821a95038fa865a6a0023732a8464927e3459..8c1259b14eccca07c364c9731f4134050024915f 100644 (file)
@@ -456,29 +456,6 @@ varpool_empty_needed_queue (void)
   varpool_last_needed_node = NULL;
 }
 
-/* Output all variables enqueued to be assembled.  */
-void
-varpool_output_debug_info (void)
-{
-  timevar_push (TV_SYMOUT);
-  if (errorcount == 0 && sorrycount == 0)
-    while (varpool_assembled_nodes_queue)
-      {
-       struct varpool_node *node = varpool_assembled_nodes_queue;
-
-       /* Local static variables are never seen by check_global_declarations
-          so we need to output debug info by hand.  */
-       if (DECL_CONTEXT (node->decl)
-           && (TREE_CODE (DECL_CONTEXT (node->decl)) == BLOCK
-               || TREE_CODE (DECL_CONTEXT (node->decl)) == FUNCTION_DECL)
-           && errorcount == 0 && sorrycount == 0)
-            (*debug_hooks->global_decl) (node->decl);
-       varpool_assembled_nodes_queue = node->next_needed;
-       node->next_needed = 0;
-      }
-  timevar_pop (TV_SYMOUT);
-}
-
 /* Create a new global variable of type TYPE.  */
 tree
 add_new_static_var (tree type)