@@ -119,53 +119,29 @@ dwarf2_cu::addr_type () const
return addr_type;
}
-/* A hashtab traversal function that marks the dependent CUs. */
-
-static int
-dwarf2_mark_helper (void **slot, void *data)
-{
- dwarf2_per_cu_data *per_cu = (dwarf2_per_cu_data *) *slot;
- dwarf2_per_objfile *per_objfile = (dwarf2_per_objfile *) data;
- dwarf2_cu *cu = per_objfile->get_cu (per_cu);
-
- /* cu->m_dependencies references may not yet have been ever read if
- QUIT aborts reading of the chain. As such dependencies remain
- valid it is not much useful to track and undo them during QUIT
- cleanups. */
- if (cu != nullptr)
- cu->mark ();
- return 1;
-}
-
/* See dwarf2/cu.h. */
void
dwarf2_cu::mark ()
{
- if (!m_mark)
- {
- m_mark = true;
- if (m_dependencies != nullptr)
- htab_traverse_noresize (m_dependencies.get (), dwarf2_mark_helper,
- per_objfile);
- }
-}
+ if (m_mark)
+ return;
-/* See dwarf2/cu.h. */
+ m_mark = true;
-void
-dwarf2_cu::add_dependence (struct dwarf2_per_cu_data *ref_per_cu)
-{
- void **slot;
+ for (dwarf2_per_cu_data *per_cu : m_dependencies)
+ {
+ /* cu->m_dependencies references may not yet have been ever
+ read if QUIT aborts reading of the chain. As such
+ dependencies remain valid it is not much useful to track
+ and undo them during QUIT cleanups. */
+ dwarf2_cu *cu = per_objfile->get_cu (per_cu);
- if (m_dependencies == nullptr)
- m_dependencies.reset (htab_create_alloc
- (5, htab_hash_pointer, htab_eq_pointer,
- nullptr, xcalloc, xfree));
+ if (cu == nullptr)
+ continue;
- slot = htab_find_slot (m_dependencies.get (), ref_per_cu, INSERT);
- if (*slot == nullptr)
- *slot = ref_per_cu;
+ cu->mark ();
+ }
}
/* See dwarf2/cu.h. */
@@ -24,6 +24,7 @@
#include "dwarf2/comp-unit-head.h"
#include <optional>
#include "language.h"
+#include "gdbsupport/unordered_set.h"
/* Type used for delaying computation of method physnames.
See comments for compute_delayed_physnames. */
@@ -95,7 +96,8 @@ struct dwarf2_cu
}
/* Add a dependence relationship from this cu to REF_PER_CU. */
- void add_dependence (struct dwarf2_per_cu_data *ref_per_cu);
+ void add_dependence (struct dwarf2_per_cu_data *ref_per_cu)
+ { m_dependencies.emplace (ref_per_cu); }
/* The header of the compilation unit. */
struct comp_unit_head header;
@@ -120,9 +122,9 @@ struct dwarf2_cu
std::unique_ptr<buildsym_compunit> m_builder;
/* A set of pointers to dwarf2_per_cu_data objects for compilation
- units referenced by this one. Only set during full symbol processing;
+ units referenced by this one. Only used during full symbol processing;
partial symbol tables do not have dependencies. */
- htab_up m_dependencies;
+ gdb::unordered_set<dwarf2_per_cu_data *> m_dependencies;
public:
/* The generic symbol table building routines have separate lists for
@@ -96,6 +96,7 @@
#include "gdbsupport/thread-pool.h"
#include "run-on-main-thread.h"
#include "dwarf2/parent-map.h"
+#include "gdbsupport/unordered_dense.h"
/* When == 1, print basic high level tracing messages.
When > 1, be more verbose.
@@ -2876,12 +2877,8 @@ dw_expand_symtabs_matching_file_matcher
if (file_matcher == NULL)
return;
- htab_up visited_found (htab_create_alloc (10, htab_hash_pointer,
- htab_eq_pointer,
- NULL, xcalloc, xfree));
- htab_up visited_not_found (htab_create_alloc (10, htab_hash_pointer,
- htab_eq_pointer,
- NULL, xcalloc, xfree));
+ gdb::unordered_set<quick_file_names *> visited_found;
+ gdb::unordered_set<quick_file_names *> visited_not_found;
/* The rule is CUs specify all the files, including those used by
any TU, so there's no need to scan TUs here. */
@@ -2924,9 +2921,9 @@ dw_expand_symtabs_matching_file_matcher
if (file_data == NULL)
continue;
- if (htab_find (visited_not_found.get (), file_data) != NULL)
+ if (visited_not_found.contains (file_data))
continue;
- else if (htab_find (visited_found.get (), file_data) != NULL)
+ else if (visited_found.contains (file_data))
{
per_cu->mark = 1;
continue;
@@ -2957,11 +2954,10 @@ dw_expand_symtabs_matching_file_matcher
}
}
- void **slot = htab_find_slot (per_cu->mark
- ? visited_found.get ()
- : visited_not_found.get (),
- file_data, INSERT);
- *slot = file_data;
+ if (per_cu->mark)
+ visited_found.insert (file_data);
+ else
+ visited_not_found.insert (file_data);
}
}
@@ -6036,21 +6032,21 @@ void dwarf2_per_objfile::set_type_for_signatured_type
included by PER_CU. */
static void
-recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
- htab_t all_children, htab_t all_type_symtabs,
- dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *per_objfile,
- struct compunit_symtab *immediate_parent)
+recursively_compute_inclusions
+ (std::vector<compunit_symtab *> *result,
+ gdb::unordered_set<dwarf2_per_cu_data *> &all_children,
+ gdb::unordered_set<compunit_symtab *> &all_type_symtabs,
+ dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile,
+ struct compunit_symtab *immediate_parent)
{
- void **slot = htab_find_slot (all_children, per_cu, INSERT);
- if (*slot != NULL)
+ if (bool inserted = all_children.emplace (per_cu).second;
+ !inserted)
{
/* This inclusion and its children have been processed. */
return;
}
- *slot = per_cu;
-
/* Only add a CU if it has a symbol table. */
compunit_symtab *cust = per_objfile->get_symtab (per_cu);
if (cust != NULL)
@@ -6059,10 +6055,9 @@ recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
seen it yet (type unit per_cu's can share symtabs). */
if (per_cu->is_debug_types)
{
- slot = htab_find_slot (all_type_symtabs, cust, INSERT);
- if (*slot == NULL)
+ if (bool inserted = all_type_symtabs.insert (cust).second;
+ inserted)
{
- *slot = cust;
result->push_back (cust);
if (cust->user == NULL)
cust->user = immediate_parent;
@@ -6101,16 +6096,12 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu,
if (cust == NULL)
return;
- htab_up all_children (htab_create_alloc (1, htab_hash_pointer,
- htab_eq_pointer,
- NULL, xcalloc, xfree));
- htab_up all_type_symtabs (htab_create_alloc (1, htab_hash_pointer,
- htab_eq_pointer,
- NULL, xcalloc, xfree));
+ gdb::unordered_set<dwarf2_per_cu_data *> all_children;
+ gdb::unordered_set<compunit_symtab *> all_type_symtabs;
for (dwarf2_per_cu_data *ptr : per_cu->imported_symtabs)
- recursively_compute_inclusions (&result_symtabs, all_children.get (),
- all_type_symtabs.get (), ptr,
+ recursively_compute_inclusions (&result_symtabs, all_children,
+ all_type_symtabs, ptr,
per_objfile, cust);
/* Now we have a transitive closure of all the included symtabs. */