aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2025-03-17 23:16:25 -0400
committerSimon Marchi <simon.marchi@efficios.com>2025-03-18 15:45:09 -0400
commitc08c2adbb03ecd4fa9338932f26143389bf1135e (patch)
treeab847b683e99dd103ae96c648435002e4f0f65c7 /gdb/dwarf2/read.h
parentd87251a45bceebbc90eed3161adb8ce75e35f959 (diff)
downloadbinutils-c08c2adbb03ecd4fa9338932f26143389bf1135e.zip
binutils-c08c2adbb03ecd4fa9338932f26143389bf1135e.tar.gz
binutils-c08c2adbb03ecd4fa9338932f26143389bf1135e.tar.bz2
gdb/dwarf: remove type_unit_group
The type_unit_group is an indirection between a stmt_list_hash (possible dwo_unit + line table section offset) and a type_unit_group_unshareable that provides no real value. In dwarf2_per_objfile, we maintain a stmt_list_hash -> type_unit_group mapping, and in dwarf2_per_objfile, we maintain a type_unit_group_unshareable mapping. The type_unit_group type is empty and only exists to have an identity and to be a link between the two mappings. This patch changes it so that we have a single stmt_list_hash -> type_unit_group_unshareable mapping. Regression tested on Debian 12 amd64 with a bunch of DWARF target boards. Change-Id: I9c5778ecb18963f353e9dd058e0f8152f7d8930c Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/dwarf2/read.h')
-rw-r--r--gdb/dwarf2/read.h52
1 files changed, 29 insertions, 23 deletions
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 44fd7e9..ba2dd07 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -55,7 +55,6 @@ struct dwarf2_per_cu;
struct mapped_index;
struct mapped_debug_names;
struct signatured_type;
-struct type_unit_group;
/* One item on the queue of compilation units to read in full symbols
for. */
@@ -74,6 +73,27 @@ struct dwarf2_queue_item
dwarf2_per_objfile *per_objfile;
};
+/* A struct that can be used as a hash key for tables based on DW_AT_stmt_list.
+ This includes type_unit_group and quick_file_names. */
+
+struct stmt_list_hash
+{
+ bool operator== (const stmt_list_hash &other) const noexcept;
+
+ /* The DWO unit this table is from or NULL if there is none. */
+ struct dwo_unit *dwo_unit;
+
+ /* Offset in .debug_line or .debug_line.dwo. */
+ sect_offset line_sect_off;
+};
+
+struct stmt_list_hash_hash
+{
+ using is_avalanching = void;
+
+ std::uint64_t operator() (const stmt_list_hash &key) const noexcept;
+};
+
/* A deleter for dwarf2_per_cu that knows to downcast to signatured_type as
appropriate. This approach lets us avoid a virtual destructor, which saves
a bit of space. */
@@ -376,8 +396,9 @@ struct signatured_type : public dwarf2_per_cu
sect_offset type_offset_in_section {};
/* Type units are grouped by their DW_AT_stmt_list entry so that they
- can share them. This points to the containing symtab. */
- struct type_unit_group *type_unit_group = nullptr;
+ can share them. This is the key of the group this type unit is part
+ of. */
+ std::optional<stmt_list_hash> type_unit_group_key;
/* Containing DWO unit.
This field is valid iff per_cu.reading_dwo_directly. */
@@ -467,17 +488,6 @@ struct dwp_file;
using dwp_file_up = std::unique_ptr<dwp_file>;
-struct stmt_list_hash;
-
-struct stmt_list_hash_hash
-{
- using is_avalanching = void;
-
- std::uint64_t operator() (const stmt_list_hash &key) const noexcept;
-};
-
-using type_unit_group_up = std::unique_ptr<type_unit_group>;
-
/* Some DWARF data can be shared across objfiles who share the same BFD,
this data is stored in this object.
@@ -614,11 +624,6 @@ public:
std::vector<dwarf2_per_cu *> all_comp_units_index_cus;
std::vector<dwarf2_per_cu *> all_comp_units_index_tus;
- /* Table of struct type_unit_group objects.
- The hash key is the DW_AT_stmt_list value. */
- gdb::unordered_map<stmt_list_hash, type_unit_group_up, stmt_list_hash_hash>
- type_unit_groups;
-
/* Set of signatured_types, used to look up by signature. */
signatured_type_set signatured_types;
@@ -828,10 +833,10 @@ struct dwarf2_per_objfile
/* Set the compunit_symtab associated to PER_CU. */
void set_symtab (const dwarf2_per_cu *per_cu, compunit_symtab *symtab);
- /* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one
+ /* Get the type_unit_group_unshareable corresponding to TU_GROUP_KEY. If one
does not exist, create it. */
type_unit_group_unshareable *get_type_unit_group_unshareable
- (type_unit_group *tu_group);
+ (stmt_list_hash tu_group_key);
struct type *get_type_for_signatured_type (signatured_type *sig_type) const;
@@ -898,9 +903,10 @@ private:
expanded yet. */
std::vector<compunit_symtab *> m_symtabs;
- /* Map from a type unit group to the corresponding unshared
+ /* Map from a type unit group key to the corresponding unshared
structure. */
- gdb::unordered_map<type_unit_group *, type_unit_group_unshareable_up>
+ gdb::unordered_map<stmt_list_hash, type_unit_group_unshareable_up,
+ stmt_list_hash_hash>
m_type_units;
/* Map from signatured types to the corresponding struct type. */