Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: dje@google.com (Doug Evans)
To: gdb-patches@sourceware.org
Subject: [RFA] dwarf2read.c:comp_unit_head cleanup
Date: Wed, 10 Sep 2008 23:29:00 -0000	[thread overview]
Message-ID: <20080910232817.D00141C789E@localhost> (raw)

Hi.  This cleans up comp_unit_head.
[useful as part of my DW_FORM_sig8 work,
http://wiki.dwarfstd.org/index.php?title=COMDAT_Type_Sections]

Ok to check in?

2008-09-10  Doug Evans  <dje@google.com>

	* dwarf2read.c (comp_unit_head): Rename first_die_ptr to
	first_die_offset.  All uses updated.
	Delete unused members cu_head_ptr, next.
	Mov members base_known, base_address to ...
	(dwarf2_cu) ... here.  All uses updated.

--- dwarf2read.c	2008-09-10 16:14:26.365839000 -0700
+++ dwarf2read.c.dje	2008-09-10 16:23:28.956028000 -0700
@@ -247,22 +247,9 @@ struct comp_unit_head
      .debug_info section, for resolving relative reference dies.  */
   unsigned int offset;
 
-  /* Pointer to this compilation unit header in the .debug_info
-     section.  */
-  gdb_byte *cu_head_ptr;
-
-  /* Pointer to the first die of this compilation unit.  This will be
-     the first byte following the compilation unit header.  */
-  gdb_byte *first_die_ptr;
-
-  /* Pointer to the next compilation unit header in the program.  */
-  struct comp_unit_head *next;
-
-  /* Base address of this compilation unit.  */
-  CORE_ADDR base_address;
-
-  /* Non-zero if base_address has been set.  */
-  int base_known;
+  /* Offset to first die in this cu from the start of the cu.
+     This will be the first byte following the compilation unit header.  */
+  unsigned int first_die_offset;
 };
 
 /* Internal state when decoding a particular compilation unit.  */
@@ -271,12 +258,15 @@ struct dwarf2_cu
   /* The objfile containing this compilation unit.  */
   struct objfile *objfile;
 
-  /* The header of the compilation unit.
-
-     FIXME drow/2003-11-10: Some of the things from the comp_unit_head
-     should logically be moved to the dwarf2_cu structure.  */
+  /* The header of the compilation unit.  */
   struct comp_unit_head header;
 
+  /* Base address of this compilation unit.  */
+  CORE_ADDR base_address;
+
+  /* Non-zero if base_address has been set.  */
+  int base_known;
+
   struct function_range *first_fn, *last_fn, *cached_fn;
 
   /* The language we are debugging.  */
@@ -1493,8 +1483,7 @@ dwarf2_build_psymtabs_hard (struct objfi
 
       /* Complete the cu_header */
       cu.header.offset = beg_of_comp_unit - dwarf2_per_objfile->info_buffer;
-      cu.header.first_die_ptr = info_ptr;
-      cu.header.cu_head_ptr = beg_of_comp_unit;
+      cu.header.first_die_offset = info_ptr - beg_of_comp_unit;
 
       cu.list_in_scope = &file_symbols;
 
@@ -1660,8 +1649,7 @@ load_comp_unit (struct dwarf2_per_cu_dat
 
   /* Complete the cu_header.  */
   cu->header.offset = beg_of_comp_unit - dwarf2_per_objfile->info_buffer;
-  cu->header.first_die_ptr = info_ptr;
-  cu->header.cu_head_ptr = beg_of_comp_unit;
+  cu->header.first_die_offset = info_ptr - beg_of_comp_unit;
 
   /* Read the abbrevs for this compilation unit into a table.  */
   dwarf2_read_abbrevs (abfd, cu);
@@ -2649,22 +2637,22 @@ process_full_comp_unit (struct dwarf2_pe
      DW_AT_entry_pc.  It's been removed, but GCC still uses this for
      compilation units with discontinuous ranges.  */
 
-  cu->header.base_known = 0;
-  cu->header.base_address = 0;
+  cu->base_known = 0;
+  cu->base_address = 0;
 
   attr = dwarf2_attr (cu->dies, DW_AT_entry_pc, cu);
   if (attr)
     {
-      cu->header.base_address = DW_ADDR (attr);
-      cu->header.base_known = 1;
+      cu->base_address = DW_ADDR (attr);
+      cu->base_known = 1;
     }
   else
     {
       attr = dwarf2_attr (cu->dies, DW_AT_low_pc, cu);
       if (attr)
 	{
-	  cu->header.base_address = DW_ADDR (attr);
-	  cu->header.base_known = 1;
+	  cu->base_address = DW_ADDR (attr);
+	  cu->base_known = 1;
 	}
     }
 
@@ -3132,8 +3120,8 @@ dwarf2_ranges_read (unsigned offset, COR
   CORE_ADDR high = 0;
   CORE_ADDR baseaddr;
 
-  found_base = cu_header->base_known;
-  base = cu_header->base_address;
+  found_base = cu->base_known;
+  base = cu->base_address;
 
   if (offset >= dwarf2_per_objfile->ranges_size)
     {
@@ -3400,8 +3388,8 @@ dwarf2_record_block_ranges (struct die_i
          'baseaddr' argument, which GDB uses to relocate debugging
          information from a shared library based on the address at
          which the library was loaded.  */
-      CORE_ADDR base = cu->header.base_address;
-      int base_known = cu->header.base_known;
+      CORE_ADDR base = cu->base_address;
+      int base_known = cu->base_known;
 
       if (offset >= dwarf2_per_objfile->ranges_size)
         {
@@ -5886,11 +5874,11 @@ read_partial_die (struct partial_die_inf
 	  || dwarf2_per_objfile->has_section_at_zero))
     part_die->has_pc_info = 1;
 
-  if (base_address_type != base_address_none && !cu->header.base_known)
+  if (base_address_type != base_address_none && !cu->base_known)
     {
       gdb_assert (part_die->tag == DW_TAG_compile_unit);
-      cu->header.base_known = 1;
-      cu->header.base_address = base_address;
+      cu->base_known = 1;
+      cu->base_address = base_address;
     }
 
   return info_ptr;
@@ -5955,7 +5943,9 @@ find_partial_die (unsigned long offset, 
 	  dwarf2_read_abbrevs (per_cu->cu->objfile->obfd, per_cu->cu);
 	  back_to = make_cleanup (dwarf2_free_abbrev_table, per_cu->cu);
 	}
-      info_ptr = per_cu->cu->header.first_die_ptr;
+      info_ptr = (dwarf2_per_objfile->info_buffer
+		  + per_cu->cu->header.offset
+		  + per_cu->cu->header.first_die_offset);
       abbrev = peek_die_abbrev (info_ptr, &bytes_read, per_cu->cu);
       info_ptr = read_partial_die (&comp_unit_die, abbrev, bytes_read,
 				   per_cu->cu->objfile->obfd, info_ptr,
@@ -9916,8 +9906,8 @@ dwarf2_symbol_mark_computed (struct attr
 	 don't run off the edge of the section.  */
       baton->size = dwarf2_per_objfile->loc_size - DW_UNSND (attr);
       baton->data = dwarf2_per_objfile->loc_buffer + DW_UNSND (attr);
-      baton->base_address = cu->header.base_address;
-      if (cu->header.base_known == 0)
+      baton->base_address = cu->base_address;
+      if (cu->base_known == 0)
 	complaint (&symfile_complaints,
 		   _("Location list used without specifying the CU base address."));
 


             reply	other threads:[~2008-09-10 23:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-10 23:29 Doug Evans [this message]
2008-09-10 23:40 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080910232817.D00141C789E@localhost \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox