Code cleanup: Split create_debug_types_hash_table

DWARF-5 moved .debug_types into .debug_info and so the types reading code needs
to be reused more (in a future patch).

gdb/ChangeLog
2017-02-20  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.
This commit is contained in:
Jan Kratochvil
2017-02-20 20:53:19 +01:00
parent 43a444f9c5
commit 78d4d2c538
2 changed files with 145 additions and 131 deletions

View File

@ -1,3 +1,11 @@
2017-02-20 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.
2017-02-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/16188

View File

@ -4605,27 +4605,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
@ -4636,18 +4626,11 @@ 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;
if (info_ptr == NULL)
continue;
return;
/* We can't set abfd until now because the section may be empty or
not present, in which case the bfd is unknown. */
@ -4765,7 +4748,30 @@ create_debug_types_hash_table (struct dwo_file *dwo_file,
}
}
return types_htab;
/* 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.
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 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;
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,
@ -4776,10 +4782,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;
@ -10615,8 +10621,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);