From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31322 invoked by alias); 10 Sep 2008 23:29:17 -0000 Received: (qmail 31314 invoked by uid 22791); 10 Sep 2008 23:29:16 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out3.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 10 Sep 2008 23:28:24 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out3.google.com with ESMTP id m8ANSJkJ024523 for ; Thu, 11 Sep 2008 00:28:19 +0100 Received: from localhost (ruffy.corp.google.com [172.18.118.116]) by wpaz9.hot.corp.google.com with ESMTP id m8ANSI9A030743 for ; Wed, 10 Sep 2008 16:28:18 -0700 Received: by localhost (Postfix, from userid 67641) id D00141C789E; Wed, 10 Sep 2008 16:28:17 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [RFA] dwarf2read.c:comp_unit_head cleanup Message-Id: <20080910232817.D00141C789E@localhost> Date: Wed, 10 Sep 2008 23:29:00 -0000 From: dje@google.com (Doug Evans) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-09/txt/msg00228.txt.bz2 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 * 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."));