From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 4/4] Simplify debug_names index writing
Date: Sat, 29 May 2021 07:54:43 -0600 [thread overview]
Message-ID: <20210529135443.1446279-5-tom@tromey.com> (raw)
In-Reply-To: <20210529135443.1446279-1-tom@tromey.com>
Like the previous patch, this changes the .debug_names writer to find
the TU indices in the main loop over all CUs and TUs.
2021-05-29 Tom Tromey <tom@tromey.com>
* dwarf2/index-write.c (struct signatured_type_index_data):
Remove.
(debug_names::write_one_signatured_type_data)
(debug_names::write_one_signatured_type): Remove.
(write_debug_names): Write type CUs in loop.
---
gdb/ChangeLog | 8 ++++
gdb/dwarf2/index-write.c | 93 +++++-----------------------------------
2 files changed, 18 insertions(+), 83 deletions(-)
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 06c8e1026f0..6e593310d28 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -585,21 +585,6 @@ write_psymbols (struct mapped_symtab *symtab,
}
}
-/* A helper struct used when iterating over debug_types. */
-struct signatured_type_index_data
-{
- signatured_type_index_data (data_buf &types_list_,
- std::unordered_set<partial_symbol *> &psyms_seen_)
- : types_list (types_list_), psyms_seen (psyms_seen_)
- {}
-
- struct objfile *objfile;
- struct mapped_symtab *symtab;
- data_buf &types_list;
- std::unordered_set<partial_symbol *> &psyms_seen;
- int cu_index;
-};
-
/* Recurse into all "included" dependencies and count their symbols as
if they appeared in this psymtab. */
@@ -902,32 +887,6 @@ class debug_names
m_debugstrlookup.file_write (file_str);
}
- /* A helper user data for write_one_signatured_type. */
- class write_one_signatured_type_data
- {
- public:
- write_one_signatured_type_data (debug_names &nametable_,
- signatured_type_index_data &&info_)
- : nametable (nametable_), info (std::move (info_))
- {}
- debug_names &nametable;
- struct signatured_type_index_data info;
- };
-
- /* A helper function to pass write_one_signatured_type to
- htab_traverse_noresize. */
- static int
- write_one_signatured_type (void **slot, void *d)
- {
- write_one_signatured_type_data *data = (write_one_signatured_type_data *) d;
- struct signatured_type_index_data *info = &data->info;
- struct signatured_type *entry = (struct signatured_type *) *slot;
-
- data->nametable.write_one_signatured_type (entry, info);
-
- return 1;
- }
-
private:
/* Storage for symbol names mapping them to their .debug_str section
@@ -1210,25 +1169,6 @@ class debug_names
}
}
- /* A helper function that writes a single signatured_type
- to a debug_names. */
- void
- write_one_signatured_type (struct signatured_type *entry,
- struct signatured_type_index_data *info)
- {
- partial_symtab *psymtab = entry->v.psymtab;
-
- write_psymbols (info->psyms_seen, psymtab->global_psymbols,
- info->cu_index, false, unit_kind::tu);
- write_psymbols (info->psyms_seen, psymtab->static_psymbols,
- info->cu_index, true, unit_kind::tu);
-
- info->types_list.append_uint (dwarf5_offset_size (), m_dwarf5_byte_order,
- to_underlying (entry->sect_off));
-
- ++info->cu_index;
- }
-
/* Store value of each symbol. */
std::unordered_map<c_str_view, std::set<symbol_value>, c_str_view_hasher>
m_name_to_value_set;
@@ -1475,17 +1415,16 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
work here. Also, the debug_types entries do not appear in
all_comp_units, but only in their own hash table. */
data_buf cu_list;
+ data_buf types_cu_list;
debug_names nametable (per_objfile, dwarf5_is_dwarf64, dwarf5_byte_order);
std::unordered_set<partial_symbol *>
psyms_seen (psyms_seen_size (per_objfile));
int counter = 0;
+ int types_counter = 0;
for (int i = 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i)
{
const dwarf2_per_cu_data *per_cu
= per_objfile->per_bfd->all_comp_units[i].get ();
- if (per_cu->is_debug_types)
- continue;
-
partial_symtab *psymtab = per_cu->v.psymtab;
/* CU of a shared file from 'dwz -m' may be unused by this main
@@ -1494,29 +1433,17 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
if (psymtab == NULL)
continue;
+ int &this_counter = per_cu->is_debug_types ? types_counter : counter;
+ data_buf &this_list = per_cu->is_debug_types ? types_cu_list : cu_list;
+
if (psymtab->user == NULL)
nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen,
- counter);
-
- cu_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order,
- to_underlying (per_cu->sect_off));
- ++counter;
- }
+ this_counter);
- /* Write out the .debug_type entries, if any. */
- data_buf types_cu_list;
- if (per_objfile->per_bfd->signatured_types)
- {
- debug_names::write_one_signatured_type_data sig_data (nametable,
- signatured_type_index_data (types_cu_list, psyms_seen));
-
- sig_data.info.objfile = objfile;
- /* It is used only for gdb_index. */
- sig_data.info.symtab = nullptr;
- sig_data.info.cu_index = 0;
- htab_traverse_noresize (per_objfile->per_bfd->signatured_types.get (),
- debug_names::write_one_signatured_type,
- &sig_data);
+ this_list.append_uint (nametable.dwarf5_offset_size (),
+ dwarf5_byte_order,
+ to_underlying (per_cu->sect_off));
+ ++this_counter;
}
nametable.build ();
--
2.26.3
next prev parent reply other threads:[~2021-05-29 13:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-29 13:54 [PATCH 0/4] Some small debug index writer cleanups Tom Tromey
2021-05-29 13:54 ` [PATCH 1/4] Fix oddity in write_gdbindex Tom Tromey
2021-05-29 13:54 ` [PATCH 2/4] Minor cleanup to addrmap_index_data::previous_valid Tom Tromey
2021-06-13 16:48 ` Lancelot SIX via Gdb-patches
2021-06-14 20:14 ` Tom Tromey
2021-05-29 13:54 ` [PATCH 3/4] Simplify gdb_index writing Tom Tromey
2021-05-29 13:54 ` Tom Tromey [this message]
2021-07-05 17:56 ` [PATCH 0/4] Some small debug index writer cleanups Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210529135443.1446279-5-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox