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 03/26] Change objfile_has_partial_symbols to a method
Date: Sun, 28 Feb 2021 13:37:40 -0700	[thread overview]
Message-ID: <20210228203803.1693413-4-tom@tromey.com> (raw)
In-Reply-To: <20210228203803.1693413-1-tom@tromey.com>

This changes objfile_has_partial_symbols to be a method on objfile.

There are some other functions that could benefit from this sort of
change, but this was the only one that was relevant to this series.

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

	* symfile.c (read_symbols): Update.
	* objfiles.h (struct objfile) <has_partial_symbols>: New method.
	(objfile_has_partial_symbols): Don't declare.
	* objfiles.c (objfile::has_partial_symbols): Rename from
	objfile_has_partial_symbols.
	(objfile_has_symbols, have_partial_symbols): Update.
	* elfread.c (elf_symfile_read): Update.
	* dwarf2/read.c (dwarf2_has_info): Update.
	* coffread.c (coff_symfile_read): Update.
---
 gdb/ChangeLog     | 12 ++++++++++++
 gdb/coffread.c    |  2 +-
 gdb/dwarf2/read.c |  2 +-
 gdb/elfread.c     |  6 +++---
 gdb/objfiles.c    | 16 ++++++++--------
 gdb/objfiles.h    |  5 +++--
 gdb/symfile.c     |  2 +-
 7 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index d15ba6593fc..badcb5a6084 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -708,7 +708,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   dwarf2_build_frame_info (objfile);
 
   /* Try to add separate debug file if no symbols table found.   */
-  if (!objfile_has_partial_symbols (objfile))
+  if (!objfile->has_partial_symbols ())
     {
       std::string debugfile = find_separate_debug_file_by_buildid (objfile);
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3c25f4efba6..02176e8da8f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1953,7 +1953,7 @@ dwarf2_has_info (struct objfile *objfile,
       /* We can share a "dwarf2_per_bfd" with other objfiles if the BFD
 	 doesn't require relocations and if there aren't partial symbols
 	 from some other reader.  */
-      if (!objfile_has_partial_symbols (objfile)
+      if (!objfile->has_partial_symbols ()
 	  && !gdb_bfd_requires_relocations (objfile->obfd))
 	{
 	  /* See if one has been created for this BFD yet.  */
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 8f06c8edc79..439f5cc29a0 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1266,7 +1266,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
       /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF
 	 debug information present in OBJFILE.  If there is such debug
 	 info present never use an index.  */
-      if (!objfile_has_partial_symbols (objfile)
+      if (!objfile->has_partial_symbols ()
 	  && dwarf2_initialize_objfile (objfile, &index_kind))
 	{
 	  switch (index_kind)
@@ -1293,14 +1293,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
      SYMTABS/PSYMTABS.  `.gnu_debuglink' may no longer be present with
      `.note.gnu.build-id'.
 
-     .gnu_debugdata is !objfile_has_partial_symbols because it contains only
+     .gnu_debugdata is !objfile::has_partial_symbols because it contains only
      .symtab, not .debug_* section.  But if we already added .gnu_debugdata as
      an objfile via find_separate_debug_file_in_section there was no separate
      debug info available.  Therefore do not attempt to search for another one,
      objfile->separate_debug_objfile->separate_debug_objfile GDB guarantees to
      be NULL and we would possibly violate it.  */
 
-  else if (!objfile_has_partial_symbols (objfile)
+  else if (!objfile->has_partial_symbols ()
 	   && objfile->separate_debug_objfile == NULL
 	   && objfile->separate_debug_objfile_backlink == NULL)
     {
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 2a513d82f1a..53ca66d17e6 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -810,23 +810,23 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
     breakpoint_re_set ();
 }
 \f
-/* Return non-zero if OBJFILE has partial symbols.  */
+/* See objfiles.h.  */
 
 int
-objfile_has_partial_symbols (struct objfile *objfile)
+objfile::has_partial_symbols ()
 {
-  if (!objfile->sf)
+  if (!sf)
     return 0;
 
   /* If we have not read psymbols, but we have a function capable of reading
      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 ((objfile->flags & OBJF_PSYMTABS_READ) == 0
-      && objfile->sf->sym_read_psymbols != NULL)
+  if ((flags & OBJF_PSYMTABS_READ) == 0
+      && sf->sym_read_psymbols != NULL)
     return 1;
 
-  return objfile->sf->qf->has_symbols (objfile);
+  return sf->qf->has_symbols (this);
 }
 
 /* Return non-zero if OBJFILE has full symbols.  */
@@ -844,7 +844,7 @@ int
 objfile_has_symbols (struct objfile *objfile)
 {
   for (::objfile *o : objfile->separate_debug_objfiles ())
-    if (objfile_has_partial_symbols (o) || objfile_has_full_symbols (o))
+    if (o->has_partial_symbols () || objfile_has_full_symbols (o))
       return 1;
   return 0;
 }
@@ -859,7 +859,7 @@ have_partial_symbols (void)
 {
   for (objfile *ofp : current_program_space->objfiles ())
     {
-      if (objfile_has_partial_symbols (ofp))
+      if (ofp->has_partial_symbols ())
 	return 1;
     }
   return 0;
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 052f109db4d..0568e16ae4c 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -548,6 +548,9 @@ struct objfile
     return per_bfd->gdbarch;
   }
 
+  /* Return true if OBJFILE has partial symbols.  */
+
+  int has_partial_symbols ();
 
   /* The object file's original name as specified by the user,
      made absolute, and tilde-expanded.  However, it is not canonicalized
@@ -738,8 +741,6 @@ extern void free_objfile_separate_debug (struct objfile *);
 extern void objfile_relocate (struct objfile *, const section_offsets &);
 extern void objfile_rebase (struct objfile *, CORE_ADDR);
 
-extern int objfile_has_partial_symbols (struct objfile *objfile);
-
 extern int objfile_has_full_symbols (struct objfile *objfile);
 
 extern int objfile_has_symbols (struct objfile *objfile);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index ec5d34ac783..34d6363a91a 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -775,7 +775,7 @@ read_symbols (struct objfile *objfile, symfile_add_flags add_flags)
 
   /* find_separate_debug_file_in_section should be called only if there is
      single binary with no existing separate debug info file.  */
-  if (!objfile_has_partial_symbols (objfile)
+  if (!objfile->has_partial_symbols ()
       && objfile->separate_debug_objfile == NULL
       && objfile->separate_debug_objfile_backlink == NULL)
     {
-- 
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 ` Tom Tromey [this message]
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 ` [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-4-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).