This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: dwarfout.c - emit DW_AT_LOCATION for global register variables
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 27 Feb 2003 23:02:21 -0700
- Subject: RFA: dwarfout.c - emit DW_AT_LOCATION for global register variables
I recently learned of a dwarf2 related bug in which insufficient
debugging information is being generated for global declarations such
as the following:
register void *current asm("$23");
As I understand it, this tells gcc to user register 23 for the
``void *'' variable named "current".
``readelf -w'' shows that the following dwarf2 debug info is being
generated for this variable:
<1><d13>: Abbrev Number: 3 (DW_TAG_variable)
DW_AT_name : (indirect string, offset: 0x990): current
DW_AT_decl_file : 2
DW_AT_decl_line : 4
DW_AT_type : <d1e>
When I use the patch appended below, I see the same info as above
along with the DW_AT_location attribute needed by a debugger to
find the variable:
DW_AT_location : 1 byte block: 67 (DW_OP_reg23; )
Prior to posting the patch (below) to this list, I asked for opinions
regarding this patch from a few folks who are much more knowledgable
about gcc than myself. Jason Merrill responded that it looks good.
I am not on the "Write After Approval" list for gcc, so someone else
will need to to check this in for me.
Perhaps I should be on gcc's "Write after approval" list? If so,
what's the procedure for getting added to it? (I already have cvs
access for gdb and binutils.)
Kevin
* dwarf2out.c (rtl_for_decl_location): Don't return NULL_RTX for
global register variables.
Index: dwarf2out.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.401
diff -u -p -r1.401 dwarf2out.c
--- dwarf2out.c 20 Feb 2003 17:51:39 -0000 1.401
+++ dwarf2out.c 28 Feb 2003 05:39:41 -0000
@@ -9360,13 +9360,17 @@ rtl_for_decl_location (decl)
rtl = DECL_RTL_IF_SET (decl);
/* When generating abstract instances, ignore everything except
- constants and symbols living in memory. */
+ constants, symbols living in memory, and symbols living in
+ fixed registers. */
if (! reload_completed)
{
if (rtl
&& (CONSTANT_P (rtl)
|| (GET_CODE (rtl) == MEM
- && CONSTANT_P (XEXP (rtl, 0)))))
+ && CONSTANT_P (XEXP (rtl, 0)))
+ || (GET_CODE (rtl) == REG
+ && TREE_CODE (decl) == VAR_DECL
+ && TREE_STATIC (decl))))
{
rtl = (*targetm.delegitimize_address) (rtl);
return rtl;