From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 19/26] Remove sym_fns::sym_read_psymbols
Date: Sun, 28 Feb 2021 13:37:56 -0700 [thread overview]
Message-ID: <20210228203803.1693413-20-tom@tromey.com> (raw)
In-Reply-To: <20210228203803.1693413-1-tom@tromey.com>
Partial symbols are read via the sym_fns::sym_read_psymbols function
pointer. In order to separate the partial symbols from the objfile,
this must instead be done via a virtual method on
quick_symbol_functions. This patch implements this change.
gdb/ChangeLog
2021-02-28 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_sym_fns): Update.
* symfile.h (struct sym_fns) <sym_read_psymbols>: Remove.
* symfile-debug.c (objfile::has_partial_symbols): Use
can_lazily_read_symbols.
(debug_sym_read_psymbols): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* quick-symbol.h (struct quick_symbol_functions)
<can_lazily_read_symbols, read_partial_symbols>: New methods.
* psymtab.c (require_partial_symbols): Use new 'qf' methods.
* mipsread.c (ecoff_sym_fns): Update.
* machoread.c (macho_sym_fns): Update.
* elfread.c (struct lazy_dwarf_reader): New.
(elf_symfile_read): Update.
(read_psyms): Now a method of lazy_dwarf_reader.
(elf_sym_fns): Update.
(elf_sym_fns_lazy_psyms): Remove.
* dbxread.c (aout_sym_fns): Update.
* coffread.c (coff_sym_fns): Update.
---
gdb/ChangeLog | 21 +++++++++++++++++++
gdb/coffread.c | 1 -
gdb/dbxread.c | 1 -
gdb/elfread.c | 49 ++++++++++++++++++---------------------------
gdb/machoread.c | 1 -
gdb/mipsread.c | 1 -
gdb/psymtab.c | 5 ++---
gdb/quick-symbol.h | 14 +++++++++++++
gdb/symfile-debug.c | 19 ++----------------
gdb/symfile.h | 7 -------
gdb/xcoffread.c | 1 -
11 files changed, 59 insertions(+), 61 deletions(-)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 676deec8cbe..b527f934c95 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -2168,7 +2168,6 @@ static const struct sym_fns coff_sym_fns =
for sym_read() */
coff_symfile_read, /* sym_read: read a symbol file into
symtab */
- NULL, /* sym_read_psymbols */
coff_symfile_finish, /* sym_finish: finished with file,
cleanup */
default_symfile_offsets, /* sym_offsets: xlate external to
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 9a470bf8177..e0cc2597f73 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -3131,7 +3131,6 @@ static const struct sym_fns aout_sym_fns =
dbx_new_init, /* init anything gbl to entire symtab */
dbx_symfile_init, /* read initial info, setup for sym_read() */
dbx_symfile_read, /* read a symbol file into symtab */
- NULL, /* sym_read_psymbols */
dbx_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* parse user's offsets to internal form */
default_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 4ca1f4d5284..157a0717828 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -53,7 +53,24 @@
#include "debuginfod-support.h"
#include "dwarf2/public.h"
-/* Forward declarations. */
+/* A subclass of psymbol_functions that arranges to read the DWARF
+ partial symbols when needed. */
+struct lazy_dwarf_reader : public psymbol_functions
+{
+ using psymbol_functions::psymbol_functions;
+
+ bool can_lazily_read_symbols () override
+ {
+ return true;
+ }
+
+ void read_partial_symbols (struct objfile *objfile) override
+ {
+ if (dwarf2_has_info (objfile, nullptr))
+ dwarf2_build_psymtabs (objfile);
+ }
+};
+
extern const struct sym_fns elf_sym_fns_lazy_psyms;
/* The struct elfinfo is available only during ELF symbol table and
@@ -1283,7 +1300,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_set_sym_fns (objfile, &elf_sym_fns_lazy_psyms);
+ objfile->qf.reset
+ (new lazy_dwarf_reader (objfile->partial_symtabs));
}
}
/* If the file has its own symbol tables it has no separate debug
@@ -1353,15 +1371,6 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
}
}
-/* Callback to lazily read psymtabs. */
-
-static void
-read_psyms (struct objfile *objfile)
-{
- if (dwarf2_has_info (objfile, NULL))
- dwarf2_build_psymtabs (objfile);
-}
-
/* Initialize anything that needs initializing when a completely new symbol
file is specified (not just adding some symbols from another file, e.g. a
shared library). */
@@ -1428,24 +1437,6 @@ static const struct sym_fns elf_sym_fns =
elf_new_init, /* init anything gbl to entire symtab */
elf_symfile_init, /* read initial info, setup for sym_read() */
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 */
-};
-
-/* The same as elf_sym_fns, but not registered and lazily reads
- psymbols. */
-
-const struct sym_fns elf_sym_fns_lazy_psyms =
-{
- elf_new_init, /* init anything gbl to entire symtab */
- elf_symfile_init, /* read initial info, setup for sym_read() */
- elf_symfile_read, /* read a symbol file into symtab */
- read_psyms, /* 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. */
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 44baaa26f65..17aa9ceee01 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -951,7 +951,6 @@ static const struct sym_fns macho_sym_fns = {
macho_new_init, /* init anything gbl to entire symtab */
macho_symfile_init, /* read initial info, setup for sym_read() */
macho_symfile_read, /* read a symbol file into symtab */
- NULL, /* sym_read_psymbols */
macho_symfile_finish, /* finished with file, cleanup */
macho_symfile_offsets, /* xlate external to internal form */
default_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 3f0697b9150..b51af3eeaa6 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -369,7 +369,6 @@ static const struct sym_fns ecoff_sym_fns =
mipscoff_new_init, /* init anything gbl to entire symtab */
mipscoff_symfile_init, /* read initial info, setup for sym_read() */
mipscoff_symfile_read, /* read a symbol file into symtab */
- NULL, /* sym_read_psymbols */
mipscoff_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* dummy FIXME til implem sym reloc */
default_symfile_segments, /* Get segment information from a file. */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 1549ead04d0..b5ddef90878 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -84,13 +84,12 @@ require_partial_symbols (struct objfile *objfile, bool verbose)
{
objfile->flags |= OBJF_PSYMTABS_READ;
- if (objfile->sf != nullptr
- && objfile->sf->sym_read_psymbols)
+ if (objfile->qf->can_lazily_read_symbols ())
{
if (verbose)
printf_filtered (_("Reading symbols from %s...\n"),
objfile_name (objfile));
- (*objfile->sf->sym_read_psymbols) (objfile);
+ objfile->qf->read_partial_symbols (objfile);
if (verbose && !objfile_has_symbols (objfile))
printf_filtered (_("(No debugging symbols found in %s)\n"),
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index 315a97a49e0..dd2b896fd5f 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -237,6 +237,20 @@ struct quick_symbol_functions
{
/* Do nothing. */
}
+
+ /* Return true if this class can lazily read the symbols. This may
+ only return true if there are in fact symbols to be read, because
+ this is used in the implementation of 'has_partial_symbols'. */
+ virtual bool can_lazily_read_symbols ()
+ {
+ return false;
+ }
+
+ /* Read the partial symbols for OBJFILE. This will only ever be
+ called if can_lazily_read_symbols returns true. */
+ virtual void read_partial_symbols (struct objfile *objfile)
+ {
+ }
};
typedef std::unique_ptr<quick_symbol_functions> quick_symbol_functions_up;
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 406eac0b7d3..94559c7370c 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -81,8 +81,8 @@ objfile::has_partial_symbols ()
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
- && sf != nullptr
- && sf->sym_read_psymbols != NULL)
+ && qf != nullptr
+ && qf->can_lazily_read_symbols ())
retval = true;
else if (qf != nullptr)
retval = qf->has_symbols (this);
@@ -420,18 +420,6 @@ debug_sym_read (struct objfile *objfile, symfile_add_flags symfile_flags)
debug_data->real_sf->sym_read (objfile, symfile_flags);
}
-static void
-debug_sym_read_psymbols (struct objfile *objfile)
-{
- const struct debug_sym_fns_data *debug_data
- = symfile_debug_objfile_data_key.get (objfile);
-
- fprintf_filtered (gdb_stdlog, "sf->sym_read_psymbols (%s)\n",
- objfile_debug_name (objfile));
-
- debug_data->real_sf->sym_read_psymbols (objfile);
-}
-
static void
debug_sym_finish (struct objfile *objfile)
{
@@ -508,7 +496,6 @@ static const struct sym_fns debug_sym_fns =
debug_sym_new_init,
debug_sym_init,
debug_sym_read,
- debug_sym_read_psymbols,
debug_sym_finish,
debug_sym_offsets,
debug_sym_segments,
@@ -543,8 +530,6 @@ install_symfile_debug_logging (struct objfile *objfile)
COPY_SF_PTR (real_sf, debug_data, sym_new_init, debug_sym_new_init);
COPY_SF_PTR (real_sf, debug_data, sym_init, debug_sym_init);
COPY_SF_PTR (real_sf, debug_data, sym_read, debug_sym_read);
- COPY_SF_PTR (real_sf, debug_data, sym_read_psymbols,
- debug_sym_read_psymbols);
COPY_SF_PTR (real_sf, debug_data, sym_finish, debug_sym_finish);
COPY_SF_PTR (real_sf, debug_data, sym_offsets, debug_sym_offsets);
COPY_SF_PTR (real_sf, debug_data, sym_segments, debug_sym_segments);
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 0bd50899679..ba9a4a8cc30 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -137,13 +137,6 @@ struct sym_fns
void (*sym_read) (struct objfile *, symfile_add_flags);
- /* Read the partial symbols for an objfile. This may be NULL, in which case
- gdb has to check other ways if this objfile has any symbols. This may
- only be non-NULL if the objfile actually does have debuginfo available.
- */
-
- void (*sym_read_psymbols) (struct objfile *);
-
/* Called when we are finished with an objfile. Should do all
cleanup that is specific to the object file format for the
particular objfile. */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index a336c3fadd0..aab140d8aba 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -3004,7 +3004,6 @@ static const struct sym_fns xcoff_sym_fns =
xcoff_new_init, /* init anything gbl to entire symtab */
xcoff_symfile_init, /* read initial info, setup for sym_read() */
xcoff_initial_scan, /* read a symbol file into symtab */
- NULL, /* sym_read_psymbols */
xcoff_symfile_finish, /* finished with file, cleanup */
xcoff_symfile_offsets, /* xlate offsets ext->int form */
default_symfile_segments, /* Get segment information from a file. */
--
2.26.2
next prev 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 ` Tom Tromey [this message]
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-20-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).