+2020-05-27 Tom Tromey <tom@tromey.com>
+ Simon Marchi <simon.marchi@efficios.com>
+
+ * dwarf2/read.h (struct dwarf2_per_objfile)
+ <get_type_for_signatured_type, set_type_for_signatured_type>:
+ New methods.
+ <m_type_map>: New member.
+ (struct signatured_type) <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 <tom@tromey.com>
Simon Marchi <simon.marchi@efficios.com>
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. */
}
/* 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);
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;
}
/* 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;
std::unordered_map<type_unit_group *, type_unit_group_unshareable_up>
m_type_units;
+
+ /* Map from signatured types to the corresponding struct type. */
+ std::unordered_map<signatured_type *, struct type *> m_type_map;
};
/* Get the dwarf2_per_objfile associated to OBJFILE. */
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;