From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 17/26] Attach partial symtab storage to psymbol_functions
Date: Sun, 28 Feb 2021 13:37:54 -0700 [thread overview]
Message-ID: <20210228203803.1693413-18-tom@tromey.com> (raw)
In-Reply-To: <20210228203803.1693413-1-tom@tromey.com>
Currently, the storage for partial symtabs is attached to the objfile.
Ultimately, though, this direct assocation will be removed, and the
storage will be owned by the psymbol_functions object.
This patch is a step toward this goal. The storage is already managed
as a shared_ptr, to enable cross-objfile sharing, so this adds a
reference from the psymbol_functions, and changes some code in
psymtab.c to use this reference instead.
gdb/ChangeLog
2021-02-28 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_build_psymtabs): Call
set_partial_symtabs.
* symfile.c (syms_from_objfile_1, reread_symbols): Update.
* psymtab.h (make_psymbol_functions): Add partial_symtabs
parameter.
* psymtab.c (find_pc_sect_psymtab): Add partial_symtabs
parameter.
(psymbol_functions::find_pc_sect_compunit_symtab)
(psymbol_functions::print_stats, psymbol_functions::dump)
(psymbol_functions::has_symbols): Update.
(make_psymbol_functions, dump_psymtab_addrmap): Add
partial_symtabs parameter.
(maintenance_print_psymbols): Update.
(psymbol_functions::expand_symtabs_matching): Update.
* psympriv.h (struct psymbol_functions): Add constructor.
<m_partial_symtabs>: New member.
<set_partial_symtabs>: New method.
---
gdb/ChangeLog | 20 ++++++++++++++++++
gdb/dwarf2/read.c | 6 ++++++
gdb/psympriv.h | 15 ++++++++++++++
gdb/psymtab.c | 52 ++++++++++++++++++++++++++++-------------------
gdb/psymtab.h | 3 ++-
gdb/symfile.c | 4 ++--
6 files changed, 76 insertions(+), 24 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 9aaf484a31e..3a050b351a0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -6358,6 +6358,12 @@ dwarf2_build_psymtabs (struct objfile *objfile)
/* Partial symbols were already read, so now we can simply
attach them. */
objfile->partial_symtabs = per_bfd->partial_symtabs;
+ /* 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 ());
+ gdb_assert (psf != nullptr);
+ psf->set_partial_symtabs (per_bfd->partial_symtabs);
per_objfile->resize_symtabs ();
return;
}
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 943d6c13919..b1b8027ce3a 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -476,6 +476,11 @@ class psymtab_discarder
partial symbols. */
struct psymbol_functions : public quick_symbol_functions
{
+ explicit psymbol_functions (const std::shared_ptr<psymtab_storage> &storage)
+ : m_partial_symtabs (storage)
+ {
+ }
+
bool has_symbols (struct objfile *objfile) override;
struct symtab *find_last_source_symtab (struct objfile *objfile) override;
@@ -540,6 +545,13 @@ struct psymbol_functions : public quick_symbol_functions
m_psymbol_map.clear ();
}
+ /* Replace the partial symbol table storage in this object with
+ SYMS. */
+ void set_partial_symtabs (const std::shared_ptr<psymtab_storage> &syms)
+ {
+ m_partial_symtabs = syms;
+ }
+
private:
void fill_psymbol_map (struct objfile *objfile,
@@ -547,6 +559,9 @@ struct psymbol_functions : public quick_symbol_functions
std::set<CORE_ADDR> *seen_addrs,
const std::vector<partial_symbol *> &symbols);
+ /* Storage for the partial symbols. */
+ std::shared_ptr<psymtab_storage> m_partial_symtabs;
+
/* Map symbol addresses to the partial symtab that defines the
object at that address. */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 867b71530eb..1549ead04d0 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -275,7 +275,9 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
psymtab that contains a symbol whose address is closest to PC. */
static struct partial_symtab *
-find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
+find_pc_sect_psymtab (struct objfile *objfile,
+ psymtab_storage *partial_symtabs,
+ CORE_ADDR pc,
struct obj_section *section,
struct bound_minimal_symbol msymbol)
{
@@ -291,14 +293,14 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
partial symtabs then we will end up returning a pointer to an object
that is not a partial_symtab, which doesn't end well. */
- if (objfile->partial_symtabs->psymtabs != NULL
- && objfile->partial_symtabs->psymtabs_addrmap != NULL)
+ if (partial_symtabs->psymtabs != NULL
+ && partial_symtabs->psymtabs_addrmap != NULL)
{
CORE_ADDR baseaddr = objfile->text_section_offset ();
struct partial_symtab *pst
= ((struct partial_symtab *)
- addrmap_find (objfile->partial_symtabs->psymtabs_addrmap,
+ addrmap_find (partial_symtabs->psymtabs_addrmap,
pc - baseaddr));
if (pst != NULL)
{
@@ -367,7 +369,9 @@ psymbol_functions::find_pc_sect_compunit_symtab
struct obj_section *section,
int warn_if_readin)
{
- struct partial_symtab *ps = find_pc_sect_psymtab (objfile, pc, section,
+ struct partial_symtab *ps = find_pc_sect_psymtab (objfile,
+ m_partial_symtabs.get (),
+ pc, section,
msymbol);
if (ps != NULL)
{
@@ -1013,12 +1017,12 @@ psymbol_functions::print_stats (struct objfile *objfile, bool print_bcache)
printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"),
i);
printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
- objfile->partial_symtabs->psymbol_cache.memory_used ());
+ m_partial_symtabs->psymbol_cache.memory_used ());
}
else
{
printf_filtered (_("Psymbol byte cache statistics:\n"));
- objfile->partial_symtabs->psymbol_cache.print_statistics
+ m_partial_symtabs->psymbol_cache.print_statistics
("partial symbol cache");
}
}
@@ -1031,10 +1035,10 @@ psymbol_functions::dump (struct objfile *objfile)
{
struct partial_symtab *psymtab;
- if (objfile->partial_symtabs->psymtabs)
+ if (m_partial_symtabs->psymtabs)
{
printf_filtered ("Psymtabs:\n");
- for (psymtab = objfile->partial_symtabs->psymtabs;
+ for (psymtab = m_partial_symtabs->psymtabs;
psymtab != NULL;
psymtab = psymtab->next)
{
@@ -1321,7 +1325,7 @@ psymbol_functions::expand_symtabs_matching
for (partial_symtab *ps : require_partial_symbols (objfile, true))
ps->searched_flag = PST_NOT_SEARCHED;
- for (partial_symtab *ps : objfile->psymtabs ())
+ for (partial_symtab *ps : m_partial_symtabs->range ())
{
QUIT;
@@ -1373,7 +1377,7 @@ psymbol_functions::expand_symtabs_matching
bool
psymbol_functions::has_symbols (struct objfile *objfile)
{
- return objfile->partial_symtabs->psymtabs != NULL;
+ return m_partial_symtabs->psymtabs != NULL;
}
/* Helper function for psym_find_compunit_symtab_by_address that fills
@@ -1446,9 +1450,9 @@ psymbol_functions::find_compunit_symtab_by_address (struct objfile *objfile,
}
quick_symbol_functions_up
-make_psymbol_functions ()
+make_psymbol_functions (const std::shared_ptr<psymtab_storage> &storage)
{
- return quick_symbol_functions_up (new psymbol_functions);
+ return quick_symbol_functions_up (new psymbol_functions (storage));
}
\f
@@ -1724,14 +1728,16 @@ dump_psymtab_addrmap_1 (void *datap, CORE_ADDR start_addr, void *obj)
of PSYMTAB. If PSYMTAB is NULL print the entire addrmap. */
static void
-dump_psymtab_addrmap (struct objfile *objfile, struct partial_symtab *psymtab,
+dump_psymtab_addrmap (struct objfile *objfile,
+ psymtab_storage *partial_symtabs,
+ struct partial_symtab *psymtab,
struct ui_file *outfile)
{
struct dump_psymtab_addrmap_data addrmap_dump_data;
if ((psymtab == NULL
|| psymtab->psymtabs_addrmap_supported)
- && objfile->partial_symtabs->psymtabs_addrmap != NULL)
+ && partial_symtabs->psymtabs_addrmap != NULL)
{
addrmap_dump_data.objfile = objfile;
addrmap_dump_data.psymtab = psymtab;
@@ -1739,7 +1745,7 @@ dump_psymtab_addrmap (struct objfile *objfile, struct partial_symtab *psymtab,
addrmap_dump_data.previous_matched = 0;
fprintf_filtered (outfile, "%sddress map:\n",
psymtab == NULL ? "Entire a" : " A");
- addrmap_foreach (objfile->partial_symtabs->psymtabs_addrmap,
+ addrmap_foreach (partial_symtabs->psymtabs_addrmap,
dump_psymtab_addrmap_1, &addrmap_dump_data);
}
}
@@ -1830,14 +1836,17 @@ maintenance_print_psymbols (const char *args, int from_tty)
if (!print_for_objfile)
continue;
+ psymtab_storage *partial_symtabs = objfile->partial_symtabs.get ();
+
if (address_arg != NULL)
{
struct bound_minimal_symbol msymbol = { NULL, NULL };
/* We don't assume each pc has a unique objfile (this is for
debugging). */
- struct partial_symtab *ps = find_pc_sect_psymtab (objfile, pc,
- section, msymbol);
+ struct partial_symtab *ps
+ = find_pc_sect_psymtab (objfile, partial_symtabs, pc,
+ section, msymbol);
if (ps != NULL)
{
if (!printed_objfile_header)
@@ -1847,7 +1856,7 @@ maintenance_print_psymbols (const char *args, int from_tty)
printed_objfile_header = 1;
}
dump_psymtab (objfile, ps, outfile);
- dump_psymtab_addrmap (objfile, ps, outfile);
+ dump_psymtab_addrmap (objfile, partial_symtabs, ps, outfile);
found = 1;
}
}
@@ -1874,7 +1883,8 @@ maintenance_print_psymbols (const char *args, int from_tty)
printed_objfile_header = 1;
}
dump_psymtab (objfile, ps, outfile);
- dump_psymtab_addrmap (objfile, ps, outfile);
+ dump_psymtab_addrmap (objfile, partial_symtabs, ps,
+ outfile);
}
}
}
@@ -1886,7 +1896,7 @@ maintenance_print_psymbols (const char *args, int from_tty)
&& objfile->partial_symtabs->psymtabs_addrmap != NULL)
{
outfile->puts ("\n");
- dump_psymtab_addrmap (objfile, NULL, outfile);
+ dump_psymtab_addrmap (objfile, partial_symtabs, NULL, outfile);
}
}
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 45eaf0b9013..18b47c55b3c 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -154,6 +154,7 @@ class psymtab_storage
extern psymtab_storage::partial_symtab_range require_partial_symbols
(struct objfile *objfile, bool verbose);
-extern quick_symbol_functions_up make_psymbol_functions ();
+extern quick_symbol_functions_up make_psymbol_functions
+ (const std::shared_ptr<psymtab_storage> &);
#endif /* PSYMTAB_H */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d0b9da2138b..12746c43374 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -904,7 +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 = make_psymbol_functions ();
+ objfile->qf = make_psymbol_functions (objfile->partial_symtabs);
if (objfile->sf == NULL)
{
@@ -2555,7 +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 = make_psymbol_functions ();
+ objfile->qf = make_psymbol_functions (objfile->partial_symtabs);
build_objfile_section_table (objfile);
--
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 ` Tom Tromey [this message]
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-18-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).