aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/dwarf2/read.c27
-rw-r--r--gdb/dwarf2/read.h17
3 files changed, 47 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f821370..a3dec4f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,6 +1,19 @@
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>
+
* dwarf2/read.h (struct type_unit_group_unshareable): New.
(struct dwarf2_per_objfile) <type_units>: New member.
<get_type_unit_group_unshareable>: New method.
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 53def0c..7819fc5 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 13d31a9..3500b0e 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<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. */
@@ -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;