From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id dFdnNFeTj2luvzkAWB0awg (envelope-from ) for ; Fri, 13 Feb 2026 16:10:47 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=Z3ds6xvc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BC7D21E08D; Fri, 13 Feb 2026 16:10:47 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 70A0D1E08D for ; Fri, 13 Feb 2026 16:10:46 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id DC8AA4B9DB7E for ; Fri, 13 Feb 2026 21:10:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC8AA4B9DB7E Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=Z3ds6xvc Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 8E1824B9DB6E for ; Fri, 13 Feb 2026 21:09:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E1824B9DB6E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8E1824B9DB6E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771016986; cv=none; b=DjGlRCTL6gKOnFXk+oyWoCKbS60rINpsEnapMOHH7N6xH43aa/enksTJdGJCJfXJsA2+5bIhZGo84uprG0pwX+7clLBG1zH+H/8ak1iouYxAIH/+Z766ySm3DMh/0bvuCwJ7kEOrV0bg+WRlD42f7uQ7gHpJGU8bMQkmI+5DpsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771016986; c=relaxed/simple; bh=oX70/ivm6ik8FTAiD1GHQyjmSb7qp/1mvqSm9x46kuU=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=jyRtdnh7kdJLaGIoUQSFYTHexrAHVdEemKFctEakrZC0eyCUUxwPyr4SRF6tmO2yPhlcLJiZJlgeG2wb1KKnyIYiawDP3/2NLqOl76keznm+QtZYut8u/0B0Py3S7gZKTeFMG8CiQl1bwQVsj9aSxd2kiJFhbdPetVvyOH3F8kY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E1824B9DB6E Received: from eig-obgw-5007b.ext.cloudfilter.net ([10.0.29.167]) by cmsmtp with ESMTPS id qvmLvdXQCKXDJr0Q6v3zlM; Fri, 13 Feb 2026 21:09:46 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id r0Q5v552dV6WMr0Q5v5ZaN; Fri, 13 Feb 2026 21:09:45 +0000 X-Authority-Analysis: v=2.4 cv=E//Npbdl c=1 sm=1 tr=0 ts=698f931a a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=ItBw4LHWJt0A:10 a=MJ7cAkC8zlywFYjcM88A:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=cuugdpKkK3yrOp5EdYkR73KUdU7G4QIlPLW+zT6lh0c=; b=Z3ds6xvcVqirjzBEfjV/LlZffE u7bp+8tvP/ho3UE5zCuI7J2ozGS/eVBZHkvqzd3Q2KtbTAZQO+63HVBwxT91B7Mb0kVaDa5PaZGAR m4dKec4kXh+01kTKDNdvZr4L9; Received: from 97-118-49-200.hlrn.qwest.net ([97.118.49.200]:47424 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vr0Q4-00000003pCY-3TTf; Fri, 13 Feb 2026 14:09:44 -0700 From: Tom Tromey Date: Fri, 13 Feb 2026 14:09:43 -0700 Subject: [PATCH 3/3] Change have_*_symbols functions to methods of program_space MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260213-random-methods-v1-3-59bdac57c3e1@tromey.com> References: <20260213-random-methods-v1-0-59bdac57c3e1@tromey.com> In-Reply-To: <20260213-random-methods-v1-0-59bdac57c3e1@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.49.200 X-Source-L: No X-Exim-ID: 1vr0Q4-00000003pCY-3TTf X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-49-200.hlrn.qwest.net ([192.168.122.1]) [97.118.49.200]:47424 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfPIf1KnF6YZ1RS+Uut2Voj6NGJMm0BU6sysurYET07rWqLAej+CQTTduHKnZbAEVqEzSg/X3YyOJVJjM70QetXChzL3yPBd91DHMzW6z7wVY0N01P+32 NQtMSw6m/p30ShAuo8LWJn03WAOBMO0kgVoWRt6nlhQWBiOlizBGhzSJjBYAyMr9zrmoTRAUTJdhowOyG798UJ1JDYYKPH7iq+I= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 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 (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 (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); 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 (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 (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