public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Simplify DWARF symtab inclusion handling
@ 2024-01-20 0:43 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-01-20 0:43 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4a2318c9858fdb1899157339f526df3d20e43cfe
commit 4a2318c9858fdb1899157339f526df3d20e43cfe
Author: Tom Tromey <tom@tromey.com>
Date: Sun Jan 14 18:21:42 2024 -0700
Simplify DWARF symtab inclusion handling
In the past, dwarf2_per_cu_data was allocated using malloc, so special
handling was needed for the vector used for symtab handling. We
changed this to use 'new' a while back, so this code can now be
greatly simplified.
Regression tested on x86-64 Fedora 38.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diff:
---
gdb/dwarf2/read.c | 36 +++++++++++++-----------------------
gdb/dwarf2/read.h | 46 +++-------------------------------------------
2 files changed, 16 insertions(+), 66 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7691fe0050b..6be8f818ec6 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1280,10 +1280,7 @@ dwarf2_per_bfd::~dwarf2_per_bfd ()
index_table->wait_completely ();
for (auto &per_cu : all_units)
- {
- per_cu->imported_symtabs_free ();
- per_cu->free_cached_file_names ();
- }
+ per_cu->free_cached_file_names ();
/* Everything else should be on this->obstack. */
}
@@ -6103,13 +6100,10 @@ recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
}
}
- if (!per_cu->imported_symtabs_empty ())
- for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs)
- {
- recursively_compute_inclusions (result, all_children,
- all_type_symtabs, ptr, per_objfile,
- cust);
- }
+ for (dwarf2_per_cu_data *ptr : per_cu->imported_symtabs)
+ recursively_compute_inclusions (result, all_children,
+ all_type_symtabs, ptr, per_objfile,
+ cust);
}
/* Compute the compunit_symtab 'includes' fields for the compunit_symtab of
@@ -6121,7 +6115,7 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu,
{
gdb_assert (! per_cu->is_debug_types);
- if (!per_cu->imported_symtabs_empty ())
+ if (!per_cu->imported_symtabs.empty ())
{
int len;
std::vector<compunit_symtab *> result_symtabs;
@@ -6138,12 +6132,10 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu,
htab_eq_pointer,
NULL, xcalloc, xfree));
- for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs)
- {
- recursively_compute_inclusions (&result_symtabs, all_children.get (),
- all_type_symtabs.get (), ptr,
- per_objfile, cust);
- }
+ for (dwarf2_per_cu_data *ptr : per_cu->imported_symtabs)
+ recursively_compute_inclusions (&result_symtabs, all_children.get (),
+ all_type_symtabs.get (), ptr,
+ per_objfile, cust);
/* Now we have a transitive closure of all the included symtabs. */
len = result_symtabs.size ();
@@ -6391,7 +6383,7 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu)
load_full_comp_unit (per_cu, per_objfile, per_objfile->get_cu (per_cu),
false, cu->lang ());
- cu->per_cu->imported_symtabs_push (per_cu);
+ cu->per_cu->imported_symtabs.push_back (per_cu);
}
}
@@ -9651,7 +9643,7 @@ queue_and_load_dwo_tu (void **slot, void *info)
if (maybe_queue_comp_unit (NULL, sig_type, cu->per_objfile,
cu->lang ()))
load_full_type_unit (sig_type, cu->per_objfile);
- cu->per_cu->imported_symtabs_push (sig_type);
+ cu->per_cu->imported_symtabs.push_back (sig_type);
}
return 1;
@@ -20701,9 +20693,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type,
http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */
if (per_objfile->per_bfd->index_table != NULL
&& !per_objfile->per_bfd->index_table->version_check ())
- {
- (*ref_cu)->per_cu->imported_symtabs_push (sig_cu->per_cu);
- }
+ (*ref_cu)->per_cu->imported_symtabs.push_back (sig_cu->per_cu);
*ref_cu = sig_cu;
return die;
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 66c6fe3fe87..424802fd0c8 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -227,10 +227,7 @@ public:
NOTE: This points into dwarf2_per_objfile->per_bfd->quick_file_names_table. */
struct quick_file_names *file_names = nullptr;
- /* The CUs we import using DW_TAG_imported_unit. This is filled in
- while reading psymtabs, used to compute the psymtab dependencies,
- and then cleared. Then it is filled in again while reading full
- symbols, and only deleted when the objfile is destroyed.
+ /* The CUs we import using DW_TAG_imported_unit.
This is also used to work around a difference between the way gold
generates .gdb_index version <=7 and the way gdb does. Arguably this
@@ -244,45 +241,8 @@ public:
.gdb_index version <=7 this also records the TUs that the CU referred
to. Concurrently with this change gdb was modified to emit version 8
indices so we only pay a price for gold generated indices.
- http://sourceware.org/bugzilla/show_bug.cgi?id=15021.
-
- This currently needs to be a public member due to how
- dwarf2_per_cu_data is allocated and used. Ideally in future things
- could be refactored to make this private. Until then please try to
- avoid direct access to this member, and instead use the helper
- functions above. */
- std::vector <dwarf2_per_cu_data *> *imported_symtabs = nullptr;
-
- /* Return true of IMPORTED_SYMTABS is empty or not yet allocated. */
- bool imported_symtabs_empty () const
- {
- return (imported_symtabs == nullptr || imported_symtabs->empty ());
- }
-
- /* Push P to the back of IMPORTED_SYMTABS, allocated IMPORTED_SYMTABS
- first if required. */
- void imported_symtabs_push (dwarf2_per_cu_data *p)
- {
- if (imported_symtabs == nullptr)
- imported_symtabs = new std::vector <dwarf2_per_cu_data *>;
- imported_symtabs->push_back (p);
- }
-
- /* Return the size of IMPORTED_SYMTABS if it is allocated, otherwise
- return 0. */
- size_t imported_symtabs_size () const
- {
- if (imported_symtabs == nullptr)
- return 0;
- return imported_symtabs->size ();
- }
-
- /* Delete IMPORTED_SYMTABS and set the pointer back to nullptr. */
- void imported_symtabs_free ()
- {
- delete imported_symtabs;
- imported_symtabs = nullptr;
- }
+ http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */
+ std::vector<dwarf2_per_cu_data *> imported_symtabs;
/* Get the header of this per_cu, reading it if necessary. */
const comp_unit_head *get_header () const;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-20 0:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-20 0:43 [binutils-gdb] Simplify DWARF symtab inclusion handling Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).