This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] dwarf2read.c: add DIE debugging dumps


Hi.

This patch adds back dumping of DIEs when requested with
set debug dwarf2-die 1.
Plus it adds a debugging printf to read_comp_units_from_section
so the output is consistent with type units.

Committed.

2013-04-03  Doug Evans  <dje@google.com>

	* dwarf2read.c (read_die_and_siblings_1): Renamed from
	read_die_and_siblings.
	(read_die_and_siblings): New function.
	(read_cutu_die_from_dwo): Dump die if requested.
	(read_die_and_children): Call read_full_die_1 and
	read_die_and_siblings_1.
	(read_full_die): Dump die if requested.

	* dwarf2read.c (read_comp_units_from_section): Add debugging printf.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.775
diff -u -p -r1.775 dwarf2read.c
--- dwarf2read.c	3 Apr 2013 19:11:01 -0000	1.775
+++ dwarf2read.c	3 Apr 2013 19:41:48 -0000
@@ -1530,10 +1530,9 @@ static CORE_ADDR decode_locdesc (struct 
 static enum dwarf_array_dim_ordering read_array_order (struct die_info *,
 						       struct dwarf2_cu *);
 
-static struct die_info *read_die_and_children (const struct die_reader_specs *,
-					       gdb_byte *info_ptr,
-					       gdb_byte **new_info_ptr,
-					       struct die_info *parent);
+static struct die_info *read_die_and_siblings_1
+  (const struct die_reader_specs *, gdb_byte *, gdb_byte **,
+   struct die_info *);
 
 static struct die_info *read_die_and_siblings (const struct die_reader_specs *,
 					       gdb_byte *info_ptr,
@@ -4568,6 +4567,16 @@ read_cutu_die_from_dwo (struct dwarf2_pe
     comp_unit_die->attrs[i++] = *comp_dir;
   comp_unit_die->num_attrs += num_extra_attrs;
 
+  if (dwarf2_die_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "Read die from %s@0x%x of %s:\n",
+			  bfd_section_name (abfd, section->asection),
+			  (unsigned) (begin_info_ptr - section->buffer),
+			  bfd_get_filename (abfd));
+      dump_die (comp_unit_die, dwarf2_die_debug);
+    }
+
   /* Skip dummy compilation units.  */
   if (info_ptr >= begin_info_ptr + dwo_unit->length
       || peek_abbrev_code (abfd, info_ptr) == 0)
@@ -5690,6 +5699,10 @@ read_comp_units_from_section (struct obj
   gdb_byte *info_ptr;
   bfd *abfd = section->asection->owner;
 
+  if (dwarf2_read_debug)
+    fprintf_unfiltered (gdb_stdlog, "Reading %s for %s\n",
+			section->asection->name, bfd_get_filename (abfd));
+
   dwarf2_read_section (objfile, section);
 
   info_ptr = section->buffer;
@@ -13059,7 +13072,7 @@ read_die_and_children (const struct die_
   gdb_byte *cur_ptr;
   int has_children;
 
-  cur_ptr = read_full_die (reader, &die, info_ptr, &has_children);
+  cur_ptr = read_full_die_1 (reader, &die, info_ptr, &has_children, 0);
   if (die == NULL)
     {
       *new_info_ptr = cur_ptr;
@@ -13068,7 +13081,7 @@ read_die_and_children (const struct die_
   store_in_ref_table (die, reader->cu);
 
   if (has_children)
-    die->child = read_die_and_siblings (reader, cur_ptr, new_info_ptr, die);
+    die->child = read_die_and_siblings_1 (reader, cur_ptr, new_info_ptr, die);
   else
     {
       die->child = NULL;
@@ -13085,10 +13098,10 @@ read_die_and_children (const struct die_
    in read_die_and_children.  */
 
 static struct die_info *
-read_die_and_siblings (const struct die_reader_specs *reader,
-		       gdb_byte *info_ptr,
-		       gdb_byte **new_info_ptr,
-		       struct die_info *parent)
+read_die_and_siblings_1 (const struct die_reader_specs *reader,
+			 gdb_byte *info_ptr,
+			 gdb_byte **new_info_ptr,
+			 struct die_info *parent)
 {
   struct die_info *first_die, *last_sibling;
   gdb_byte *cur_ptr;
@@ -13116,6 +13129,34 @@ read_die_and_siblings (const struct die_
     }
 }
 
+/* Read a die, all of its descendents, and all of its siblings; set
+   all of the fields of all of the dies correctly.  Arguments are as
+   in read_die_and_children.
+   This the main entry point for reading a DIE and all its children.  */
+
+static struct die_info *
+read_die_and_siblings (const struct die_reader_specs *reader,
+		       gdb_byte *info_ptr,
+		       gdb_byte **new_info_ptr,
+		       struct die_info *parent)
+{
+  struct die_info *die = read_die_and_siblings_1 (reader, info_ptr,
+						  new_info_ptr, parent);
+
+  if (dwarf2_die_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "Read die from %s@0x%x of %s:\n",
+			  bfd_section_name (reader->abfd,
+					    reader->die_section->asection),
+			  (unsigned) (info_ptr - reader->die_section->buffer),
+			  bfd_get_filename (reader->abfd));
+      dump_die (die, dwarf2_die_debug);
+    }
+
+  return die;
+}
+
 /* Read a die and all its attributes, leave space for NUM_EXTRA_ATTRS
    attributes.
    The caller is responsible for filling in the extra attributes
@@ -13181,7 +13222,22 @@ read_full_die (const struct die_reader_s
 	       struct die_info **diep, gdb_byte *info_ptr,
 	       int *has_children)
 {
-  return read_full_die_1 (reader, diep, info_ptr, has_children, 0);
+  gdb_byte *result;
+
+  result = read_full_die_1 (reader, diep, info_ptr, has_children, 0);
+
+  if (dwarf2_die_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+			  "Read die from %s@0x%x of %s:\n",
+			  bfd_section_name (reader->abfd,
+					    reader->die_section->asection),
+			  (unsigned) (info_ptr - reader->die_section->buffer),
+			  bfd_get_filename (reader->abfd));
+      dump_die (*diep, dwarf2_die_debug);
+    }
+
+  return result;
 }
 
 /* Abbreviation tables.


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