From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Victor Leschuk <vleschuk@accesssoftek.com>
Subject: [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table
Date: Sun, 12 Feb 2017 20:23:00 -0000 [thread overview]
Message-ID: <148693098109.9024.15851764429541979761.stgit@host1.jankratochvil.net> (raw)
In-Reply-To: <148693097396.9024.2288256732840761882.stgit@host1.jankratochvil.net>
Hi,
DWARF-5 moved .debug_types into .debug_info and so the types reading code needs
to be reused more (in a future patch).
Jan
gdb/ChangeLog
2017-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (create_debug_type_hash_table): New function from
create_debug_types_hash_table.
(create_debug_types_hash_table): Call create_debug_type_hash_table.
(create_all_type_units, open_and_init_dwo_file): Update
create_debug_types_hash_table callers.
---
gdb/dwarf2read.c | 256 ++++++++++++++++++++++++++++--------------------------
1 file changed, 131 insertions(+), 125 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bf381a7..7c74718 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4606,27 +4606,17 @@ add_signatured_type_cu_to_table (void **slot, void *datum)
return 1;
}
-/* Create the hash table of all entries in the .debug_types
- (or .debug_types.dwo) section(s).
- If reading a DWO file, then DWO_FILE is a pointer to the DWO file object,
- otherwise it is NULL.
+/* A helper for create_debug_types_hash_table. Read types from SECTION
+ and fill them into TYPES_HTAB. */
- The result is a pointer to the hash table or NULL if there are no types.
-
- Note: This function processes DWO files only, not DWP files. */
-
-static htab_t
-create_debug_types_hash_table (struct dwo_file *dwo_file,
- VEC (dwarf2_section_info_def) *types)
+static void
+create_debug_type_hash_table (struct dwo_file *dwo_file,
+ dwarf2_section_info *section, htab_t &types_htab)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
- htab_t types_htab = NULL;
- int ix;
- struct dwarf2_section_info *section;
struct dwarf2_section_info *abbrev_section;
-
- if (VEC_empty (dwarf2_section_info_def, types))
- return NULL;
+ bfd *abfd;
+ const gdb_byte *info_ptr, *end_ptr;
abbrev_section = (dwo_file != NULL
? &dwo_file->sections.abbrev
@@ -4637,136 +4627,152 @@ create_debug_types_hash_table (struct dwo_file *dwo_file,
dwo_file ? ".dwo" : "",
get_section_file_name (abbrev_section));
- for (ix = 0;
- VEC_iterate (dwarf2_section_info_def, types, ix, section);
- ++ix)
- {
- bfd *abfd;
- const gdb_byte *info_ptr, *end_ptr;
+ dwarf2_read_section (objfile, section);
+ info_ptr = section->buffer;
- dwarf2_read_section (objfile, section);
- info_ptr = section->buffer;
+ if (info_ptr == NULL)
+ return;
- if (info_ptr == NULL)
- continue;
+ /* We can't set abfd until now because the section may be empty or
+ not present, in which case the bfd is unknown. */
+ abfd = get_section_bfd_owner (section);
- /* We can't set abfd until now because the section may be empty or
- not present, in which case the bfd is unknown. */
- abfd = get_section_bfd_owner (section);
+ /* 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. */
- /* 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. */
+ end_ptr = info_ptr + section->size;
+ while (info_ptr < end_ptr)
+ {
+ sect_offset offset;
+ cu_offset type_offset_in_tu;
+ ULONGEST signature;
+ struct signatured_type *sig_type;
+ struct dwo_unit *dwo_tu;
+ void **slot;
+ const gdb_byte *ptr = info_ptr;
+ struct comp_unit_head header;
+ unsigned int length;
- end_ptr = info_ptr + section->size;
- while (info_ptr < end_ptr)
- {
- sect_offset offset;
- cu_offset type_offset_in_tu;
- ULONGEST signature;
- struct signatured_type *sig_type;
- struct dwo_unit *dwo_tu;
- void **slot;
- const gdb_byte *ptr = info_ptr;
- struct comp_unit_head header;
- unsigned int length;
+ offset.sect_off = ptr - section->buffer;
- offset.sect_off = ptr - section->buffer;
+ /* We need to read the type's signature in order to build the hash
+ table, but we don't need anything else just yet. */
- /* We need to read the type's signature in order to build the hash
- table, but we don't need anything else just yet. */
+ ptr = read_and_check_type_unit_head (&header, section,
+ abbrev_section, ptr,
+ &signature, &type_offset_in_tu);
- ptr = read_and_check_type_unit_head (&header, section,
- abbrev_section, ptr,
- &signature, &type_offset_in_tu);
+ length = get_cu_length (&header);
- length = get_cu_length (&header);
+ /* Skip dummy type units. */
+ if (ptr >= info_ptr + length
+ || peek_abbrev_code (abfd, ptr) == 0)
+ {
+ info_ptr += length;
+ continue;
+ }
- /* Skip dummy type units. */
- if (ptr >= info_ptr + length
- || peek_abbrev_code (abfd, ptr) == 0)
- {
- info_ptr += length;
- continue;
- }
+ if (types_htab == NULL)
+ {
+ if (dwo_file)
+ types_htab = allocate_dwo_unit_table (objfile);
+ else
+ types_htab = allocate_signatured_type_table (objfile);
+ }
- if (types_htab == NULL)
- {
- if (dwo_file)
- types_htab = allocate_dwo_unit_table (objfile);
- else
- types_htab = allocate_signatured_type_table (objfile);
- }
+ if (dwo_file)
+ {
+ sig_type = NULL;
+ dwo_tu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct dwo_unit);
+ dwo_tu->dwo_file = dwo_file;
+ dwo_tu->signature = signature;
+ dwo_tu->type_offset_in_tu = type_offset_in_tu;
+ dwo_tu->section = section;
+ dwo_tu->offset = offset;
+ dwo_tu->length = length;
+ }
+ else
+ {
+ /* N.B.: type_offset is not usable if this type uses a DWO file.
+ The real type_offset is in the DWO file. */
+ dwo_tu = NULL;
+ sig_type = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct signatured_type);
+ sig_type->signature = signature;
+ sig_type->type_offset_in_tu = type_offset_in_tu;
+ sig_type->per_cu.objfile = objfile;
+ sig_type->per_cu.is_debug_types = 1;
+ sig_type->per_cu.section = section;
+ sig_type->per_cu.offset = offset;
+ sig_type->per_cu.length = length;
+ }
+
+ slot = htab_find_slot (types_htab,
+ dwo_file ? (void*) dwo_tu : (void *) sig_type,
+ INSERT);
+ gdb_assert (slot != NULL);
+ if (*slot != NULL)
+ {
+ sect_offset dup_offset;
if (dwo_file)
{
- sig_type = NULL;
- dwo_tu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct dwo_unit);
- dwo_tu->dwo_file = dwo_file;
- dwo_tu->signature = signature;
- dwo_tu->type_offset_in_tu = type_offset_in_tu;
- dwo_tu->section = section;
- dwo_tu->offset = offset;
- dwo_tu->length = length;
+ const struct dwo_unit *dup_tu
+ = (const struct dwo_unit *) *slot;
+
+ dup_offset = dup_tu->offset;
}
else
{
- /* N.B.: type_offset is not usable if this type uses a DWO file.
- The real type_offset is in the DWO file. */
- dwo_tu = NULL;
- sig_type = OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct signatured_type);
- sig_type->signature = signature;
- sig_type->type_offset_in_tu = type_offset_in_tu;
- sig_type->per_cu.objfile = objfile;
- sig_type->per_cu.is_debug_types = 1;
- sig_type->per_cu.section = section;
- sig_type->per_cu.offset = offset;
- sig_type->per_cu.length = length;
+ const struct signatured_type *dup_tu
+ = (const struct signatured_type *) *slot;
+
+ dup_offset = dup_tu->per_cu.offset;
}
- slot = htab_find_slot (types_htab,
- dwo_file ? (void*) dwo_tu : (void *) sig_type,
- INSERT);
- gdb_assert (slot != NULL);
- if (*slot != NULL)
- {
- sect_offset dup_offset;
+ complaint (&symfile_complaints,
+ _("debug type entry at offset 0x%x is duplicate to"
+ " the entry at offset 0x%x, signature %s"),
+ offset.sect_off, dup_offset.sect_off,
+ hex_string (signature));
+ }
+ *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type;
- if (dwo_file)
- {
- const struct dwo_unit *dup_tu
- = (const struct dwo_unit *) *slot;
+ if (dwarf_read_debug > 1)
+ fprintf_unfiltered (gdb_stdlog, " offset 0x%x, signature %s\n",
+ offset.sect_off,
+ hex_string (signature));
- dup_offset = dup_tu->offset;
- }
- else
- {
- const struct signatured_type *dup_tu
- = (const struct signatured_type *) *slot;
+ info_ptr += length;
+ }
+}
- dup_offset = dup_tu->per_cu.offset;
- }
+/* Create the hash table of all entries in the .debug_types
+ (or .debug_types.dwo) section(s).
+ If reading a DWO file, then DWO_FILE is a pointer to the DWO file object,
+ otherwise it is NULL.
- complaint (&symfile_complaints,
- _("debug type entry at offset 0x%x is duplicate to"
- " the entry at offset 0x%x, signature %s"),
- offset.sect_off, dup_offset.sect_off,
- hex_string (signature));
- }
- *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type;
+ The result is a pointer to the hash table or NULL if there are no types.
- if (dwarf_read_debug > 1)
- fprintf_unfiltered (gdb_stdlog, " offset 0x%x, signature %s\n",
- offset.sect_off,
- hex_string (signature));
+ Note: This function processes DWO files only, not DWP files. */
- info_ptr += length;
- }
- }
+static void
+create_debug_types_hash_table (struct dwo_file *dwo_file,
+ VEC (dwarf2_section_info_def) *types,
+ htab_t &types_htab)
+{
+ int ix;
+ struct dwarf2_section_info *section;
+
+ if (VEC_empty (dwarf2_section_info_def, types))
+ return;
- return types_htab;
+ for (ix = 0;
+ VEC_iterate (dwarf2_section_info_def, types, ix, section);
+ ++ix)
+ create_debug_type_hash_table (dwo_file, section, types_htab);
}
/* Create the hash table of all entries in the .debug_types section,
@@ -4777,10 +4783,10 @@ create_debug_types_hash_table (struct dwo_file *dwo_file,
static int
create_all_type_units (struct objfile *objfile)
{
- htab_t types_htab;
+ htab_t types_htab = NULL;
struct signatured_type **iter;
- types_htab = create_debug_types_hash_table (NULL, dwarf2_per_objfile->types);
+ create_debug_types_hash_table (NULL, dwarf2_per_objfile->types, types_htab);
if (types_htab == NULL)
{
dwarf2_per_objfile->signatured_types = NULL;
@@ -10616,8 +10622,8 @@ open_and_init_dwo_file (struct dwarf2_per_cu_data *per_cu,
dwo_file->cu = create_dwo_cu (dwo_file);
- dwo_file->tus = create_debug_types_hash_table (dwo_file,
- dwo_file->sections.types);
+ create_debug_types_hash_table (dwo_file, dwo_file->sections.types,
+ dwo_file->tus);
discard_cleanups (cleanups);
next prev parent reply other threads:[~2017-02-12 20:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
2017-02-12 20:23 ` [PATCH 5/8] DWARF-5 basic functionality Jan Kratochvil
2017-02-17 11:41 ` Pedro Alves
2017-02-19 21:26 ` Jan Kratochvil
[not found] ` <e23e71b0-3cf7-ca57-c4a7-932d4d2be6a3@redhat.com>
2017-02-20 19:52 ` Jan Kratochvil
2017-02-20 20:07 ` [commit] " Jan Kratochvil
2017-02-12 20:23 ` [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
2017-02-17 1:19 ` Pedro Alves
2017-02-19 21:26 ` Jan Kratochvil
2017-02-20 11:11 ` Pedro Alves
2017-02-12 20:23 ` [PATCH 8/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
2017-02-17 12:09 ` Pedro Alves
2017-02-19 21:26 ` Jan Kratochvil
2017-02-20 11:44 ` Pedro Alves
2017-02-17 12:24 ` Pedro Alves
2017-02-12 20:23 ` [PATCH 6/8] DWARF-5: call sites Jan Kratochvil
2017-02-12 20:41 ` Eli Zaretskii
2017-02-17 11:57 ` Pedro Alves
2017-02-19 21:26 ` Jan Kratochvil
2017-02-12 20:23 ` [PATCH 7/8] DWARF-5: Macros Jan Kratochvil
2017-02-17 11:59 ` Pedro Alves
2017-02-12 20:23 ` [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
2017-02-17 1:21 ` Pedro Alves
2017-02-12 20:23 ` Jan Kratochvil [this message]
2017-02-16 19:33 ` [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table Pedro Alves
2017-02-16 15:23 ` [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Pedro Alves
2017-02-16 19:40 ` Jan Kratochvil
2017-02-16 20:01 ` Pedro Alves
2017-02-16 22:54 ` Pedro Alves
2017-02-17 1:28 ` Pedro Alves
2017-02-19 21:25 ` Jan Kratochvil
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=148693098109.9024.15851764429541979761.stgit@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=vleschuk@accesssoftek.com \
/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