[13/14] Move signatured_type::type to unshareable object
Commit Message
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.
2020-02-15 Tom Tromey <tom@tromey.com>
* dwarf2/read.h (struct dwarf2_unshareable) <type_map>: New
member.
(struct signatured_type) <type>: Remove.
* dwarf2/read.c (get_signatured_type): Use type_map.
---
gdb/ChangeLog | 7 +++++++
gdb/dwarf2/read.c | 7 ++++---
gdb/dwarf2/read.h | 8 +++-----
3 files changed, 14 insertions(+), 8 deletions(-)
@@ -22767,8 +22767,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;
+ auto iter = dwarf2_per_objfile->unshareable->type_map.find (sig_type);
+ if (iter != dwarf2_per_objfile->unshareable->type_map.end ())
+ return iter->second;
type_cu = cu;
type_die = follow_die_sig_1 (die, sig_type, &type_cu);
@@ -22795,7 +22796,7 @@ 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->unshareable->type_map[sig_type] = type;
return type;
}
@@ -112,6 +112,9 @@ struct dwarf2_unshareable
structure. */
std::unordered_map<type_unit_group *, std::unique_ptr<type_unit_unshareable>>
type_units;
+
+ /* Map from signatured types to the corresponding struct type. */
+ std::unordered_map<signatured_type *, struct type *> type_map;
};
/* Collection of data recorded per objfile.
@@ -574,11 +577,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;