aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-11-22 16:53:34 -0700
committerTom Tromey <tom@tromey.com>2022-04-20 09:10:03 -0600
commitf75a1d3a732d96ed4adadddaaeafe17732453256 (patch)
tree3befd6320ccd834bd306113972f0e1568fcd85a9 /gdb/dwarf2
parentc1a56932c4b61f1fe81ce847cb40770203ffd16f (diff)
downloadgdb-f75a1d3a732d96ed4adadddaaeafe17732453256.zip
gdb-f75a1d3a732d96ed4adadddaaeafe17732453256.tar.gz
gdb-f75a1d3a732d96ed4adadddaaeafe17732453256.tar.bz2
Add an ad hoc version check to dwarf_scanner_base
Some generic code in the DWARF reader has a special case for older versions of .gdb_index. This patch adds an ad hoc version check method so that these spots can work without specific knowledge of which index is in use.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/mapped-index.h8
-rw-r--r--gdb/dwarf2/read.c9
2 files changed, 15 insertions, 2 deletions
diff --git a/gdb/dwarf2/mapped-index.h b/gdb/dwarf2/mapped-index.h
index 39a9ede..e5d7746 100644
--- a/gdb/dwarf2/mapped-index.h
+++ b/gdb/dwarf2/mapped-index.h
@@ -58,6 +58,14 @@ struct dwarf_scanner_base
/* Return a quick_symbol_functions instance that refers back to this
dwarf_scanner_base. */
virtual quick_symbol_functions_up make_quick_functions () const = 0;
+
+ /* An ad hoc version check. This is needed for .gdb_index to check
+ whether a version 8 or above index is in use. Returns true if
+ the index is usable, false otherwise. */
+ virtual bool version_check () const
+ {
+ return true;
+ }
};
/* Base class containing bits shared by both .gdb_index and
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index f340cd6..aa3bf6e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -245,6 +245,11 @@ struct mapped_index final : public mapped_index_base
{ return this->symbol_table.size () / 2; }
quick_symbol_functions_up make_quick_functions () const override;
+
+ bool version_check () const override
+ {
+ return version >= 8;
+ }
};
/* A description of the mapped .debug_names.
@@ -2038,7 +2043,7 @@ dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu,
&& cu != NULL
&& cu->dwo_unit != NULL
&& per_objfile->per_bfd->index_table != NULL
- && per_objfile->per_bfd->index_table->version <= 7
+ && !per_objfile->per_bfd->index_table->version_check ()
/* DWP files aren't supported yet. */
&& get_dwp_file (per_objfile) == NULL)
queue_and_load_all_dwo_tus (cu);
@@ -22576,7 +22581,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type,
/* For .gdb_index version 7 keep track of included TUs.
http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */
if (per_objfile->per_bfd->index_table != NULL
- && per_objfile->per_bfd->index_table->version <= 7)
+ && !per_objfile->per_bfd->index_table->version_check ())
{
(*ref_cu)->per_cu->imported_symtabs_push (sig_cu->per_cu);
}