From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/4] gdb: add new function quick_symbol_functions::has_unexpanded_symbols
Date: Mon, 26 Apr 2021 18:07:00 +0100 [thread overview]
Message-ID: <87ca93b987e114d57bb549ae72d6635148341e22.1619456691.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1619456691.git.andrew.burgess@embecosm.com>
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.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* dwarf2/read.c (struct dwarf2_base_index_functions)
<has_unexpanded_symbols>: Declare.
(dwarf2_base_index_functions::has_unexpanded_symbols): Define new
function.
* objfiles.h (struct objfile) <has_unexpanded_symbols>: Declare.
* psympriv.h (struct psymbol_functions) <has_unexpanded_symbols>:
Declare.
* psymtab.c (psymbol_functions::has_unexpanded_symbols): Define
new function.
* quick-symbol.h (struct quick_symbol_functions)
<has_unexpanded_symbols>: Declare.
* symfile-debug.c (objfile::has_unexpanded_symbols): Define new
function.
---
gdb/ChangeLog | 16 ++++++++++++++++
gdb/dwarf2/read.c | 22 ++++++++++++++++++++++
gdb/objfiles.h | 6 ++++++
gdb/psympriv.h | 2 ++
gdb/psymtab.c | 18 ++++++++++++++++++
gdb/quick-symbol.h | 6 ++++++
gdb/symfile-debug.c | 13 +++++++++++++
7 files changed, 83 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 306971ef1b7..5ab0c59c7ae 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2275,6 +2275,8 @@ struct dwarf2_base_index_functions : public quick_symbol_functions
{
bool has_symbols (struct objfile *objfile) override;
+ bool has_unexpanded_symbols (struct objfile *objfile) override;
+
struct symtab *find_last_source_symtab (struct objfile *objfile) override;
void forget_cached_source_info (struct objfile *objfile) override;
@@ -4767,6 +4769,26 @@ dwarf2_base_index_functions::has_symbols (struct objfile *objfile)
return true;
}
+/* See quick_symbol_functions::has_unexpanded_symbols in quick-symbol.h. */
+
+bool
+dwarf2_base_index_functions::has_unexpanded_symbols (struct objfile *objfile)
+{
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+
+ for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units)
+ {
+ /* Is this already expanded? */
+ if (per_objfile->symtab_set_p (per_cu))
+ 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. */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 5a8a782a646..72d9bab5555 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -565,6 +565,12 @@ struct objfile
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_symbols ();
+
/* See quick_symbol_functions. */
struct symtab *find_last_source_symtab ();
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 59dd66f57e5..1712ad978e6 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -503,6 +503,8 @@ struct psymbol_functions : public quick_symbol_functions
bool has_symbols (struct objfile *objfile) override;
+ bool has_unexpanded_symbols (struct objfile *objfile) override;
+
struct symtab *find_last_source_symtab (struct objfile *objfile) override;
void forget_cached_source_info (struct objfile *objfile) override;
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 75a307c89aa..cc5eb503902 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1185,6 +1185,24 @@ psymbol_functions::has_symbols (struct objfile *objfile)
return m_partial_symtabs->psymtabs != NULL;
}
+/* See quick_symbol_functions::has_unexpanded_symbols in quick-symbol.h. */
+
+bool
+psymbol_functions::has_unexpanded_symbols (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. */
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index f06ceff41c2..096053e75e9 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -86,6 +86,12 @@ struct quick_symbol_functions
available. */
virtual bool has_symbols (struct objfile *objfile) = 0;
+ /* Return true if OBJFILE has any unexpanded symbols. A return value of
+ false indicates there are no unexpanded symbols, this might mean that
+ all of the symbols have been expanded (full debug has been read in),
+ or it might been that OBJFILE has no debug information. */
+ virtual bool has_unexpanded_symbols (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;
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index b839194e2f7..cfc3bed9222 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -100,6 +100,19 @@ objfile::has_partial_symbols ()
return retval;
}
+/* See objfiles.h. */
+bool
+objfile::has_unexpanded_symbols ()
+{
+ for (const auto &iter : qf)
+ {
+ if (iter->has_unexpanded_symbols (this))
+ return true;
+ }
+
+ return false;
+}
+
struct symtab *
objfile::find_last_source_symtab ()
{
--
2.25.4
next prev parent reply other threads:[~2021-04-26 17:07 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-26 17:06 [PATCH 0/4] New option for 'info sources', also better MI support Andrew Burgess
2021-04-26 17:07 ` Andrew Burgess [this message]
2021-05-13 14:38 ` [PATCH 1/4] gdb: add new function quick_symbol_functions::has_unexpanded_symbols Simon Marchi via Gdb-patches
2021-05-13 17:29 ` Tom Tromey
2021-05-13 14:46 ` Simon Marchi via Gdb-patches
2021-04-26 17:07 ` [PATCH 2/4] gdb: make struct output_source_filename_data more C++ like Andrew Burgess
2021-05-13 14:58 ` Simon Marchi via Gdb-patches
2021-04-26 17:07 ` [PATCH 3/4] gdb: add new -group-by-binary flag to info sources command Andrew Burgess
2021-04-26 17:34 ` Eli Zaretskii via Gdb-patches
2021-05-13 15:05 ` Simon Marchi via Gdb-patches
2021-05-15 8:45 ` Andrew Burgess
2021-05-15 13:19 ` Simon Marchi via Gdb-patches
2021-04-26 17:07 ` [PATCH 4/4] gdb/mi: extend -file-list-exec-source-files command Andrew Burgess
2021-04-26 17:39 ` Eli Zaretskii via Gdb-patches
2021-05-13 15:47 ` Simon Marchi via Gdb-patches
2021-05-13 10:34 ` [PATCH 0/4] New option for 'info sources', also better MI support Andrew Burgess
2021-05-19 11:12 ` [PATCHv2 0/5] "info sources" - group by objfile Andrew Burgess
2021-05-19 11:12 ` [PATCHv2 1/5] gdb: add new function quick_symbol_functions::has_unexpanded_symbols Andrew Burgess
2021-05-19 11:12 ` [PATCHv2 2/5] gdb: make struct output_source_filename_data more C++ like Andrew Burgess
2021-05-19 11:12 ` [PATCHv2 3/5] gdb/mi: add regexp filtering to -file-list-exec-source-files Andrew Burgess
2021-05-19 11:51 ` Eli Zaretskii via Gdb-patches
2021-05-19 11:12 ` [PATCHv2 4/5] gdb/mi: add new --group-by-objfile flag for -file-list-exec-source-files Andrew Burgess
2021-05-19 11:44 ` Eli Zaretskii via Gdb-patches
2021-05-19 11:12 ` [PATCHv2 5/5] gdb: change info sources to group results by objfile Andrew Burgess
2021-05-19 11:53 ` Eli Zaretskii via Gdb-patches
2021-06-03 13:08 ` Simon Marchi via Gdb-patches
2021-06-03 9:27 ` [PATCHv2 0/5] "info sources" - group " Andrew Burgess
2021-06-03 13:15 ` Simon Marchi via Gdb-patches
2021-06-07 18:32 ` [PATCHv3 " Andrew Burgess
2021-06-07 18:32 ` [PATCHv3 1/5] gdb: add new function quick_symbol_functions::has_unexpanded_symbols Andrew Burgess
2021-06-07 18:32 ` [PATCHv3 2/5] gdb: make struct output_source_filename_data more C++ like Andrew Burgess
2021-07-05 12:31 ` Tom de Vries
2021-07-26 13:21 ` Andrew Burgess
2021-06-07 18:32 ` [PATCHv3 3/5] gdb/mi: add regexp filtering to -file-list-exec-source-files Andrew Burgess
2021-06-07 18:32 ` [PATCHv3 4/5] gdb/mi: add new --group-by-objfile flag for -file-list-exec-source-files Andrew Burgess
2021-06-07 18:32 ` [PATCHv3 5/5] gdb: change info sources to group results by objfile Andrew Burgess
2021-06-21 12:02 ` PING! Re: [PATCHv3 0/5] "info sources" - group " Andrew Burgess
2021-06-25 20:08 ` Andrew Burgess
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=87ca93b987e114d57bb549ae72d6635148341e22.1619456691.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.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