* [commit] minor dwarf2read.c cleanup
@ 2013-09-27 18:49 Doug Evans
0 siblings, 0 replies; 2+ messages in thread
From: Doug Evans @ 2013-09-27 18:49 UTC (permalink / raw)
To: gdb-patches
Hi.
fyi, committed.
Regression tested on amd64-linux, with/without fission.
2013-09-27 Doug Evans <dje@google.com>
* dwarf2read.c (struct dwo_file): Add/tweak comments.
(lookup_dwo_unit_in_dwp): Renamed from lookup_dwo_in_dwp. Remove
arg "htab". All callers updated.
(create_debug_types_hash_table): Remove redundant copy of
abbrev_section.
(create_dwo_in_dwp): Tweak comments.
(read_str_index): Tweak comment. Record dwarf form name in static
local.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.836
diff -u -p -r1.836 dwarf2read.c
--- dwarf2read.c 25 Sep 2013 21:44:11 -0000 1.836
+++ dwarf2read.c 27 Sep 2013 00:14:16 -0000
@@ -750,8 +750,15 @@ struct dwo_unit
};
/* Data for one DWO file.
- This includes virtual DWO files that have been packaged into a
- DWP file. */
+
+ This includes virtual DWO files (a virtual DWO file is a DWO file as it
+ appears in a DWP file). DWP files don't really have DWO files per se -
+ comdat folding of types "loses" the DWO file they came from, and from
+ a high level view DWP files appear to contain a mass of random types.
+ However, to maintain consistency with the non-DWP case we pretend DWP
+ files contain virtual DWO files, and we assign each TU with one virtual
+ DWO file (generally based on the line and abbrev section offsets -
+ a heuristic that seems to work in practice). */
struct dwo_file
{
@@ -830,7 +837,7 @@ struct dwp_file
/* Section info for this file. */
struct dwp_sections sections;
- /* Table of CUs in the file. */
+ /* Table of CUs in the file. */
const struct dwp_hash_table *cus;
/* Table of TUs in the file. */
@@ -1699,9 +1706,9 @@ static htab_t allocate_signatured_type_t
static htab_t allocate_dwo_unit_table (struct objfile *objfile);
-static struct dwo_unit *lookup_dwo_in_dwp
- (struct dwp_file *dwp_file, const struct dwp_hash_table *htab,
- const char *comp_dir, ULONGEST signature, int is_debug_types);
+static struct dwo_unit *lookup_dwo_unit_in_dwp
+ (struct dwp_file *dwp_file, const char *comp_dir,
+ ULONGEST signature, int is_debug_types);
static struct dwp_file *get_dwp_file (void);
@@ -4238,7 +4245,6 @@ create_debug_types_hash_table (struct dw
{
bfd *abfd;
const gdb_byte *info_ptr, *end_ptr;
- struct dwarf2_section_info *abbrev_section;
dwarf2_read_section (objfile, section);
info_ptr = section->buffer;
@@ -4250,11 +4256,6 @@ create_debug_types_hash_table (struct dw
not present, in which case section->asection will be NULL. */
abfd = section->asection->owner;
- if (dwo_file)
- abbrev_section = &dwo_file->sections.abbrev;
- else
- abbrev_section = &dwarf2_per_objfile->abbrev;
-
/* We don't use init_cutu_and_read_dies_simple, or some such, here
because we don't need to read any dies: the signature is in the
header. */
@@ -4551,8 +4552,8 @@ lookup_dwp_signatured_type (struct dwarf
Try the DWP file and hope for the best. */
if (dwp_file->tus == NULL)
return NULL;
- dwo_entry = lookup_dwo_in_dwp (dwp_file, dwp_file->tus, NULL,
- sig, 1 /* is_debug_types */);
+ dwo_entry = lookup_dwo_unit_in_dwp (dwp_file, NULL,
+ sig, 1 /* is_debug_types */);
if (dwo_entry == NULL)
return NULL;
@@ -9219,8 +9220,8 @@ create_dwo_in_dwp (struct dwp_file *dwp_
The DWP file can be made up of a random collection of CUs and TUs.
However, for each CU + set of TUs that came from the same original DWO
- file, we want to combine them back into a virtual DWO file to save space
- (fewer struct dwo_file objects to allocated). Remember that for really
+ file, we can combine them back into a virtual DWO file to save space
+ (fewer struct dwo_file objects to allocate). Remember that for really
large apps there can be on the order of 8K CUs and 200K TUs, or more. */
virtual_dwo_name =
@@ -9255,12 +9256,13 @@ create_dwo_in_dwp (struct dwp_file *dwp_
dwo_file->sections.str_offsets = sections.str_offsets;
/* The "str" section is global to the entire DWP file. */
dwo_file->sections.str = dwp_file->sections.str;
- /* The info or types section is assigned later to dwo_unit,
+ /* The info or types section is assigned below to dwo_unit,
there's no need to record it in dwo_file.
Also, we can't simply record type sections in dwo_file because
we record a pointer into the vector in dwo_unit. As we collect more
types we'll grow the vector and eventually have to reallocate space
- for it, invalidating all the pointers into the current copy. */
+ for it, invalidating all copies of pointers into the previous
+ contents. */
*dwo_file_slot = dwo_file;
}
else
@@ -9280,21 +9282,22 @@ create_dwo_in_dwp (struct dwp_file *dwp_
dwo_unit->section = obstack_alloc (&objfile->objfile_obstack,
sizeof (struct dwarf2_section_info));
*dwo_unit->section = sections.info_or_types;
- /* offset, length, type_offset_in_tu are set later. */
+ /* dwo_unit->{offset,length,type_offset_in_tu} are set later. */
return dwo_unit;
}
-/* Lookup the DWO with SIGNATURE in DWP_FILE. */
+/* Lookup the DWO unit with SIGNATURE in DWP_FILE.
+ Returns NULL if the signature isn't found. */
static struct dwo_unit *
-lookup_dwo_in_dwp (struct dwp_file *dwp_file,
- const struct dwp_hash_table *htab,
- const char *comp_dir,
- ULONGEST signature, int is_debug_types)
+lookup_dwo_unit_in_dwp (struct dwp_file *dwp_file, const char *comp_dir,
+ ULONGEST signature, int is_debug_types)
{
+ const struct dwp_hash_table *dwp_htab =
+ is_debug_types ? dwp_file->tus : dwp_file->cus;
bfd *dbfd = dwp_file->dbfd;
- uint32_t mask = htab->nr_slots - 1;
+ uint32_t mask = dwp_htab->nr_slots - 1;
uint32_t hash = signature & mask;
uint32_t hash2 = ((signature >> 32) & mask) | 1;
unsigned int i;
@@ -9309,18 +9312,19 @@ lookup_dwo_in_dwp (struct dwp_file *dwp_
return *slot;
/* Use a for loop so that we don't loop forever on bad debug info. */
- for (i = 0; i < htab->nr_slots; ++i)
+ for (i = 0; i < dwp_htab->nr_slots; ++i)
{
ULONGEST signature_in_table;
signature_in_table =
- read_8_bytes (dbfd, htab->hash_table + hash * sizeof (uint64_t));
+ read_8_bytes (dbfd, dwp_htab->hash_table + hash * sizeof (uint64_t));
if (signature_in_table == signature)
{
- uint32_t section_index =
- read_4_bytes (dbfd, htab->unit_table + hash * sizeof (uint32_t));
+ uint32_t unit_index =
+ read_4_bytes (dbfd,
+ dwp_htab->unit_table + hash * sizeof (uint32_t));
- *slot = create_dwo_in_dwp (dwp_file, htab, section_index,
+ *slot = create_dwo_in_dwp (dwp_file, dwp_htab, unit_index,
comp_dir, signature, is_debug_types);
return *slot;
}
@@ -9756,8 +9760,8 @@ lookup_dwo_cutu (struct dwarf2_per_cu_da
if (dwp_htab != NULL)
{
struct dwo_unit *dwo_cutu =
- lookup_dwo_in_dwp (dwp_file, dwp_htab, comp_dir,
- signature, is_debug_types);
+ lookup_dwo_unit_in_dwp (dwp_file, comp_dir,
+ signature, is_debug_types);
if (dwo_cutu != NULL)
{
@@ -15436,7 +15440,8 @@ dwarf2_read_addr_index (struct dwarf2_pe
return read_addr_index_1 (addr_index, addr_base, addr_size);
}
-/* Given a DW_AT_str_index, fetch the string. */
+/* Given a DW_FORM_GNU_str_index, fetch the string.
+ This is only used by the Fission support. */
static const char *
read_str_index (const struct die_reader_specs *reader,
@@ -15448,21 +15453,22 @@ read_str_index (const struct die_reader_
struct dwo_sections *sections = &reader->dwo_file->sections;
const gdb_byte *info_ptr;
ULONGEST str_offset;
+ static const char form_name[] = "DW_FORM_GNU_str_index";
dwarf2_read_section (objfile, §ions->str);
dwarf2_read_section (objfile, §ions->str_offsets);
if (sections->str.buffer == NULL)
- error (_("DW_FORM_str_index used without .debug_str.dwo section"
+ error (_("%s used without .debug_str.dwo section"
" in CU at offset 0x%lx [in module %s]"),
- (long) cu->header.offset.sect_off, dwo_name);
+ form_name, (long) cu->header.offset.sect_off, dwo_name);
if (sections->str_offsets.buffer == NULL)
- error (_("DW_FORM_str_index used without .debug_str_offsets.dwo section"
+ error (_("%s used without .debug_str_offsets.dwo section"
" in CU at offset 0x%lx [in module %s]"),
- (long) cu->header.offset.sect_off, dwo_name);
+ form_name, (long) cu->header.offset.sect_off, dwo_name);
if (str_index * cu->header.offset_size >= sections->str_offsets.size)
- error (_("DW_FORM_str_index pointing outside of .debug_str_offsets.dwo"
+ error (_("%s pointing outside of .debug_str_offsets.dwo"
" section in CU at offset 0x%lx [in module %s]"),
- (long) cu->header.offset.sect_off, dwo_name);
+ form_name, (long) cu->header.offset.sect_off, dwo_name);
info_ptr = (sections->str_offsets.buffer
+ str_index * cu->header.offset_size);
if (cu->header.offset_size == 4)
@@ -15470,9 +15476,9 @@ read_str_index (const struct die_reader_
else
str_offset = bfd_get_64 (abfd, info_ptr);
if (str_offset >= sections->str.size)
- error (_("Offset from DW_FORM_str_index pointing outside of"
+ error (_("Offset from %s pointing outside of"
" .debug_str.dwo section in CU at offset 0x%lx [in module %s]"),
- (long) cu->header.offset.sect_off, dwo_name);
+ form_name, (long) cu->header.offset.sect_off, dwo_name);
return (const char *) (sections->str.buffer + str_offset);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [commit] minor dwarf2read.c cleanup
@ 2013-03-28 20:28 Doug Evans
0 siblings, 0 replies; 2+ messages in thread
From: Doug Evans @ 2013-03-28 20:28 UTC (permalink / raw)
To: gdb-patches
Hi.
I've had this patch in a sandbox for awhile.
It's just some minor cleanup. Committed.
2013-03-28 Doug Evans <dje@google.com>
* dwarf2read.c (dwarf2_physname): Move declaration to better spot.
(compute_symtab_includes): Remove unnecessary forward declaration.
(die_needs_namespace): Add comment marking group of functions for
dwarf2 name computation.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.758
diff -u -p -r1.758 dwarf2read.c
--- dwarf2read.c 20 Mar 2013 18:35:22 -0000 1.758
+++ dwarf2read.c 28 Mar 2013 17:19:01 -0000
@@ -1554,6 +1557,9 @@ static const char *dwarf2_full_name (con
struct die_info *die,
struct dwarf2_cu *cu);
+static const char *dwarf2_physname (const char *name, struct die_info *die,
+ struct dwarf2_cu *cu);
+
static struct die_info *dwarf2_extension (struct die_info *die,
struct dwarf2_cu **);
@@ -1765,9 +1771,6 @@ byte_swap (offset_type value)
/* The suffix for an index file. */
#define INDEX_SUFFIX ".gdb-index"
-static const char *dwarf2_physname (const char *name, struct die_info *die,
- struct dwarf2_cu *cu);
-
/* Try to locate the sections we need for DWARF 2 debugging
information and return true if we have enough to do something.
NAMES points to the dwarf2 section names, or is NULL if the standard
@@ -6867,8 +6880,6 @@ fixup_go_packaging (struct dwarf2_cu *cu
}
}
-static void compute_symtab_includes (struct dwarf2_per_cu_data *per_cu);
-
/* Return the symtab for PER_CU. This works properly regardless of
whether we're using the index or psymtabs. */
@@ -7279,6 +7290,8 @@ process_die (struct die_info *die, struc
break;
}
}
+\f
+/* DWARF name computation. */
/* A helper function for dwarf2_compute_name which determines whether DIE
needs to have the name of the scope prepended to the name listed in the
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-27 18:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-27 18:49 [commit] minor dwarf2read.c cleanup Doug Evans
-- strict thread matches above, loose matches on Subject: below --
2013-03-28 20:28 Doug Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).