From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 3/3] Change have_*_symbols functions to methods of program_space
Date: Fri, 13 Feb 2026 14:09:43 -0700 [thread overview]
Message-ID: <20260213-random-methods-v1-3-59bdac57c3e1@tromey.com> (raw)
In-Reply-To: <20260213-random-methods-v1-0-59bdac57c3e1@tromey.com>
This changes the have_*_symbols functions to be methods of
program_space.
---
gdb/ada-exp.y | 4 ++--
gdb/c-exp.y | 4 ++--
gdb/cli/cli-cmds.c | 4 ++--
gdb/d-exp.y | 4 ++--
gdb/go-exp.y | 4 ++--
gdb/linespec.c | 10 +++++-----
gdb/objfiles.c | 37 -------------------------------------
gdb/objfiles.h | 12 ------------
gdb/p-exp.y | 4 ++--
gdb/parse.c | 4 ++--
gdb/progspace.c | 36 ++++++++++++++++++++++++++++++++++++
gdb/progspace.h | 12 ++++++++++++
gdb/source.c | 4 ++--
gdb/symfile.c | 8 ++++----
gdb/symtab.c | 8 ++++----
gdb/tui/tui-disasm.c | 4 ++--
16 files changed, 79 insertions(+), 80 deletions(-)
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 771a867c4ae..1a7d17f9d04 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1870,8 +1870,8 @@ write_var_or_type (struct parser_state *par_state,
}
}
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space)
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ()
&& block == NULL)
error (_("No symbol table is loaded. Use the \"file\" command."));
if (block == par_state->expression_context_block)
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 9a37eb5fb69..68e728ef1b0 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1201,8 +1201,8 @@ variable: name_not_typename
= lookup_minimal_symbol (current_program_space, arg.c_str ());
if (msymbol.minsym == NULL)
{
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."),
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 5cf8f87cd75..21d067c4f5d 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1349,8 +1349,8 @@ list_command (const char *arg, int from_tty)
and clear NO_END; however, if one of the arguments is blank,
set DUMMY_BEG or DUMMY_END to record that fact. */
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
std::vector<symtab_and_line> sals;
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index eef87702353..e0ce8a86473 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -466,8 +466,8 @@ PrimaryExpression:
= lookup_minimal_symbol (current_program_space, copy.c_str ());
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation> (msymbol);
- else if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ else if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command"));
else
error (_("No symbol \"%s\" in current context."),
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index d6060c9567d..a7114152069 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -575,8 +575,8 @@ variable: name_not_typename
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation>
(msymbol);
- else if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ else if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. "
"Use the \"file\" command."));
else
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 4376a769e49..873e085a4c8 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1524,9 +1524,9 @@ symbol_not_found_error (const char *symbol, const char *filename)
if (symbol == NULL)
symbol = "";
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space)
- && !have_minimal_symbols (current_program_space))
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ()
+ && !current_program_space->have_minimal_symbols ())
throw_error (NOT_FOUND_ERROR,
_("No symbol table is loaded. Use the \"file\" command."));
@@ -3648,8 +3648,8 @@ symtabs_from_filename (const char *filename,
if (result.empty ())
{
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
throw_error (NOT_FOUND_ERROR,
_("No symbol table is loaded. "
"Use the \"file\" command."));
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 4f5258e971d..ff98cf28ca6 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -611,31 +611,6 @@ objfile::has_symbols ()
return false;
}
-/* See objfiles.h. */
-
-bool
-have_partial_symbols (program_space *pspace)
-{
- for (objfile &ofp : pspace->objfiles ())
- if (ofp.has_partial_symbols ())
- return true;
-
- return false;
-}
-
-/* See objfiles.h. */
-
-bool
-have_full_symbols (program_space *pspace)
-{
- for (objfile &ofp : pspace->objfiles ())
- if (ofp.has_full_symbols ())
- return true;
-
- return false;
-}
-
-
/* See objfiles.h. */
void
@@ -651,18 +626,6 @@ objfile_purge_solibs (program_space *pspace)
}
}
-/* See objfiles.h. */
-
-bool
-have_minimal_symbols (program_space *pspace)
-{
- for (objfile &ofp : pspace->objfiles ())
- if (ofp.per_bfd->minimal_symbol_count > 0)
- return true;
-
- return false;
-}
-
/* Qsort comparison function. */
static bool
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 371fd223693..89ac559ce81 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -912,14 +912,6 @@ extern void objfile_relocate (struct objfile *,
gdb::array_view<const CORE_ADDR>);
extern void objfile_rebase (struct objfile *, CORE_ADDR);
-/* Return true if any objfile of PSPACE has partial symbols. */
-
-extern bool have_partial_symbols (program_space *pspace);
-
-/* Return true if any objfile of PSPACE has full symbols. */
-
-extern bool have_full_symbols (program_space *pspace);
-
extern void objfile_set_sym_fns (struct objfile *objfile,
const struct sym_fns *sf);
@@ -948,10 +940,6 @@ extern void objfile_purge_solibs (program_space *pspace);
/* Functions for dealing with the minimal symbol table, really a misc
address<->symbol mapping for things we don't have debug symbols for. */
-/* Return true if any objfile of PSPACE has minimal symbols. */
-
-extern bool have_minimal_symbols (program_space *pspace);
-
extern struct obj_section *find_pc_section (CORE_ADDR pc);
/* Return true if PC is in a section called NAME. */
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 8195a08c1ac..000ac5342e2 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -723,8 +723,8 @@ variable: name_not_typename
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation>
(msymbol);
- else if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ else if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. "
"Use the \"file\" command."));
else
diff --git a/gdb/parse.c b/gdb/parse.c
index 21a59d0f2be..e7592d0fd23 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -148,8 +148,8 @@ parser_state::push_symbol (const char *name, block_symbol sym)
= lookup_minimal_symbol (current_program_space, name);
if (msymbol.minsym != NULL)
push_new<expr::var_msym_value_operation> (msymbol);
- else if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ else if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."), name);
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 3e10e57012b..6edd750334c 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -311,6 +311,42 @@ program_space::entry_point_address () const
return *retval;
}
+/* See progspace.h. */
+
+bool
+program_space::have_partial_symbols ()
+{
+ for (objfile &ofp : objfiles ())
+ if (ofp.has_partial_symbols ())
+ return true;
+
+ return false;
+}
+
+/* See progspace.h. */
+
+bool
+program_space::have_full_symbols ()
+{
+ for (objfile &ofp : objfiles ())
+ if (ofp.has_full_symbols ())
+ return true;
+
+ return false;
+}
+
+/* See progspace.h. */
+
+bool
+program_space::have_minimal_symbols ()
+{
+ for (objfile &ofp : objfiles ())
+ if (ofp.per_bfd->minimal_symbol_count > 0)
+ return true;
+
+ return false;
+}
+
/* Prints the list of program spaces and their details on UIOUT. If
REQUESTED is not -1, it's the ID of the pspace that should be
printed. Otherwise, all spaces are printed. */
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 3ed33b2e472..b3d8d6d39ed 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -340,6 +340,18 @@ struct program_space
it is not known. */
CORE_ADDR entry_point_address () const;
+ /* Return true if any objfile of this program space has partial
+ symbols. */
+ bool have_partial_symbols ();
+
+ /* Return true if any objfile of this program space has full
+ symbols. */
+ bool have_full_symbols ();
+
+ /* Return true if any objfile of this program space has minimal
+ symbols. */
+ bool have_minimal_symbols ();
+
/* Unique ID number. */
int num = 0;
diff --git a/gdb/source.c b/gdb/source.c
index f890533b931..cd5434a80a2 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -254,8 +254,8 @@ get_current_source_symtab_and_line (program_space *pspace)
void
set_default_source_symtab_and_line (void)
{
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
/* Pull in a current source symtab if necessary. */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index aadb449153e..48daf66673d 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1040,8 +1040,8 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
if (from_tty
&& (always_confirm
- || ((have_full_symbols (current_program_space)
- || have_partial_symbols (current_program_space))
+ || ((current_program_space->have_full_symbols ()
+ || current_program_space->have_partial_symbols ())
&& mainline))
&& !query (_("Load new symbol table from \"%s\"? "), name))
error (_("Not confirmed."));
@@ -1189,8 +1189,8 @@ symbol_file_add_main_1 (const char *args, symfile_add_flags add_flags,
void
symbol_file_clear (int from_tty)
{
- if ((have_full_symbols (current_program_space)
- || have_partial_symbols (current_program_space))
+ if ((current_program_space->have_full_symbols ()
+ || current_program_space->have_partial_symbols ())
&& from_tty
&& (current_program_space->symfile_object_file
? !query (_("Discard symbol table from `%s'? "),
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 07436104ce7..1aaa1d9e5d7 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4573,8 +4573,8 @@ info_sources_worker (struct ui_out *uiout,
static void
info_sources_command (const char *args, int from_tty)
{
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
filename_partial_match_opts match_opts;
@@ -6258,8 +6258,8 @@ make_source_files_completion_list (const char *text)
const char *base_name;
struct add_partial_filename_data datum;
- if (!have_full_symbols (current_program_space)
- && !have_partial_symbols (current_program_space))
+ if (!current_program_space->have_full_symbols ()
+ && !current_program_space->have_partial_symbols ())
return list;
filename_seen_cache filenames_seen;
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 2b22ca9efca..fee5eb53c61 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -393,8 +393,8 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
if (tui_location.addr () == 0)
{
- if (have_full_symbols (current_program_space)
- || have_partial_symbols (current_program_space))
+ if (current_program_space->have_full_symbols ()
+ || current_program_space->have_partial_symbols ())
{
set_default_source_symtab_and_line ();
symtab_and_line sal
--
2.49.0
next prev parent reply other threads:[~2026-02-13 21:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 21:09 [PATCH 0/3] Change some " Tom Tromey
2026-02-13 21:09 ` [PATCH 1/3] Move entry point functions to program_space Tom Tromey
2026-02-13 21:09 ` [PATCH 2/3] Use std::optional in entry_point_address_query Tom Tromey
2026-02-13 21:09 ` Tom Tromey [this message]
2026-02-14 4:16 ` [PATCH 3/3] Change have_*_symbols functions to methods of program_space Simon Marchi
2026-02-14 17:33 ` Tom Tromey
2026-02-14 4:17 ` [PATCH 0/3] Change some " 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=20260213-random-methods-v1-3-59bdac57c3e1@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