From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IfM+OqmTj2luvzkAWB0awg (envelope-from ) for ; Fri, 13 Feb 2026 16:12:09 -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=Q8T2cX4G; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E966D1E0DD; Fri, 13 Feb 2026 16:12:09 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no 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 36F1B1E08D for ; Fri, 13 Feb 2026 16:12:09 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id AC3494B9DB7C for ; Fri, 13 Feb 2026 21:12:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC3494B9DB7C 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=Q8T2cX4G Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 314F04BAD158 for ; Fri, 13 Feb 2026 21:09:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 314F04BAD158 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 314F04BAD158 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771016996; cv=none; b=WXw6Vd+TVN3toHDVW2l9fIhwqsaJ4StCqrrGz5SggOrLerevvT0/6v5AyqWBaJsyg7sImdDsmGp3RktmmYxvCXtGSTI70dIrFdc4K5nmcfWzyds7DClxQoHoetZ+Ev+TGFNUSpXiFd8t30SQcbq25myEszVtgBCdJV57demRFRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771016996; c=relaxed/simple; bh=Jwgyx0FUbFb04Hp/x/F1PSNVFdIb7+LB3eSglWU8CZg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=R8exJCxTC7KyoVK4uPlkCCcohKZO3yTmPjtrqm1FiNhESV1GCrtF9YYEf39mzGFfOlwTiidO40jYGSVHmvNn9Jh29z5nR31o5AUwNLOGEYtCH7EHfzoLgKrWFVSToNYhBJkYy44IrjSyrTi5UQoGED57F5UAEuMx3UoWkNBbKwM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 314F04BAD158 Received: from eig-obgw-5004b.ext.cloudfilter.net ([10.0.29.208]) by cmsmtp with ESMTPS id qycJvkZPySkcfr0QGvfpxN; Fri, 13 Feb 2026 21:09:56 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id r0Q4vnHqRqfpWr0Q5vac0z; Fri, 13 Feb 2026 21:09:45 +0000 X-Authority-Analysis: v=2.4 cv=A55sP7WG c=1 sm=1 tr=0 ts=698f9323 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=ItBw4LHWJt0A:10 a=NCWgGup7tOOHVEjZskEA: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=zH9zDc63aFii67jvqAVVSbWONIq+TLSd61hyNWcna3I=; b=Q8T2cX4GMNpWNAGdVDc/gUwkpP QUrJ+b5ToTgFwscUKHG+eGlsgKUWHzKRSsUgBvVOCpeFRQtb65Up75ZFR8TAb5ykfwkr9DV8w1/dJ U0Ra3uv1MqScGfn9sBkhO2Bfc; 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-2A3V; Fri, 13 Feb 2026 14:09:44 -0700 From: Tom Tromey Date: Fri, 13 Feb 2026 14:09:42 -0700 Subject: [PATCH 2/3] Use std::optional in entry_point_address_query MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260213-random-methods-v1-2-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-2A3V 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: 7 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDA0BSQnE5DmuZNt77rZapM18kUUd7oE3NEg5PP8fdoCkfT1DWG4WsTIBP4F2iMO94Tln0GxhPmL7SOzXCBrx4+dyE6sb6qH+W4ktfqwC2WacBpKqUPn zPM/HRB5lsVqxY63jY7fxuqhkku6LHiQGnjf7qvmnEOOVqke34FTHXtYvoUZ97gmZII5S9OLY9JdQZgDAumEWeu9jPXwUp7N3c0= 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 entry_point_address_query to return a std::optional. --- gdb/frame.c | 8 ++++---- gdb/progspace.c | 16 +++++++--------- gdb/progspace.h | 4 ++-- gdb/solib-frv.c | 9 +++++---- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index bfc85296942..5509e5ab7d7 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2675,12 +2675,12 @@ inside_main_func (const frame_info_ptr &this_frame) static bool inside_entry_func (const frame_info_ptr &this_frame) { - CORE_ADDR entry_point; - - if (!current_program_space->entry_point_address_query (&entry_point)) + std::optional entry_point + = current_program_space->entry_point_address_query (); + if (!entry_point.has_value ()) return false; - return get_frame_func (this_frame) == entry_point; + return get_frame_func (this_frame) == *entry_point; } /* Return a structure containing various interesting information about diff --git a/gdb/progspace.c b/gdb/progspace.c index bfd7ca5bcb9..3e10e57012b 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -287,17 +287,15 @@ program_space::empty () /* See progspace.h. */ -int -program_space::entry_point_address_query (CORE_ADDR *entry_p) const +std::optional +program_space::entry_point_address_query () const { objfile *objf = symfile_object_file; if (objf == NULL || !objf->per_bfd->ei.entry_point_p) - return 0; + return {}; int idx = objf->per_bfd->ei.the_bfd_section_index; - *entry_p = objf->per_bfd->ei.entry_point + objf->section_offsets[idx]; - - return 1; + return objf->per_bfd->ei.entry_point + objf->section_offsets[idx]; } /* See progspace.h. */ @@ -305,12 +303,12 @@ program_space::entry_point_address_query (CORE_ADDR *entry_p) const CORE_ADDR program_space::entry_point_address () const { - CORE_ADDR retval; + std::optional retval = entry_point_address_query (); - if (!entry_point_address_query (&retval)) + if (!retval.has_value ()) error (_("Entry point address is not known.")); - return retval; + return *retval; } /* Prints the list of program spaces and their details on UIOUT. If diff --git a/gdb/progspace.h b/gdb/progspace.h index 68d5ad35413..3ed33b2e472 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -333,8 +333,8 @@ struct program_space } /* If there is a valid and known entry point in this program space, - fill *ENTRY_P with it and return non-zero. */ - int entry_point_address_query (CORE_ADDR *entry_p) const; + return it. Otherwise return an empty optional. */ + std::optional entry_point_address_query () const; /* Get the entry point address in this program space. Call error if it is not known. */ diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 4460362a57f..95f97dc1133 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -689,7 +689,6 @@ static int enable_break (void) { asection *interp_sect; - CORE_ADDR entry_point; if (current_program_space->symfile_object_file == NULL) { @@ -697,7 +696,9 @@ enable_break (void) return 0; } - if (!current_program_space->entry_point_address_query (&entry_point)) + std::optional entry_point + = current_program_space->entry_point_address_query (); + if (!entry_point.has_value ()) { solib_debug_printf ("Symbol file has no entry point."); return 0; @@ -715,10 +716,10 @@ enable_break (void) return 0; } - create_solib_event_breakpoint (current_inferior ()->arch (), entry_point); + create_solib_event_breakpoint (current_inferior ()->arch (), *entry_point); solib_debug_printf ("solib event breakpoint placed at entry point: %s", - hex_string_custom (entry_point, 8)); + hex_string_custom (*entry_point, 8)); return 1; } -- 2.49.0