From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 609223857378; Wed, 20 Apr 2022 15:12:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 609223857378 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] Introduce and use dwarf_scanner_base X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 045a7baed2e8039fc734b43f4f35393c76e59e55 X-Git-Newrev: 6606799fc4aaf812d0986166f57c9849b5d562ed Message-Id: <20220420151217.609223857378@sourceware.org> Date: Wed, 20 Apr 2022 15:12:17 +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:17 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6606799fc4aa= f812d0986166f57c9849b5d562ed commit 6606799fc4aaf812d0986166f57c9849b5d562ed Author: Tom Tromey Date: Mon Nov 22 16:43:47 2021 -0700 Introduce and use dwarf_scanner_base =20 This introduces dwarf_scanner_base, a base class for all the index readers in the DWARF code. Then, it changes both mapped_index_base and cooked_index_vector to derive from this new base class. Diff: --- gdb/dwarf2/cooked-index.h | 5 ++++- gdb/dwarf2/mapped-index.h | 20 ++++++++++++++------ gdb/dwarf2/read.c | 9 ++++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 4b52eaf93d0..e1ff05645c5 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -31,6 +31,7 @@ #include "addrmap.h" #include "gdbsupport/iterator-range.h" #include "gdbsupport/thread-pool.h" +#include "dwarf2/mapped-index.h" =20 struct dwarf2_per_cu_data; =20 @@ -241,7 +242,7 @@ private: cooked_index_vector for storage and final indexing. The index is made by iterating over the entries previously created. */ =20 -class cooked_index_vector +class cooked_index_vector : public dwarf_scanner_base { public: =20 @@ -291,6 +292,8 @@ public: "main". This will return NULL if no such entry is available. */ const cooked_index_entry *get_main () const; =20 + quick_symbol_functions_up make_quick_functions () const override; + private: =20 /* GNAT only emits mangled ("encoded") names in the DWARF, and does diff --git a/gdb/dwarf2/mapped-index.h b/gdb/dwarf2/mapped-index.h index 9f51a9e6578..39a9ede4896 100644 --- a/gdb/dwarf2/mapped-index.h +++ b/gdb/dwarf2/mapped-index.h @@ -47,13 +47,25 @@ struct name_component offset_type idx; }; =20 +/* Base class of all DWARF scanner types. */ + +struct dwarf_scanner_base +{ + dwarf_scanner_base () =3D default; + virtual ~dwarf_scanner_base () =3D default; + DISABLE_COPY_AND_ASSIGN (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; +}; + /* Base class containing bits shared by both .gdb_index and .debug_name indexes. */ =20 -struct mapped_index_base +struct mapped_index_base : public dwarf_scanner_base { mapped_index_base () =3D default; - virtual ~mapped_index_base() =3D default; DISABLE_COPY_AND_ASSIGN (mapped_index_base); =20 /* The name_component table (a sorted vector). See name_component's @@ -77,10 +89,6 @@ struct mapped_index_base return false; } =20 - /* Return a quick_symbol_functions instance that refers back to this - mapped_index_base. */ - virtual quick_symbol_functions_up make_quick_functions () const =3D 0; - /* Build the symbol name component sorted vector, if we haven't yet. */ void build_name_components (dwarf2_per_objfile *per_objfile); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 83651f21d31..3053ec9b303 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5301,7 +5301,8 @@ dwarf2_initialize_objfile (struct objfile *objfile) if (per_bfd->cooked_index_table !=3D nullptr) { dwarf_read_debug_printf ("re-using cooked index table"); - objfile->qf.push_front (make_cooked_index_funcs ()); + objfile->qf.push_front + (per_bfd->cooked_index_table->make_quick_functions ()); return; } =20 @@ -18682,6 +18683,12 @@ make_cooked_index_funcs () return quick_symbol_functions_up (new cooked_index_functions); } =20 +quick_symbol_functions_up +cooked_index_vector::make_quick_functions () const +{ + return make_cooked_index_funcs (); +} + =0C =20 /* Read the .debug_loclists or .debug_rnglists header (they are the same f= ormat)