From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 7F1343856DC2; Wed, 20 Apr 2022 15:12:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F1343856DC2 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Add an ad hoc version check to dwarf_scanner_base X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: c1a56932c4b61f1fe81ce847cb40770203ffd16f X-Git-Newrev: f75a1d3a732d96ed4adadddaaeafe17732453256 Message-Id: <20220420151227.7F1343856DC2@sourceware.org> Date: Wed, 20 Apr 2022 15:12:27 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2022 15:12:27 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df75a1d3a732d= 96ed4adadddaaeafe17732453256 commit f75a1d3a732d96ed4adadddaaeafe17732453256 Author: Tom Tromey Date: Mon Nov 22 16:53:34 2021 -0700 Add an ad hoc version check to dwarf_scanner_base =20 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. Diff: --- gdb/dwarf2/mapped-index.h | 8 ++++++++ gdb/dwarf2/read.c | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/mapped-index.h b/gdb/dwarf2/mapped-index.h index 39a9ede4896..e5d77469925 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 =3D 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; + } }; =20 /* Base class containing bits shared by both .gdb_index and diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f340cd68e67..aa3bf6e2f25 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; } =20 quick_symbol_functions_up make_quick_functions () const override; + + bool version_check () const override + { + return version >=3D 8; + } }; =20 /* A description of the mapped .debug_names. @@ -2038,7 +2043,7 @@ dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu, && cu !=3D NULL && cu->dwo_unit !=3D NULL && per_objfile->per_bfd->index_table !=3D NULL - && per_objfile->per_bfd->index_table->version <=3D 7 + && !per_objfile->per_bfd->index_table->version_check () /* DWP files aren't supported yet. */ && get_dwp_file (per_objfile) =3D=3D 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=3D15021. */ if (per_objfile->per_bfd->index_table !=3D NULL - && per_objfile->per_bfd->index_table->version <=3D 7) + && !per_objfile->per_bfd->index_table->version_check ()) { (*ref_cu)->per_cu->imported_symtabs_push (sig_cu->per_cu); }