Patchwork Add DIE addresses to debug_dwarf_die

login
register
mail settings
Submitter Dodji Seketeli
Date Nov. 14, 2010, 6:23 p.m.
Message ID <m3ipzz4ve8.fsf@redhat.com>
Download mbox | patch
Permalink /patch/71142/
State New
Headers show

Comments

Dodji Seketeli - Nov. 14, 2010, 6:23 p.m.
Hello,

While working on another patch, I felt the need to add the addresses
of the DIEs to the output of debug_dwarf_die, similar to what
debug_tree does.  Maybe this could be useful to others.

Now the output looks like [note the (0x7ffff19a70f0)]:

(gdb) call debug_dwarf_die(type_die)
DIE    0: DW_TAG_typedef (0x7ffff19a70f0)
  abbrev id: 0 offset: 0 mark: 0
  DW_AT_name: "A"
  DW_AT_decl_file: "../../prtests/test.cc" (1)
  DW_AT_decl_line: 4
  DW_AT_type: die -> 0 (0x7ffff19a7140)

Tested on x86_64-unknown-linux-gnu against trunk.
Jason Merrill - Nov. 24, 2010, 11:36 p.m.
OK.

Jason

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1094a9f..ebeff3c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -8337,11 +8337,14 @@  print_die (dw_die_ref die, FILE *outfile)
   unsigned ix;
 
   print_spaces (outfile);
-  fprintf (outfile, "DIE %4ld: %s\n",
-	   die->die_offset, dwarf_tag_name (die->die_tag));
+  fprintf (outfile, "DIE %4ld: %s (%p)\n",
+	   die->die_offset, dwarf_tag_name (die->die_tag),
+	   (void*) die);
   print_spaces (outfile);
   fprintf (outfile, "  abbrev id: %lu", die->die_abbrev);
-  fprintf (outfile, " offset: %ld\n", die->die_offset);
+  fprintf (outfile, " offset: %ld", die->die_offset);
+  fprintf (outfile, " mark: %d\n", die->die_mark);
+
   if (dwarf_version >= 4 && die->die_id.die_type_node)
     {
       print_spaces (outfile);
@@ -8405,6 +8408,7 @@  print_die (dw_die_ref die, FILE *outfile)
 		         AT_ref (a)->die_id.die_symbol);
 	      else
 		fprintf (outfile, "die -> %ld", AT_ref (a)->die_offset);
+	      fprintf (outfile, " (%p)", (void *) AT_ref (a));
 	    }
 	  else
 	    fprintf (outfile, "die -> <null>");