PATCH: PR debug/36589: [4.4 Regression]: No debug info for local static variable at -O0

H.J. Lu hjl.tools@gmail.com
Mon Jun 23 13:52:00 GMT 2008


Before

http://gcc.gnu.org/ml/gcc-patches/2008-06/msg01170.html

debug info of local static variables is handled in
varpool_output_debug_info as a special case.  Since unit-at-a-time
is enaled at O0, we output local static variables directly in
cgraph_output_in_order and no longer put them on
varpool_assembled_nodes_queue.  As the result, there is no
debug info for local static variable at -O0.  This patch generates
debug info for local static variables in cgraph_output_in_order.
OK for trunk?

Thanks.

H.J.
---
2008-06-23  H.J. Lu  <hongjiu.lu@intel.com>

	PR debug/36589
	* cgraphunit.c (cgraph_output_in_order): Output debug info for
	local static variables.

Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 136905)
+++ cgraphunit.c	(working copy)
@@ -1303,7 +1303,15 @@ cgraph_output_in_order (void)
 	  break;
 
 	case ORDER_VAR:
-	  varpool_assemble_decl (nodes[i].u.v);
+	  pv = nodes[i].u.v;
+	  varpool_assemble_decl (pv);
+	  /* Since check_global_declarations never sees local static
+	     variables, we need to output debug info by hand.  */
+	if (DECL_CONTEXT (pv->decl)
+	    && (TREE_CODE (DECL_CONTEXT (pv->decl)) == BLOCK
+		|| (TREE_CODE (DECL_CONTEXT (pv->decl))
+		    == FUNCTION_DECL)))
+	     (*debug_hooks->global_decl) (pv->decl);
 	  break;
 
 	case ORDER_ASM:



More information about the Gcc-patches mailing list