From: Tom Tromey Date: Wed, 27 May 2020 15:19:35 +0000 (-0400) Subject: Move signatured_type::type to unshareable object X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e286671bf99ab870d67431068e863c1c57631b1f;p=binutils-gdb.git Move signatured_type::type to unshareable object signatured_type has a link to the "struct type". However, types are inherently objfile-specific, so once sharing is implemented, this will be incorrect. This patch moves the type to a new map in the DWARF unshareable object. gdb/ChangeLog: YYYY-MM-DD Tom Tromey YYYY-MM-DD Simon Marchi * dwarf2/read.h (struct dwarf2_per_objfile) : New methods. : New member. (struct signatured_type) : Remove. * dwarf2/read.c (dwarf2_per_objfile::get_type_for_signatured_type, dwarf2_per_objfile::set_type_for_signatured_type): New. (get_signatured_type): Use new methods. Change-Id: I765ae3c43fae1064f51ced352167a57638609f02 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f8213706243..a3dec4fd13f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2020-05-27 Tom Tromey + Simon Marchi + + * dwarf2/read.h (struct dwarf2_per_objfile) + : + New methods. + : New member. + (struct signatured_type) : Remove. + * dwarf2/read.c + (dwarf2_per_objfile::get_type_for_signatured_type, + dwarf2_per_objfile::set_type_for_signatured_type): New. + (get_signatured_type): Use new methods. + 2020-05-27 Tom Tromey Simon Marchi diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 53def0c87eb..7819fc5c8d6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9630,6 +9630,25 @@ dwarf2_per_objfile::get_type_unit_group_unshareable (type_unit_group *tu_group) return result; } +struct type * +dwarf2_per_objfile::get_type_for_signatured_type + (signatured_type *sig_type) const +{ + auto iter = this->m_type_map.find (sig_type); + if (iter == this->m_type_map.end ()) + return nullptr; + + return iter->second; +} + +void dwarf2_per_objfile::set_type_for_signatured_type + (signatured_type *sig_type, struct type *type) +{ + gdb_assert (this->m_type_map.find (sig_type) == this->m_type_map.end ()); + + this->m_type_map[sig_type] = type; +} + /* A helper function for computing the list of all symbol tables included by PER_CU. */ @@ -22720,8 +22739,9 @@ get_signatured_type (struct die_info *die, ULONGEST signature, } /* If we already know the type we're done. */ - if (sig_type->type != NULL) - return sig_type->type; + type = dwarf2_per_objfile->get_type_for_signatured_type (sig_type); + if (type != nullptr) + return type; type_cu = cu; type_die = follow_die_sig_1 (die, sig_type, &type_cu); @@ -22748,7 +22768,8 @@ get_signatured_type (struct die_info *die, ULONGEST signature, objfile_name (dwarf2_per_objfile->objfile)); type = build_error_marker_type (cu, die); } - sig_type->type = type; + + dwarf2_per_objfile->set_type_for_signatured_type (sig_type, type); return type; } diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 13d31a97d3d..3500b0e7ba9 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -329,11 +329,16 @@ struct dwarf2_per_objfile /* Set the compunit_symtab associated to PER_CU. */ void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab); -/* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one - does not exist, create it. */ + /* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one + does not exist, create it. */ type_unit_group_unshareable *get_type_unit_group_unshareable (type_unit_group *tu_group); + struct type *get_type_for_signatured_type (signatured_type *sig_type) const; + + void set_type_for_signatured_type (signatured_type *sig_type, + struct type *type); + /* Find an integer type SIZE_IN_BYTES bytes in size and return it. UNSIGNED_P controls if the integer is unsigned or not. */ struct type *int_type (int size_in_bytes, bool unsigned_p) const; @@ -363,6 +368,9 @@ private: std::unordered_map m_type_units; + + /* Map from signatured types to the corresponding struct type. */ + std::unordered_map m_type_map; }; /* Get the dwarf2_per_objfile associated to OBJFILE. */ @@ -584,11 +592,6 @@ struct signatured_type can share them. This points to the containing symtab. */ struct type_unit_group *type_unit_group; - /* The type. - The first time we encounter this type we fully read it in and install it - in the symbol tables. Subsequent times we only need the type. */ - struct type *type; - /* Containing DWO unit. This field is valid iff per_cu.reading_dwo_directly. */ struct dwo_unit *dwo_unit;