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]

dwarf2out patch: Emit const_value for non-definitions


This patch adds an AT_const_value to a declaration DIE for a C++
member constant, so that the debugger will know its value even if
no definition is ever provided.  gdb doesn't seem to take advantage of
this yet, however.

Daniel, any word on multiple-CU support for gdb?

2000-09-21  Jason Merrill  <jason@redhat.com>

	* dwarf2out.c (tree_add_const_value_attribute): New fn.
	(gen_variable_die): Call it for non-definitions.

*** dwarf2out.c.~1~	Sun Sep 17 15:47:48 2000
--- dwarf2out.c	Wed Sep 20 21:55:32 2000
*************** add_location_or_const_value_attribute (d
*** 7931,7936 ****
--- 7950,7989 ----
      }
  }
  
+ /* If we don't have a copy of this variable in memory for some reason (such
+    as a C++ member constant that doesn't have an out-of-line definition),
+    we should tell the debugger about the constant value.  */
+ 
+ static void
+ tree_add_const_value_attribute (var_die, decl)
+      dw_die_ref var_die;
+      tree decl;
+ {
+   tree init = DECL_INITIAL (decl);
+   tree type = TREE_TYPE (decl);
+ 
+   if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) && init
+       && initializer_constant_valid_p (init, type) == null_pointer_node)
+     /* OK */;
+   else
+     return;
+ 
+   switch (TREE_CODE (type))
+     {
+     case INTEGER_TYPE:
+       if (host_integerp (init, 0))
+ 	add_AT_unsigned (var_die, DW_AT_const_value,
+ 			 TREE_INT_CST_LOW (init));
+       else
+ 	add_AT_long_long (var_die, DW_AT_const_value,
+ 			  TREE_INT_CST_HIGH (init),
+ 			  TREE_INT_CST_LOW (init));
+       break;
+ 
+     default:;
+     }
+ }
+      
  /* Generate an DW_AT_name attribute given some string value to be included as
     the value of the attribute.  */
  
*************** gen_variable_die (decl, context_die)
*** 9369,9374 ****
--- 9422,9429 ----
        add_location_or_const_value_attribute (var_die, decl);
        add_pubname (decl, var_die);
      }
+   else
+     tree_add_const_value_attribute (var_die, decl);
  }
  
  /* Generate a DIE to represent a label identifier.  */

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