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 25/26] Switch objfile to hold a list of psymbol readers
Date: Sun, 28 Feb 2021 13:38:02 -0700	[thread overview]
Message-ID: <20210228203803.1693413-26-tom@tromey.com> (raw)
In-Reply-To: <20210228203803.1693413-1-tom@tromey.com>

This changes objfile::qf to be a forward_list, and then updates all
the uses to iterate over the list.  Note that there is still only ever
a single element in the list; this is handled by clearing the list
whenever an object is added.

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

	* dwarf2/read.c (dwarf2_build_psymtabs): Update.
	* 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)
	(objfile::require_partial_symbols): Update.
	* psymtab.c (maintenance_print_psymbols)
	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
	* objfiles.h (struct objfile) <qf>: Now a forward_list.
	* objfiles.c (objfile_relocate1): Update.
	* elfread.c (elf_symfile_read): Update.
---
 gdb/ChangeLog       |  25 +++
 gdb/dwarf2/read.c   |   2 +-
 gdb/elfread.c       |   9 +-
 gdb/objfiles.c      |   4 +-
 gdb/objfiles.h      |   3 +-
 gdb/psymtab.c       | 412 +++++++++++++++++++++++---------------------
 gdb/symfile-debug.c | 137 +++++++++------
 gdb/symfile.c       |   7 +-
 8 files changed, 337 insertions(+), 262 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 183876bb5b7..570df071bf7 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -6361,7 +6361,7 @@ dwarf2_build_psymtabs (struct objfile *objfile)
       /* This is a temporary hack to ensure that the objfile and 'qf'
 	 psymtabs are identical.  */
       psymbol_functions *psf
-	= dynamic_cast<psymbol_functions *> (objfile->qf.get ());
+	= dynamic_cast<psymbol_functions *> (objfile->qf.front ().get ());
       gdb_assert (psf != nullptr);
       psf->set_partial_symtabs (per_bfd->partial_symtabs);
       per_objfile->resize_symtabs ();
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 157a0717828..1cf9b2addc4 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1287,10 +1287,12 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 	  switch (index_kind)
 	    {
 	    case dw_index_kind::GDB_INDEX:
-	      objfile->qf = make_dwarf_gdb_index ();
+	      objfile->qf.clear ();
+	      objfile->qf.push_front (make_dwarf_gdb_index ());
 	      break;
 	    case dw_index_kind::DEBUG_NAMES:
-	      objfile->qf = make_dwarf_debug_names ();
+	      objfile->qf.clear ();
+	      objfile->qf.push_front (make_dwarf_debug_names ());
 	      break;
 	    }
 	}
@@ -1300,7 +1302,8 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 	     partial symbols, because OBJF_PSYMTABS_READ has not been
 	     set, and so our lazy reader function will still be called
 	     when needed.  */
-	  objfile->qf.reset
+	  objfile->qf.clear ();
+	  objfile->qf.emplace_front
 	    (new lazy_dwarf_reader (objfile->partial_symtabs));
 	}
     }
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index ca135dd63c3..ed51c31c8b9 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -703,8 +703,8 @@ objfile_relocate1 (struct objfile *objfile,
   }
 
   /* Notify the quick symbol object.  */
-  if (objfile->qf)
-    objfile->qf->relocated ();
+  for (const auto &iter : objfile->qf)
+    iter->relocated ();
 
   /* Relocate isolated symbols.  */
   {
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index cb441b117df..2f566709eb2 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -38,6 +38,7 @@
 #include "gdbsupport/refcounted-object.h"
 #include "jit.h"
 #include "quick-symbol.h"
+#include <forward_list>
 
 struct htab;
 struct objfile_data;
@@ -668,7 +669,7 @@ struct objfile
 
   /* The "quick" (aka partial) symbol functions for this symbol
      reader.  */
-  quick_symbol_functions_up qf;
+  std::forward_list<quick_symbol_functions_up> qf;
 
   /* Per objfile data-pointers required by other GDB modules.  */
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 3f3b5596864..785eda04c9e 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1810,49 +1810,25 @@ maintenance_print_psymbols (const char *args, int from_tty)
       if (!print_for_objfile)
 	continue;
 
-      psymbol_functions *psf
-	= dynamic_cast<psymbol_functions *> (objfile->qf.get ());
-      if (psf == nullptr)
-	continue;
-
-      psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
-
-      if (address_arg != NULL)
+      for (const auto &iter : objfile->qf)
 	{
-	  struct bound_minimal_symbol msymbol = { NULL, NULL };
+	  psymbol_functions *psf
+	    = dynamic_cast<psymbol_functions *> (iter.get ());
+	  if (psf == nullptr)
+	    continue;
 
-	  /* We don't assume each pc has a unique objfile (this is for
-	     debugging).  */
-	  struct partial_symtab *ps
-	    = psf->find_pc_sect_psymtab (objfile, pc, section, msymbol);
-	  if (ps != NULL)
-	    {
-	      if (!printed_objfile_header)
-		{
-		  outfile->printf ("\nPartial symtabs for objfile %s\n",
-				  objfile_name (objfile));
-		  printed_objfile_header = 1;
-		}
-	      dump_psymtab (objfile, ps, outfile);
-	      dump_psymtab_addrmap (objfile, partial_symtabs, ps, outfile);
-	      found = 1;
-	    }
-	}
-      else
-	{
-	  for (partial_symtab *ps : psf->require_partial_symbols (objfile))
+	  psymtab_storage *partial_symtabs
+	    = psf->get_partial_symtabs ().get ();
+
+	  if (address_arg != NULL)
 	    {
-	      int print_for_source = 0;
+	      struct bound_minimal_symbol msymbol = { NULL, NULL };
 
-	      QUIT;
-	      if (source_arg != NULL)
-		{
-		  print_for_source
-		    = compare_filenames_for_search (ps->filename, source_arg);
-		  found = 1;
-		}
-	      if (source_arg == NULL
-		  || print_for_source)
+	      /* We don't assume each pc has a unique objfile (this is for
+		 debugging).  */
+	      struct partial_symtab *ps
+		= psf->find_pc_sect_psymtab (objfile, pc, section, msymbol);
+	      if (ps != NULL)
 		{
 		  if (!printed_objfile_header)
 		    {
@@ -1861,20 +1837,48 @@ maintenance_print_psymbols (const char *args, int from_tty)
 		      printed_objfile_header = 1;
 		    }
 		  dump_psymtab (objfile, ps, outfile);
-		  dump_psymtab_addrmap (objfile, partial_symtabs, ps,
-					outfile);
+		  dump_psymtab_addrmap (objfile, partial_symtabs, ps, outfile);
+		  found = 1;
+		}
+	    }
+	  else
+	    {
+	      for (partial_symtab *ps : psf->require_partial_symbols (objfile))
+		{
+		  int print_for_source = 0;
+
+		  QUIT;
+		  if (source_arg != NULL)
+		    {
+		      print_for_source
+			= compare_filenames_for_search (ps->filename, source_arg);
+		      found = 1;
+		    }
+		  if (source_arg == NULL
+		      || print_for_source)
+		    {
+		      if (!printed_objfile_header)
+			{
+			  outfile->printf ("\nPartial symtabs for objfile %s\n",
+					   objfile_name (objfile));
+			  printed_objfile_header = 1;
+			}
+		      dump_psymtab (objfile, ps, outfile);
+		      dump_psymtab_addrmap (objfile, partial_symtabs, ps,
+					    outfile);
+		    }
 		}
 	    }
-	}
 
-      /* If we're printing all the objfile's symbols dump the full addrmap.  */
+	  /* If we're printing all the objfile's symbols dump the full addrmap.  */
 
-      if (address_arg == NULL
-	  && source_arg == NULL
-	  && partial_symtabs->psymtabs_addrmap != NULL)
-	{
-	  outfile->puts ("\n");
-	  dump_psymtab_addrmap (objfile, partial_symtabs, NULL, outfile);
+	  if (address_arg == NULL
+	      && source_arg == NULL
+	      && partial_symtabs->psymtabs_addrmap != NULL)
+	    {
+	      outfile->puts ("\n");
+	      dump_psymtab_addrmap (objfile, partial_symtabs, NULL, outfile);
+	    }
 	}
     }
 
@@ -1904,91 +1908,94 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
 	   actually find a symtab whose name matches.  */
 	int printed_objfile_start = 0;
 
-	psymbol_functions *psf
-	  = dynamic_cast<psymbol_functions *> (objfile->qf.get ());
-	if (psf == nullptr)
-	  continue;
-	for (partial_symtab *psymtab : psf->require_partial_symbols (objfile))
+	for (const auto &iter : objfile->qf)
 	  {
-	    QUIT;
-
-	    if (! regexp
-		|| re_exec (psymtab->filename))
+	    psymbol_functions *psf
+	      = dynamic_cast<psymbol_functions *> (iter.get ());
+	    if (psf == nullptr)
+	      continue;
+	    for (partial_symtab *psymtab : psf->require_partial_symbols (objfile))
 	      {
-		if (! printed_objfile_start)
-		  {
-		    printf_filtered ("{ objfile %s ", objfile_name (objfile));
-		    wrap_here ("  ");
-		    printf_filtered ("((struct objfile *) %s)\n",
-				     host_address_to_string (objfile));
-		    printed_objfile_start = 1;
-		  }
+		QUIT;
 
-		printf_filtered ("  { psymtab %s ", psymtab->filename);
-		wrap_here ("    ");
-		printf_filtered ("((struct partial_symtab *) %s)\n",
-				 host_address_to_string (psymtab));
-
-		printf_filtered ("    readin %s\n",
-				 psymtab->readin_p (objfile) ? "yes" : "no");
-		printf_filtered ("    fullname %s\n",
-				 psymtab->fullname
-				 ? psymtab->fullname : "(null)");
-		printf_filtered ("    text addresses ");
-		fputs_filtered (paddress (gdbarch,
-					  psymtab->text_low (objfile)),
-				gdb_stdout);
-		printf_filtered (" -- ");
-		fputs_filtered (paddress (gdbarch,
-					  psymtab->text_high (objfile)),
-				gdb_stdout);
-		printf_filtered ("\n");
-		printf_filtered ("    psymtabs_addrmap_supported %s\n",
-				 (psymtab->psymtabs_addrmap_supported
-				  ? "yes" : "no"));
-		printf_filtered ("    globals ");
-		if (!psymtab->global_psymbols.empty ())
-		  printf_filtered
-		    ("(* (struct partial_symbol **) %s @ %d)\n",
-		     host_address_to_string (psymtab->global_psymbols.data ()),
-		     (int) psymtab->global_psymbols.size ());
-		else
-		  printf_filtered ("(none)\n");
-		printf_filtered ("    statics ");
-		if (!psymtab->static_psymbols.empty ())
-		  printf_filtered
-		    ("(* (struct partial_symbol **) %s @ %d)\n",
-		     host_address_to_string (psymtab->static_psymbols.data ()),
-		     (int) psymtab->static_psymbols.size ());
-		else
-		  printf_filtered ("(none)\n");
-		if (psymtab->user)
-		  printf_filtered ("    user %s "
-				   "((struct partial_symtab *) %s)\n",
-				   psymtab->user->filename,
-				   host_address_to_string (psymtab->user));
-		printf_filtered ("    dependencies ");
-		if (psymtab->number_of_dependencies)
+		if (! regexp
+		    || re_exec (psymtab->filename))
 		  {
-		    int i;
+		    if (! printed_objfile_start)
+		      {
+			printf_filtered ("{ objfile %s ", objfile_name (objfile));
+			wrap_here ("  ");
+			printf_filtered ("((struct objfile *) %s)\n",
+					 host_address_to_string (objfile));
+			printed_objfile_start = 1;
+		      }
 
-		    printf_filtered ("{\n");
-		    for (i = 0; i < psymtab->number_of_dependencies; i++)
+		    printf_filtered ("  { psymtab %s ", psymtab->filename);
+		    wrap_here ("    ");
+		    printf_filtered ("((struct partial_symtab *) %s)\n",
+				     host_address_to_string (psymtab));
+
+		    printf_filtered ("    readin %s\n",
+				     psymtab->readin_p (objfile) ? "yes" : "no");
+		    printf_filtered ("    fullname %s\n",
+				     psymtab->fullname
+				     ? psymtab->fullname : "(null)");
+		    printf_filtered ("    text addresses ");
+		    fputs_filtered (paddress (gdbarch,
+					      psymtab->text_low (objfile)),
+				    gdb_stdout);
+		    printf_filtered (" -- ");
+		    fputs_filtered (paddress (gdbarch,
+					      psymtab->text_high (objfile)),
+				    gdb_stdout);
+		    printf_filtered ("\n");
+		    printf_filtered ("    psymtabs_addrmap_supported %s\n",
+				     (psymtab->psymtabs_addrmap_supported
+				      ? "yes" : "no"));
+		    printf_filtered ("    globals ");
+		    if (!psymtab->global_psymbols.empty ())
+		      printf_filtered
+			("(* (struct partial_symbol **) %s @ %d)\n",
+			 host_address_to_string (psymtab->global_psymbols.data ()),
+			 (int) psymtab->global_psymbols.size ());
+		    else
+		      printf_filtered ("(none)\n");
+		    printf_filtered ("    statics ");
+		    if (!psymtab->static_psymbols.empty ())
+		      printf_filtered
+			("(* (struct partial_symbol **) %s @ %d)\n",
+			 host_address_to_string (psymtab->static_psymbols.data ()),
+			 (int) psymtab->static_psymbols.size ());
+		    else
+		      printf_filtered ("(none)\n");
+		    if (psymtab->user)
+		      printf_filtered ("    user %s "
+				       "((struct partial_symtab *) %s)\n",
+				       psymtab->user->filename,
+				       host_address_to_string (psymtab->user));
+		    printf_filtered ("    dependencies ");
+		    if (psymtab->number_of_dependencies)
 		      {
-			struct partial_symtab *dep = psymtab->dependencies[i];
-
-			/* Note the string concatenation there --- no
-			   comma.  */
-			printf_filtered ("      psymtab %s "
-					 "((struct partial_symtab *) %s)\n",
-					 dep->filename,
-					 host_address_to_string (dep));
+			int i;
+
+			printf_filtered ("{\n");
+			for (i = 0; i < psymtab->number_of_dependencies; i++)
+			  {
+			    struct partial_symtab *dep = psymtab->dependencies[i];
+
+			    /* Note the string concatenation there --- no
+			       comma.  */
+			    printf_filtered ("      psymtab %s "
+					     "((struct partial_symtab *) %s)\n",
+					     dep->filename,
+					     host_address_to_string (dep));
+			  }
+			printf_filtered ("    }\n");
 		      }
-		    printf_filtered ("    }\n");
+		    else
+		      printf_filtered ("(none)\n");
+		    printf_filtered ("  }\n");
 		  }
-		else
-		  printf_filtered ("(none)\n");
-		printf_filtered ("  }\n");
 	      }
 	  }
 
@@ -2009,93 +2016,96 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      psymbol_functions *psf
-	= dynamic_cast<psymbol_functions *> (objfile->qf.get ());
-      if (psf == nullptr)
-	continue;
-
-      for (partial_symtab *ps : psf->require_partial_symbols (objfile))
+      for (const auto &iter : objfile->qf)
 	{
-	  struct gdbarch *gdbarch = objfile->arch ();
-
-	  /* We don't call psymtab_to_symtab here because that may cause symtab
-	     expansion.  When debugging a problem it helps if checkers leave
-	     things unchanged.  */
-	  cust = ps->get_compunit_symtab (objfile);
+	  psymbol_functions *psf
+	    = dynamic_cast<psymbol_functions *> (iter.get ());
+	  if (psf == nullptr)
+	    continue;
 
-	  /* First do some checks that don't require the associated symtab.  */
-	  if (ps->text_high (objfile) < ps->text_low (objfile))
+	  for (partial_symtab *ps : psf->require_partial_symbols (objfile))
 	    {
-	      printf_filtered ("Psymtab ");
-	      puts_filtered (ps->filename);
-	      printf_filtered (" covers bad range ");
-	      fputs_filtered (paddress (gdbarch, ps->text_low (objfile)),
-			      gdb_stdout);
-	      printf_filtered (" - ");
-	      fputs_filtered (paddress (gdbarch, ps->text_high (objfile)),
-			      gdb_stdout);
-	      printf_filtered ("\n");
-	      continue;
-	    }
+	      struct gdbarch *gdbarch = objfile->arch ();
 
-	  /* Now do checks requiring the associated symtab.  */
-	  if (cust == NULL)
-	    continue;
-	  bv = COMPUNIT_BLOCKVECTOR (cust);
-	  b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-	  for (partial_symbol *psym : ps->static_psymbols)
-	    {
-	      /* Skip symbols for inlined functions without address.  These may
-		 or may not have a match in the full symtab.  */
-	      if (psym->aclass == LOC_BLOCK
-		  && psym->ginfo.value.address == 0)
-		continue;
+	      /* We don't call psymtab_to_symtab here because that may cause symtab
+		 expansion.  When debugging a problem it helps if checkers leave
+		 things unchanged.  */
+	      cust = ps->get_compunit_symtab (objfile);
 
-	      sym = block_lookup_symbol (b, psym->ginfo.search_name (),
-					 symbol_name_match_type::SEARCH_NAME,
-					 psym->domain);
-	      if (!sym)
+	      /* First do some checks that don't require the associated symtab.  */
+	      if (ps->text_high (objfile) < ps->text_low (objfile))
 		{
-		  printf_filtered ("Static symbol `");
-		  puts_filtered (psym->ginfo.linkage_name ());
-		  printf_filtered ("' only found in ");
+		  printf_filtered ("Psymtab ");
 		  puts_filtered (ps->filename);
-		  printf_filtered (" psymtab\n");
+		  printf_filtered (" covers bad range ");
+		  fputs_filtered (paddress (gdbarch, ps->text_low (objfile)),
+				  gdb_stdout);
+		  printf_filtered (" - ");
+		  fputs_filtered (paddress (gdbarch, ps->text_high (objfile)),
+				  gdb_stdout);
+		  printf_filtered ("\n");
+		  continue;
 		}
-	    }
-	  b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-	  for (partial_symbol *psym : ps->global_psymbols)
-	    {
-	      sym = block_lookup_symbol (b, psym->ginfo.search_name (),
-					 symbol_name_match_type::SEARCH_NAME,
-					 psym->domain);
-	      if (!sym)
+
+	      /* Now do checks requiring the associated symtab.  */
+	      if (cust == NULL)
+		continue;
+	      bv = COMPUNIT_BLOCKVECTOR (cust);
+	      b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+	      for (partial_symbol *psym : ps->static_psymbols)
+		{
+		  /* Skip symbols for inlined functions without address.  These may
+		     or may not have a match in the full symtab.  */
+		  if (psym->aclass == LOC_BLOCK
+		      && psym->ginfo.value.address == 0)
+		    continue;
+
+		  sym = block_lookup_symbol (b, psym->ginfo.search_name (),
+					     symbol_name_match_type::SEARCH_NAME,
+					     psym->domain);
+		  if (!sym)
+		    {
+		      printf_filtered ("Static symbol `");
+		      puts_filtered (psym->ginfo.linkage_name ());
+		      printf_filtered ("' only found in ");
+		      puts_filtered (ps->filename);
+		      printf_filtered (" psymtab\n");
+		    }
+		}
+	      b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+	      for (partial_symbol *psym : ps->global_psymbols)
+		{
+		  sym = block_lookup_symbol (b, psym->ginfo.search_name (),
+					     symbol_name_match_type::SEARCH_NAME,
+					     psym->domain);
+		  if (!sym)
+		    {
+		      printf_filtered ("Global symbol `");
+		      puts_filtered (psym->ginfo.linkage_name ());
+		      printf_filtered ("' only found in ");
+		      puts_filtered (ps->filename);
+		      printf_filtered (" psymtab\n");
+		    }
+		}
+	      if (ps->raw_text_high () != 0
+		  && (ps->text_low (objfile) < BLOCK_START (b)
+		      || ps->text_high (objfile) > BLOCK_END (b)))
 		{
-		  printf_filtered ("Global symbol `");
-		  puts_filtered (psym->ginfo.linkage_name ());
-		  printf_filtered ("' only found in ");
+		  printf_filtered ("Psymtab ");
 		  puts_filtered (ps->filename);
-		  printf_filtered (" psymtab\n");
+		  printf_filtered (" covers ");
+		  fputs_filtered (paddress (gdbarch, ps->text_low (objfile)),
+				  gdb_stdout);
+		  printf_filtered (" - ");
+		  fputs_filtered (paddress (gdbarch, ps->text_high (objfile)),
+				  gdb_stdout);
+		  printf_filtered (" but symtab covers only ");
+		  fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout);
+		  printf_filtered (" - ");
+		  fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout);
+		  printf_filtered ("\n");
 		}
 	    }
-	  if (ps->raw_text_high () != 0
-	      && (ps->text_low (objfile) < BLOCK_START (b)
-		  || ps->text_high (objfile) > BLOCK_END (b)))
-	    {
-	      printf_filtered ("Psymtab ");
-	      puts_filtered (ps->filename);
-	      printf_filtered (" covers ");
-	      fputs_filtered (paddress (gdbarch, ps->text_low (objfile)),
-			      gdb_stdout);
-	      printf_filtered (" - ");
-	      fputs_filtered (paddress (gdbarch, ps->text_high (objfile)),
-			      gdb_stdout);
-	      printf_filtered (" but symtab covers only ");
-	      fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout);
-	      printf_filtered (" - ");
-	      fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout);
-	      printf_filtered ("\n");
-	    }
 	}
     }
 }
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 99974536bf4..3daede88292 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -80,12 +80,16 @@ objfile::has_partial_symbols ()
      them, then that is an indication that they are in fact available.  Without
      this function the symbols may have been already read in but they also may
      not be present in this objfile.  */
-  if ((flags & OBJF_PSYMTABS_READ) == 0
-      && qf != nullptr
-      && qf->can_lazily_read_symbols ())
-    retval = true;
-  else if (qf != nullptr)
-    retval = qf->has_symbols (this);
+  for (const auto &iter : qf)
+    {
+      if ((flags & OBJF_PSYMTABS_READ) == 0
+	  && iter->can_lazily_read_symbols ())
+	retval = true;
+      else
+	retval = iter->has_symbols (this);
+      if (retval)
+	break;
+    }
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n",
@@ -103,8 +107,12 @@ objfile::find_last_source_symtab ()
     fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
 		      objfile_debug_name (this));
 
-  if (qf != nullptr)
-    retval = qf->find_last_source_symtab (this);
+  for (const auto &iter : qf)
+    {
+      retval = iter->find_last_source_symtab (this);
+      if (retval != nullptr)
+	break;
+    }
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n",
@@ -120,8 +128,8 @@ objfile::forget_cached_source_info ()
     fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
 		      objfile_debug_name (this));
 
-  if (qf != nullptr)
-    qf->forget_cached_source_info (this);
+  for (const auto &iter : qf)
+    iter->forget_cached_source_info (this);
 }
 
 bool
@@ -138,9 +146,13 @@ objfile::map_symtabs_matching_filename
 		      host_address_to_string (&callback));
 
   bool retval = false;
-  if (qf != nullptr)
-    retval = (qf->map_symtabs_matching_filename
-	      (this, name, real_path, callback));
+  for (const auto &iter : qf)
+    {
+      retval = (iter->map_symtabs_matching_filename
+		(this, name, real_path, callback));
+      if (retval)
+	break;
+    }
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog,
@@ -161,8 +173,12 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
 		      objfile_debug_name (this), kind, name,
 		      domain_name (domain));
 
-  if (qf != nullptr)
-    retval = qf->lookup_symbol (this, kind, name, domain);
+  for (const auto &iter : qf)
+    {
+      retval = iter->lookup_symbol (this, kind, name, domain);
+      if (retval != nullptr)
+	break;
+    }
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
@@ -180,8 +196,8 @@ objfile::print_stats (bool print_bcache)
     fprintf_filtered (gdb_stdlog, "qf->print_stats (%s, %d)\n",
 		      objfile_debug_name (this), print_bcache);
 
-  if (qf != nullptr)
-    qf->print_stats (this, print_bcache);
+  for (const auto &iter : qf)
+    iter->print_stats (this, print_bcache);
 }
 
 void
@@ -191,8 +207,8 @@ objfile::dump ()
     fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n",
 		      objfile_debug_name (this));
 
-  if (qf != nullptr)
-    qf->dump (this);
+  for (const auto &iter : qf)
+    iter->dump (this);
 }
 
 void
@@ -203,8 +219,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 (qf != nullptr)
-    qf->expand_symtabs_for_function (this, func_name);
+  for (const auto &iter : qf)
+    iter->expand_symtabs_for_function (this, func_name);
 }
 
 void
@@ -214,8 +230,8 @@ objfile::expand_all_symtabs ()
     fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
 		      objfile_debug_name (this));
 
-  if (qf != nullptr)
-    qf->expand_all_symtabs (this);
+  for (const auto &iter : qf)
+    iter->expand_all_symtabs (this);
 }
 
 void
@@ -226,8 +242,8 @@ objfile::expand_symtabs_with_fullname (const char *fullname)
 		      "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
 		      objfile_debug_name (this), fullname);
 
-  if (qf != nullptr)
-    qf->expand_symtabs_with_fullname (this, fullname);
+  for (const auto &iter : qf)
+    iter->expand_symtabs_with_fullname (this, fullname);
 }
 
 void
@@ -244,9 +260,9 @@ objfile::map_matching_symbols
 		      domain_name (domain), global,
 		      host_address_to_string (ordered_compare));
 
-  if (qf != nullptr)
-    qf->map_matching_symbols (this, name, domain, global,
-			      callback, ordered_compare);
+  for (const auto &iter : qf)
+    iter->map_matching_symbols (this, name, domain, global,
+				callback, ordered_compare);
 }
 
 void
@@ -266,9 +282,9 @@ objfile::expand_symtabs_matching
 		      host_address_to_string (&expansion_notify),
 		      search_domain_name (kind));
 
-  if (qf != nullptr)
-    qf->expand_symtabs_matching (this, file_matcher, lookup_name,
-				 symbol_matcher, expansion_notify, kind);
+  for (const auto &iter : qf)
+    iter->expand_symtabs_matching (this, file_matcher, lookup_name,
+				   symbol_matcher, expansion_notify, kind);
 }
 
 struct compunit_symtab *
@@ -288,9 +304,13 @@ objfile::find_pc_sect_compunit_symtab (struct bound_minimal_symbol msymbol,
 		      host_address_to_string (section),
 		      warn_if_readin);
 
-  if (qf != nullptr)
-    retval = qf->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
-					       warn_if_readin);
+  for (const auto &iter : qf)
+    {
+      retval = iter->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
+						   warn_if_readin);
+      if (retval != nullptr)
+	break;
+    }
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog,
@@ -314,8 +334,8 @@ objfile::map_symbol_filenames (symbol_filename_ftype *fun, void *data,
 		      host_address_to_string (data),
 		      need_fullname);
 
-  if (qf != nullptr)
-    qf->map_symbol_filenames (this, fun, data, need_fullname);
+  for (const auto &iter : qf)
+    iter->map_symbol_filenames (this, fun, data, need_fullname);
 }
 
 struct compunit_symtab *
@@ -328,8 +348,12 @@ objfile::find_compunit_symtab_by_address (CORE_ADDR address)
 		      hex_string (address));
 
   struct compunit_symtab *result = NULL;
-  if (qf != nullptr)
-    result = qf->find_compunit_symtab_by_address (this, address);
+  for (const auto &iter : qf)
+    {
+      result = iter->find_compunit_symtab_by_address (this, address);
+      if (result != nullptr)
+	break;
+    }
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog,
@@ -347,12 +371,15 @@ objfile::lookup_global_symbol_language (const char *name,
 					bool *symbol_found_p)
 {
   enum language result = language_unknown;
+  *symbol_found_p = false;
 
-  if (qf != nullptr)
-    result = qf->lookup_global_symbol_language (this, name, domain,
-						symbol_found_p);
-  else
-    *symbol_found_p = false;
+  for (const auto &iter : qf)
+    {
+      result = iter->lookup_global_symbol_language (this, name, domain,
+						    symbol_found_p);
+      if (*symbol_found_p)
+	break;
+    }
 
   return result;
 }
@@ -364,17 +391,23 @@ objfile::require_partial_symbols (bool verbose)
     {
       flags |= OBJF_PSYMTABS_READ;
 
-      if (qf->can_lazily_read_symbols ())
+      bool printed = false;
+      for (const auto &iter : qf)
 	{
-	  if (verbose)
-	    printf_filtered (_("Reading symbols from %s...\n"),
-			     objfile_name (this));
-	  qf->read_partial_symbols (this);
-
-	  if (verbose && !objfile_has_symbols (this))
-	    printf_filtered (_("(No debugging symbols found in %s)\n"),
-			     objfile_name (this));
+	  if (iter->can_lazily_read_symbols ())
+	    {
+	      if (verbose && !printed)
+		{
+		  printf_filtered (_("Reading symbols from %s...\n"),
+				   objfile_name (this));
+		  printed = true;
+		}
+	      iter->read_partial_symbols (this);
+	    }
 	}
+      if (printed && !objfile_has_symbols (this))
+	printf_filtered (_("(No debugging symbols found in %s)\n"),
+			 objfile_name (this));
     }
 }
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d2ea04ed149..244565f8f47 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -903,7 +903,8 @@ syms_from_objfile_1 (struct objfile *objfile,
 
   objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
   objfile->reset_psymtabs ();
-  objfile->qf = make_psymbol_functions (objfile->partial_symtabs);
+  objfile->qf.clear ();
+  objfile->qf.push_front (make_psymbol_functions (objfile->partial_symtabs));
 
   if (objfile->sf == NULL)
     {
@@ -2553,7 +2554,9 @@ reread_symbols (void)
 	     start over.  PR symtab/15885  */
 	  objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
 	  objfile->reset_psymtabs ();
-	  objfile->qf = make_psymbol_functions (objfile->partial_symtabs);
+	  objfile->qf.clear ();
+	  objfile->qf.push_front
+	    (make_psymbol_functions (objfile->partial_symtabs));
 
 	  build_objfile_section_table (objfile);
 
-- 
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 ` [PATCH 07/26] Move sym_fns::qf to objfile Tom Tromey
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 ` Tom Tromey [this message]
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-26-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).