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 07/26] Move sym_fns::qf to objfile
Date: Sun, 28 Feb 2021 13:37:44 -0700	[thread overview]
Message-ID: <20210228203803.1693413-8-tom@tromey.com> (raw)
In-Reply-To: <20210228203803.1693413-1-tom@tromey.com>

Currently the "partial" symbol reader is attached to the objfile's
symbol functions.  However, in order to allow multiple separate
partial symbol readers, this association must be changed.  This patch
moves the "qf" member out of sym_fns as a step toward that goal.

gdb/ChangeLog
2021-02-28  Tom Tromey  <tom@tromey.com>

	* psymtab.c (require_partial_symbols): Check that 'sf' is not
	null.
	* xcoffread.c (xcoff_sym_fns): Update.
	* symfile.h (struct sym_fns) <qf>: Remove.
	* symfile.c (syms_from_objfile_1, reread_symbols): Update.
	* symfile-debug.c (objfile::has_partial_symbols)
	(objfile::find_last_source_symtab)
	(objfile::forget_cached_source_info)
	(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
	(objfile::print_stats, objfile::dump)
	(objfile::expand_symtabs_for_function)
	(objfile::expand_all_symtabs)
	(objfile::expand_symtabs_with_fullname)
	(objfile::map_matching_symbols)
	(objfile::expand_symtabs_matching)
	(objfile::find_pc_sect_compunit_symtab)
	(objfile::map_symbol_filenames)
	(objfile::find_compunit_symtab_by_address)
	(objfile::lookup_global_symbol_language, debug_sym_fns)
	(install_symfile_debug_logging): Update.
	* objfiles.h (struct objfile) <qf>: New member.
	* mipsread.c (ecoff_sym_fns): Update.
	* machoread.c (macho_sym_fns): Update.
	* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_debug_names):
	Don't declare.
	(elf_symfile_read, elf_sym_fns, elf_sym_fns_lazy_psyms): Update.
	* dbxread.c (aout_sym_fns): Update.
	* coffread.c (coff_sym_fns): Update.
---
 gdb/ChangeLog       | 31 +++++++++++++++++++
 gdb/coffread.c      |  1 -
 gdb/dbxread.c       |  1 -
 gdb/elfread.c       | 42 ++-----------------------
 gdb/machoread.c     |  1 -
 gdb/mipsread.c      |  1 -
 gdb/objfiles.h      |  4 +++
 gdb/psymtab.c       |  3 +-
 gdb/symfile-debug.c | 75 ++++++++++++++++++++++-----------------------
 gdb/symfile.c       |  2 ++
 gdb/symfile.h       |  4 ---
 gdb/xcoffread.c     |  1 -
 12 files changed, 77 insertions(+), 89 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index badcb5a6084..676deec8cbe 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -2180,7 +2180,6 @@ static const struct sym_fns coff_sym_fns =
   default_symfile_relocate,	/* sym_relocate: Relocate a debug
 				   section.  */
   NULL,				/* sym_probe_fns */
-  &psym_functions
 };
 
 void _initialize_coffread ();
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 6450cd32cb0..9003822a0f1 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -3130,7 +3130,6 @@ static const struct sym_fns aout_sym_fns =
   NULL,
   default_symfile_relocate,	/* Relocate a debug section.  */
   NULL,				/* sym_probe_fns */
-  &psym_functions
 };
 
 void _initialize_dbxread ();
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 439f5cc29a0..3ba7221bfc9 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -54,8 +54,6 @@
 #include "dwarf2/public.h"
 
 /* Forward declarations.  */
-extern const struct sym_fns elf_sym_fns_gdb_index;
-extern const struct sym_fns elf_sym_fns_debug_names;
 extern const struct sym_fns elf_sym_fns_lazy_psyms;
 
 /* The struct elfinfo is available only during ELF symbol table and
@@ -1272,10 +1270,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 	  switch (index_kind)
 	    {
 	    case dw_index_kind::GDB_INDEX:
-	      objfile_set_sym_fns (objfile, &elf_sym_fns_gdb_index);
+	      objfile->qf = &dwarf2_gdb_index_functions;
 	      break;
 	    case dw_index_kind::DEBUG_NAMES:
-	      objfile_set_sym_fns (objfile, &elf_sym_fns_debug_names);
+	      objfile->qf = &dwarf2_debug_names_functions;
 	      break;
 	    }
 	}
@@ -1437,7 +1435,6 @@ static const struct sym_fns elf_sym_fns =
   NULL,
   default_symfile_relocate,	/* Relocate a debug section.  */
   &elf_probe_fns,		/* sym_probe_fns */
-  &psym_functions
 };
 
 /* The same as elf_sym_fns, but not registered and lazily reads
@@ -1455,41 +1452,6 @@ const struct sym_fns elf_sym_fns_lazy_psyms =
   NULL,
   default_symfile_relocate,	/* Relocate a debug section.  */
   &elf_probe_fns,		/* sym_probe_fns */
-  &psym_functions
-};
-
-/* The same as elf_sym_fns, but not registered and uses the
-   DWARF-specific GNU index rather than psymtab.  */
-const struct sym_fns elf_sym_fns_gdb_index =
-{
-  elf_new_init,			/* init anything gbl to entire symab */
-  elf_symfile_init,		/* read initial info, setup for sym_red() */
-  elf_symfile_read,		/* read a symbol file into symtab */
-  NULL,				/* sym_read_psymbols */
-  elf_symfile_finish,		/* finished with file, cleanup */
-  default_symfile_offsets,	/* Translate ext. to int. relocation */
-  elf_symfile_segments,		/* Get segment information from a file.  */
-  NULL,
-  default_symfile_relocate,	/* Relocate a debug section.  */
-  &elf_probe_fns,		/* sym_probe_fns */
-  &dwarf2_gdb_index_functions
-};
-
-/* The same as elf_sym_fns, but not registered and uses the
-   DWARF-specific .debug_names index rather than psymtab.  */
-const struct sym_fns elf_sym_fns_debug_names =
-{
-  elf_new_init,			/* init anything gbl to entire symab */
-  elf_symfile_init,		/* read initial info, setup for sym_red() */
-  elf_symfile_read,		/* read a symbol file into symtab */
-  NULL,				/* sym_read_psymbols */
-  elf_symfile_finish,		/* finished with file, cleanup */
-  default_symfile_offsets,	/* Translate ext. to int. relocation */
-  elf_symfile_segments,		/* Get segment information from a file.  */
-  NULL,
-  default_symfile_relocate,	/* Relocate a debug section.  */
-  &elf_probe_fns,		/* sym_probe_fns */
-  &dwarf2_debug_names_functions
 };
 
 /* STT_GNU_IFUNC resolver vector to be installed to gnu_ifunc_fns_p.  */
diff --git a/gdb/machoread.c b/gdb/machoread.c
index ff50ae54f2a..44baaa26f65 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -958,7 +958,6 @@ static const struct sym_fns macho_sym_fns = {
   NULL,
   macho_symfile_relocate,	/* Relocate a debug section.  */
   NULL,				/* sym_get_probes */
-  &psym_functions
 };
 
 void _initialize_machoread ();
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 052b31c70db..3f0697b9150 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -376,7 +376,6 @@ static const struct sym_fns ecoff_sym_fns =
   NULL,
   default_symfile_relocate,	/* Relocate a debug section.  */
   NULL,				/* sym_probe_fns */
-  &psym_functions
 };
 
 void _initialize_mipsread ();
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index c55f0f174fc..8d4a23ae044 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -677,6 +677,10 @@ struct objfile
 
   const struct sym_fns *sf = nullptr;
 
+  /* The "quick" (aka partial) symbol functions for this symbol
+     reader.  */
+  const struct quick_symbol_functions *qf = nullptr;
+
   /* Per objfile data-pointers required by other GDB modules.  */
 
   REGISTRY_FIELDS {};
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 94b5acdea54..8c02fa253dc 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -84,7 +84,8 @@ require_partial_symbols (struct objfile *objfile, bool verbose)
     {
       objfile->flags |= OBJF_PSYMTABS_READ;
 
-      if (objfile->sf->sym_read_psymbols)
+      if (objfile->sf != nullptr
+	  && objfile->sf->sym_read_psymbols)
 	{
 	  if (verbose)
 	    printf_filtered (_("Reading symbols from %s...\n"),
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 419f24d2240..da3439d7928 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -84,8 +84,8 @@ objfile::has_partial_symbols ()
       && sf != nullptr
       && sf->sym_read_psymbols != NULL)
     retval = true;
-  else if (sf != nullptr)
-    retval = sf->qf->has_symbols (this);
+  else if (qf != nullptr)
+    retval = qf->has_symbols (this);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n",
@@ -103,8 +103,8 @@ objfile::find_last_source_symtab ()
     fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
 		      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    retval = sf->qf->find_last_source_symtab (this);
+  if (qf != nullptr)
+    retval = qf->find_last_source_symtab (this);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n",
@@ -120,8 +120,8 @@ objfile::forget_cached_source_info ()
     fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
 		      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->forget_cached_source_info (this);
+  if (qf != nullptr)
+    qf->forget_cached_source_info (this);
 }
 
 bool
@@ -138,8 +138,8 @@ objfile::map_symtabs_matching_filename
 		      host_address_to_string (&callback));
 
   bool retval = false;
-  if (sf != nullptr)
-    retval = (sf->qf->map_symtabs_matching_filename
+  if (qf != nullptr)
+    retval = (qf->map_symtabs_matching_filename
 	      (this, name, real_path, callback));
 
   if (debug_symfile)
@@ -161,8 +161,8 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
 		      objfile_debug_name (this), kind, name,
 		      domain_name (domain));
 
-  if (sf != nullptr)
-    retval = sf->qf->lookup_symbol (this, kind, name, domain);
+  if (qf != nullptr)
+    retval = qf->lookup_symbol (this, kind, name, domain);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
@@ -180,8 +180,8 @@ objfile::print_stats ()
     fprintf_filtered (gdb_stdlog, "qf->print_stats (%s)\n",
 		      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->print_stats (this);
+  if (qf != nullptr)
+    qf->print_stats (this);
 }
 
 void
@@ -191,8 +191,8 @@ objfile::dump ()
     fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n",
 		      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->dump (this);
+  if (qf != nullptr)
+    qf->dump (this);
 }
 
 void
@@ -203,8 +203,8 @@ objfile::expand_symtabs_for_function (const char *func_name)
 		      "qf->expand_symtabs_for_function (%s, \"%s\")\n",
 		      objfile_debug_name (this), func_name);
 
-  if (sf != nullptr)
-    sf->qf->expand_symtabs_for_function (this, func_name);
+  if (qf != nullptr)
+    qf->expand_symtabs_for_function (this, func_name);
 }
 
 void
@@ -214,8 +214,8 @@ objfile::expand_all_symtabs ()
     fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
 		      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->expand_all_symtabs (this);
+  if (qf != nullptr)
+    qf->expand_all_symtabs (this);
 }
 
 void
@@ -226,8 +226,8 @@ objfile::expand_symtabs_with_fullname (const char *fullname)
 		      "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
 		      objfile_debug_name (this), fullname);
 
-  if (sf != nullptr)
-    sf->qf->expand_symtabs_with_fullname (this, fullname);
+  if (qf != nullptr)
+    qf->expand_symtabs_with_fullname (this, fullname);
 }
 
 void
@@ -244,9 +244,9 @@ objfile::map_matching_symbols
 		      domain_name (domain), global,
 		      host_address_to_string (ordered_compare));
 
-  if (sf != nullptr)
-    sf->qf->map_matching_symbols (this, name, domain, global,
-				  callback, ordered_compare);
+  if (qf != nullptr)
+    qf->map_matching_symbols (this, name, domain, global,
+			      callback, ordered_compare);
 }
 
 void
@@ -266,9 +266,9 @@ objfile::expand_symtabs_matching
 		      host_address_to_string (&expansion_notify),
 		      search_domain_name (kind));
 
-  if (sf != nullptr)
-    sf->qf->expand_symtabs_matching (this, file_matcher, lookup_name,
-				     symbol_matcher, expansion_notify, kind);
+  if (qf != nullptr)
+    qf->expand_symtabs_matching (this, file_matcher, lookup_name,
+				 symbol_matcher, expansion_notify, kind);
 }
 
 struct compunit_symtab *
@@ -288,10 +288,9 @@ objfile::find_pc_sect_compunit_symtab (struct bound_minimal_symbol msymbol,
 		      host_address_to_string (section),
 		      warn_if_readin);
 
-  if (sf != nullptr)
-    retval
-      = sf->qf->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
-					      warn_if_readin);
+  if (qf != nullptr)
+    retval = qf->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
+					       warn_if_readin);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog,
@@ -315,8 +314,8 @@ objfile::map_symbol_filenames (symbol_filename_ftype *fun, void *data,
 		      host_address_to_string (data),
 		      need_fullname);
 
-  if (sf != nullptr)
-    sf->qf->map_symbol_filenames (this, fun, data, need_fullname);
+  if (qf != nullptr)
+    qf->map_symbol_filenames (this, fun, data, need_fullname);
 }
 
 struct compunit_symtab *
@@ -329,8 +328,8 @@ objfile::find_compunit_symtab_by_address (CORE_ADDR address)
 		      hex_string (address));
 
   struct compunit_symtab *result = NULL;
-  if (sf != nullptr && sf->qf->find_compunit_symtab_by_address != NULL)
-    result = sf->qf->find_compunit_symtab_by_address (this, address);
+  if (qf != nullptr && qf->find_compunit_symtab_by_address != NULL)
+    result = qf->find_compunit_symtab_by_address (this, address);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog,
@@ -349,9 +348,9 @@ objfile::lookup_global_symbol_language (const char *name,
 {
   enum language result = language_unknown;
 
-  if (sf != nullptr && sf->qf->lookup_global_symbol_language != nullptr)
-    result = sf->qf->lookup_global_symbol_language (this, name, domain,
-						    symbol_found_p);
+  if (qf != nullptr && qf->lookup_global_symbol_language != nullptr)
+    result = qf->lookup_global_symbol_language (this, name, domain,
+						symbol_found_p);
   else
     *symbol_found_p = false;
 
@@ -516,7 +515,6 @@ static const struct sym_fns debug_sym_fns =
   debug_sym_read_linetable,
   debug_sym_relocate,
   &debug_sym_probe_fns,
-  nullptr
 };
 \f
 /* Install the debugging versions of the symfile functions for OBJFILE.
@@ -555,7 +553,6 @@ install_symfile_debug_logging (struct objfile *objfile)
   COPY_SF_PTR (real_sf, debug_data, sym_relocate, debug_sym_relocate);
   if (real_sf->sym_probe_fns)
     debug_data->debug_sf.sym_probe_fns = &debug_sym_probe_fns;
-  debug_data->debug_sf.qf = real_sf->qf;
 
 #undef COPY_SF_PTR
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index ac9adc816a4..d56d623c588 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -904,6 +904,7 @@ syms_from_objfile_1 (struct objfile *objfile,
   const int mainline = add_flags & SYMFILE_MAINLINE;
 
   objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
+  objfile->qf = &psym_functions;
 
   if (objfile->sf == NULL)
     {
@@ -2554,6 +2555,7 @@ reread_symbols (void)
 	     based on whether .gdb_index is present, and we need it to
 	     start over.  PR symtab/15885  */
 	  objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
+	  objfile->qf = &psym_functions;
 
 	  build_objfile_section_table (objfile);
 
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 7e64db74b8d..0bd50899679 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -180,10 +180,6 @@ struct sym_fns
   /* If non-NULL, this objfile has probe support, and all the probe
      functions referred to here will be non-NULL.  */
   const struct sym_probe_fns *sym_probe_fns;
-
-  /* The "quick" (aka partial) symbol functions for this symbol
-     reader.  */
-  const struct quick_symbol_functions *qf;
 };
 
 extern section_addr_info
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 6dab4e59234..207152ece4b 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -3005,7 +3005,6 @@ static const struct sym_fns xcoff_sym_fns =
   aix_process_linenos,
   default_symfile_relocate,	/* Relocate a debug section.  */
   NULL,				/* sym_probe_fns */
-  &psym_functions
 };
 
 /* Same as xcoff_get_n_import_files, but for core files.  */
-- 
2.26.2


  parent reply	other threads:[~2021-02-28 20:38 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-28 20:37 [PATCH 00/26] Allow multiple "partial" symtab readers per objfile Tom Tromey
2021-02-28 20:37 ` [PATCH 01/26] Move some DWARF code out of symfile.h Tom Tromey
2021-02-28 20:37 ` [PATCH 02/26] Introduce dwarf2/public.h Tom Tromey
2021-02-28 20:37 ` [PATCH 03/26] Change objfile_has_partial_symbols to a method Tom Tromey
2021-02-28 20:37 ` [PATCH 04/26] Change objfile::has_partial_symbols to return bool Tom Tromey
2021-02-28 20:37 ` [PATCH 05/26] Introduce method wrappers for quick_symbol_functions Tom Tromey
2021-03-22 13:52   ` Simon Marchi
2021-02-28 20:37 ` [PATCH 06/26] Move quick_symbol_functions to a new header Tom Tromey
2021-02-28 20:37 ` Tom Tromey [this message]
2021-02-28 20:37 ` [PATCH 08/26] Convert quick_symbol_functions to use methods Tom Tromey
2021-02-28 20:37 ` [PATCH 09/26] Move psymbol_map out of objfile Tom Tromey
2021-02-28 20:37 ` [PATCH 10/26] Change how some psymbol readers access the psymtab storage Tom Tromey
2021-02-28 20:37 ` [PATCH 11/26] Do not pass objfile to psymtab_discarder Tom Tromey
2021-02-28 20:37 ` [PATCH 12/26] Set per_bfd->partial_symtabs earlier Tom Tromey
2021-02-28 20:37 ` [PATCH 13/26] Change how DWARF indices use addrmap Tom Tromey
2021-02-28 20:37 ` [PATCH 14/26] Move psymtab statistics printing to psymtab.c Tom Tromey
2021-02-28 20:37 ` [PATCH 15/26] Change how DWARF index writer finds address map Tom Tromey
2021-02-28 20:37 ` [PATCH 16/26] Reference psymtabs via per_bfd in DWARF reader Tom Tromey
2021-02-28 20:37 ` [PATCH 17/26] Attach partial symtab storage to psymbol_functions Tom Tromey
2021-02-28 20:37 ` [PATCH 18/26] Rearrange psymtab_storage construction Tom Tromey
2021-02-28 20:37 ` [PATCH 19/26] Remove sym_fns::sym_read_psymbols Tom Tromey
2021-02-28 20:37 ` [PATCH 20/26] Introduce objfile::require_partial_symbols Tom Tromey
2021-02-28 20:37 ` [PATCH 21/26] Add partial_symtabs parameter to psymtab construction functions Tom Tromey
2021-02-28 20:37 ` [PATCH 22/26] Remove last objfile partial_symtab references from psymtab.c Tom Tromey
2021-02-28 20:38 ` [PATCH 23/26] Change count_psyms to be a method on psymbol_functions Tom Tromey
2021-02-28 20:38 ` [PATCH 24/26] Remove objfile::psymtabs Tom Tromey
2021-02-28 20:38 ` [PATCH 25/26] Switch objfile to hold a list of psymbol readers Tom Tromey
2021-02-28 20:38 ` [PATCH 26/26] Allow multiple partial symbol readers per objfile Tom Tromey
2021-03-20 23:33 ` [PATCH 00/26] Allow multiple "partial" symtab " Tom Tromey
2021-03-22 14:13   ` Simon Marchi

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=20210228203803.1693413-8-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).