]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: add new function quick_symbol_functions::has_unexpanded_symbols
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 15 Apr 2021 10:29:55 +0000 (11:29 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 25 Jun 2021 19:54:28 +0000 (20:54 +0100)
Adds a new function to the quick_symbol_functions API to let us know
if there are any unexpanded symbols.  This functionality is required
by a later commit.  After this commit the functionality is unused, and
untested.

The new function objfile::has_unexpanded_symtabs is added to the
symfile-debug.c file which is a little strange, but this
is (currently) where many of the other objfile::* functions (that call
onto the quick_symbol_functions) are defined, so I'm reluctant to
break this pattern.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* dwarf2/read.c (struct dwarf2_base_index_functions)
<has_unexpanded_symtabs>: Declare.
(dwarf2_base_index_functions::has_unexpanded_symtabs): Define new
function.
* objfiles.h (struct objfile) <has_unexpanded_symtabs>: Declare.
* psympriv.h (struct psymbol_functions) <has_unexpanded_symtabs>:
Declare.
* psymtab.c (psymbol_functions::has_unexpanded_symtabs): Define
new function.
* quick-symbol.h (struct quick_symbol_functions)
<has_unexpanded_symtabs>: Declare.
* symfile-debug.c (objfile::has_unexpanded_symtabs): Define new
function.

gdb/ChangeLog
gdb/dwarf2/read.c
gdb/objfiles.h
gdb/psympriv.h
gdb/psymtab.c
gdb/quick-symbol.h
gdb/symfile-debug.c

index 9613e3e02ca54bf40343d138bee409deecc34ed5..310c506e4e9f1c269bc08e6b3dfafacc96e04eaa 100644 (file)
@@ -1,3 +1,19 @@
+2021-06-25  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * dwarf2/read.c (struct dwarf2_base_index_functions)
+       <has_unexpanded_symtabs>: Declare.
+       (dwarf2_base_index_functions::has_unexpanded_symtabs): Define new
+       function.
+       * objfiles.h (struct objfile) <has_unexpanded_symtabs>: Declare.
+       * psympriv.h (struct psymbol_functions) <has_unexpanded_symtabs>:
+       Declare.
+       * psymtab.c (psymbol_functions::has_unexpanded_symtabs): Define
+       new function.
+       * quick-symbol.h (struct quick_symbol_functions)
+       <has_unexpanded_symtabs>: Declare.
+       * symfile-debug.c (objfile::has_unexpanded_symtabs): Define new
+       function.
+
 2021-06-25  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * infcall.c (call_function_by_hand_dummy): Add missing 'else' when
index 671c607a3b3a871a47cdf9f6fdad1111d5d66457..760d4319c29697d16b7aa4890d7ed43b8cf44ebd 100644 (file)
@@ -2024,6 +2024,8 @@ struct dwarf2_base_index_functions : public quick_symbol_functions
 {
   bool has_symbols (struct objfile *objfile) override;
 
+  bool has_unexpanded_symtabs (struct objfile *objfile) override;
+
   struct symtab *find_last_source_symtab (struct objfile *objfile) override;
 
   void forget_cached_source_info (struct objfile *objfile) override;
@@ -4470,6 +4472,26 @@ dwarf2_base_index_functions::has_symbols (struct objfile *objfile)
   return true;
 }
 
+/* See quick_symbol_functions::has_unexpanded_symtabs in quick-symbol.h.  */
+
+bool
+dwarf2_base_index_functions::has_unexpanded_symtabs (struct objfile *objfile)
+{
+  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+
+  for (const auto &per_cu : per_objfile->per_bfd->all_comp_units)
+    {
+      /* Is this already expanded?  */
+      if (per_objfile->symtab_set_p (per_cu.get ()))
+       continue;
+
+      /* It has not yet been expanded.  */
+      return true;
+    }
+
+  return false;
+}
+
 /* DWARF-5 debug_names reader.  */
 
 /* DWARF-5 augmentation string for GDB's DW_IDX_GNU_* extension.  */
index 5a8a782a64623dd9ecf37e485bd6af255e9bac73..f947d699132c686569d837651939d1b1a67f64d7 100644 (file)
@@ -565,6 +565,12 @@ public:
 
   bool has_partial_symbols ();
 
+  /* Return true if this objfile has any unexpanded symbols.  A return
+     value of false indicates either, that this objfile has all its
+     symbols fully expanded (i.e. fully read in), or that this objfile has
+     no symbols at all (i.e. no debug information).  */
+  bool has_unexpanded_symtabs ();
+
   /* See quick_symbol_functions.  */
   struct symtab *find_last_source_symtab ();
 
index 59dd66f57e5d58dc94f1bd5935a4fd74ac3a15d2..3e51b972413d5337a5616ec3db6f381f0e7e4471 100644 (file)
@@ -503,6 +503,8 @@ struct psymbol_functions : public quick_symbol_functions
 
   bool has_symbols (struct objfile *objfile) override;
 
+  bool has_unexpanded_symtabs (struct objfile *objfile) override;
+
   struct symtab *find_last_source_symtab (struct objfile *objfile) override;
 
   void forget_cached_source_info (struct objfile *objfile) override;
index cbd21b3209fcf164de76a6d2ce5cae175699aaba..069052d712c614c4997caca10c8d6773280835eb 100644 (file)
@@ -1184,6 +1184,24 @@ psymbol_functions::has_symbols (struct objfile *objfile)
   return m_partial_symtabs->psymtabs != NULL;
 }
 
+/* See quick_symbol_functions::has_unexpanded_symtabs in quick-symbol.h.  */
+
+bool
+psymbol_functions::has_unexpanded_symtabs (struct objfile *objfile)
+{
+  for (partial_symtab *psymtab : require_partial_symbols (objfile))
+    {
+      /* Is this already expanded?  */
+      if (psymtab->readin_p (objfile))
+       continue;
+
+      /* It has not yet been expanded.  */
+      return true;
+    }
+
+  return false;
+}
+
 /* Helper function for psym_find_compunit_symtab_by_address that fills
    in m_psymbol_map for a given range of psymbols.  */
 
index f06ceff41c238250dfef373adb11670334c70802..7af0aebb9fe3c84a6a77350324b37b9444851e04 100644 (file)
@@ -86,6 +86,12 @@ struct quick_symbol_functions
      available.  */
   virtual bool has_symbols (struct objfile *objfile) = 0;
 
+  /* Return true if OBJFILE has any unexpanded symtabs.  A return value of
+     false indicates there are no unexpanded symtabs, this might mean that
+     all of the symtabs have been expanded (full debug has been read in),
+     or it might been that OBJFILE has no debug information.  */
+  virtual bool has_unexpanded_symtabs (struct objfile *objfile) = 0;
+
   /* Return the symbol table for the "last" file appearing in
      OBJFILE.  */
   virtual struct symtab *find_last_source_symtab (struct objfile *objfile) = 0;
index b839194e2f74272444a450aacdd7eb22503021c4..a10af68f5b18b9530ff9c8ea24e83c1dbb2cad9c 100644 (file)
@@ -100,6 +100,31 @@ objfile::has_partial_symbols ()
   return retval;
 }
 
+/* See objfiles.h.  */
+bool
+objfile::has_unexpanded_symtabs ()
+{
+  if (debug_symfile)
+    fprintf_filtered (gdb_stdlog, "qf->has_unexpanded_symtabs (%s)\n",
+                     objfile_debug_name (this));
+
+  bool result = false;
+  for (const auto &iter : qf)
+    {
+      if (iter->has_unexpanded_symtabs (this))
+       {
+         result = true;
+         break;
+       }
+    }
+
+  if (debug_symfile)
+    fprintf_filtered (gdb_stdlog, "qf->has_unexpanded_symtabs (%s) = %d\n",
+                     objfile_debug_name (this), (result ? 1 : 0));
+
+  return result;
+}
+
 struct symtab *
 objfile::find_last_source_symtab ()
 {