public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 02/17] Refactor quick-function installation in DWARF reader
Date: Wed, 17 Jan 2024 09:39:30 -0700	[thread overview]
Message-ID: <20240117-debug-names-fix-v2-2-dbd5971a9c31@tromey.com> (raw)
In-Reply-To: <20240117-debug-names-fix-v2-0-dbd5971a9c31@tromey.com>

While working on the previous patch, I saw that the handling of
quick-function installation could be unified
dwarf2_initialize_objfile.  In particular, at the end of the function,
if there is an index table, then it can be used to create the quick
function object.

This cleanup will be useful when rewriting the .debug_names reader.
---
 gdb/dwarf2/read.c | 38 ++++++++++++++------------------------
 1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e0eb1f9ce3c..84cbc1ac9af 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -3190,8 +3190,7 @@ get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz)
   return global_index_cache.lookup_gdb_index (build_id, &dwz->index_cache_res);
 }
 
-static quick_symbol_functions_up make_cooked_index_funcs
-     (dwarf2_per_objfile *);
+static void start_debug_info_reader (dwarf2_per_objfile *);
 
 /* See dwarf2/public.h.  */
 
@@ -3236,23 +3235,13 @@ dwarf2_initialize_objfile (struct objfile *objfile,
   /* Was a GDB index already read when we processed an objfile sharing
      PER_BFD?  */
   else if (per_bfd->index_table != nullptr)
-    {
-      dwarf_read_debug_printf ("re-using symbols");
-      objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
-    }
+    dwarf_read_debug_printf ("re-using symbols");
   else if (dwarf2_read_debug_names (per_objfile))
-    {
-      dwarf_read_debug_printf ("found debug names");
-      objfile->qf.push_front
-	(per_bfd->index_table->make_quick_functions ());
-    }
+    dwarf_read_debug_printf ("found debug names");
   else if (dwarf2_read_gdb_index (per_objfile,
 				  get_gdb_index_contents_from_section<struct dwarf2_per_bfd>,
 				  get_gdb_index_contents_from_section<dwz_file>))
-    {
-      dwarf_read_debug_printf ("found gdb index from file");
-      objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
-    }
+    dwarf_read_debug_printf ("found gdb index from file");
   /* ... otherwise, try to find the index in the index cache.  */
   else if (dwarf2_read_gdb_index (per_objfile,
 			     get_gdb_index_contents_from_cache,
@@ -3260,16 +3249,19 @@ dwarf2_initialize_objfile (struct objfile *objfile,
     {
       dwarf_read_debug_printf ("found gdb index from cache");
       global_index_cache.hit ();
-      objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
     }
   else
     {
       global_index_cache.miss ();
-      objfile->qf.push_front (make_cooked_index_funcs (per_objfile));
+      start_debug_info_reader (per_objfile);
     }
 
-  if (dwarf_synchronous && per_bfd->index_table != nullptr)
-    per_bfd->index_table->wait_completely ();
+  if (per_bfd->index_table != nullptr)
+    {
+      if (dwarf_synchronous)
+	per_bfd->index_table->wait_completely ();
+      objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
+    }
 
   return true;
 }
@@ -16910,10 +16902,10 @@ cooked_index_functions::expand_symtabs_matching
   return true;
 }
 
-/* Return a new cooked_index_functions object.  */
+/* Start reading .debug_info using the indexer.  */
 
-static quick_symbol_functions_up
-make_cooked_index_funcs (dwarf2_per_objfile *per_objfile)
+static void
+start_debug_info_reader (dwarf2_per_objfile *per_objfile)
 {
   /* Set the index table early so that sharing works even while
      scanning; and then start the scanning.  */
@@ -16923,8 +16915,6 @@ make_cooked_index_funcs (dwarf2_per_objfile *per_objfile)
   /* Don't start reading until after 'index_table' is set.  This
      avoids races.  */
   idx->start_reading ();
-
-  return quick_symbol_functions_up (new cooked_index_functions);
 }
 
 quick_symbol_functions_up

-- 
2.43.0


  parent reply	other threads:[~2024-01-17 16:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 16:39 [PATCH v2 00/17] Rewrite .debug_names reader and writer Tom Tromey
2024-01-17 16:39 ` [PATCH v2 01/17] Refactor 'maint set dwarf synchronous' handling Tom Tromey
2024-01-17 16:39 ` Tom Tromey [this message]
2024-01-17 16:39 ` [PATCH v2 03/17] Remove IS_ENUM_CLASS from cooked_index_flag Tom Tromey
2024-01-17 16:39 ` [PATCH v2 04/17] Document GDB extensions to DWARF .debug_names Tom Tromey
2024-01-17 16:39 ` [PATCH v2 05/17] Add language to cooked_index_entry Tom Tromey
2024-01-17 16:39 ` [PATCH v2 06/17] Move cooked_index_functions to cooked-index.h Tom Tromey
2024-01-17 16:39 ` [PATCH v2 07/17] Do not write the index cache from an index Tom Tromey
2024-01-17 16:39 ` [PATCH v2 08/17] Change cooked_index_worker to abstract base class Tom Tromey
2024-01-17 16:39 ` [PATCH v2 09/17] Remove cooked_index_worker::start_reading Tom Tromey
2024-01-17 16:39 ` [PATCH v2 10/17] Empty hash table fix in .debug_names reader Tom Tromey
2024-01-17 16:39 ` [PATCH v2 11/17] Fix dw2-zero-range.exp when an index is in use Tom Tromey
2024-01-17 16:39 ` [PATCH v2 12/17] Explicitly expand CUs in dw2-inline-with-lexical-scope.exp Tom Tromey
2024-01-17 16:39 ` [PATCH v2 13/17] Remove some .debug_names tests Tom Tromey
2024-01-17 16:39 ` [PATCH v2 14/17] Allow other results in DW_TAG_entry_point test Tom Tromey
2024-01-17 16:39 ` [PATCH v2 15/17] Rewrite .debug_names reader Tom Tromey
2024-01-17 16:39 ` [PATCH v2 16/17] Export dwarf5_augmentation Tom Tromey
2024-01-17 16:39 ` [PATCH v2 17/17] Rewrite .debug_names writer Tom Tromey
2024-01-18 10:05 ` [PATCH v2 00/17] Rewrite .debug_names reader and writer Tom de Vries
2024-01-18 15:42   ` Tom Tromey
2024-01-18 20:33     ` 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=20240117-debug-names-fix-v2-2-dbd5971a9c31@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).