public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 8/9] Add an ad hoc version check to dwarf_scanner_base
Date: Tue, 19 Apr 2022 22:29:05 -0600	[thread overview]
Message-ID: <20220420042906.1973648-9-tom@tromey.com> (raw)
In-Reply-To: <20220420042906.1973648-1-tom@tromey.com>

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.
---
 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 = 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 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; }
 
   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);
 	}
-- 
2.34.1


  parent reply	other threads:[~2022-04-20  4:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20  4:28 [PATCH 0/9] Unify the DWARF index fields Tom Tromey
2022-04-20  4:28 ` [PATCH 1/9] Move mapped_index_base to new header file Tom Tromey
2022-04-20 20:38   ` Lancelot SIX
2022-04-21 15:15     ` Pedro Alves
2022-04-20  4:28 ` [PATCH 2/9] Give mapped_index_base a virtual destructor Tom Tromey
2022-04-20  4:29 ` [PATCH 3/9] Let mapped index classes create the quick_symbol_functions object Tom Tromey
2022-04-20  4:29 ` [PATCH 4/9] Remove some "OBJF_READNOW" code from dwarf2_debug_names_index Tom Tromey
2022-04-20  4:29 ` [PATCH 5/9] Introduce readnow_functions Tom Tromey
2022-04-20  4:29 ` [PATCH 6/9] Introduce and use dwarf_scanner_base Tom Tromey
2022-04-20  4:29 ` [PATCH 7/9] Simplify version check in dw2_symtab_iter_next Tom Tromey
2022-04-20 20:49   ` Lancelot SIX
2022-04-20  4:29 ` Tom Tromey [this message]
2022-04-20  4:29 ` [PATCH 9/9] Unify the DWARF index holders Tom Tromey
2022-04-20 12:15   ` Pedro Alves
2022-04-20 12:53     ` Tom Tromey
2022-04-20 13:52       ` Pedro Alves
2022-04-20 14:53         ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420042906.1973648-9-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).