From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Qc7lEDse42pbuAYAWB0awg (envelope-from ) for ; Thu, 29 Oct 2026 06:21:47 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W1UP98pJ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 40A841E023; Thu, 29 Oct 2026 06:21:47 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 1BA8E1E023 for ; Thu, 29 Oct 2026 06:21:46 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B43B14BA23F5 for ; Thu, 29 Oct 2026 10:21:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B43B14BA23F5 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W1UP98pJ Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 61E0F4BA23EF for ; Thu, 29 Oct 2026 10:21:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61E0F4BA23EF Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 61E0F4BA23EF Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793269265; cv=none; b=jdzyNoDWMOqOE0Lb6ekS2wRJos4YpWzu2s6Y9PrJvgQ6TcPQLkac6S+xSlgzMwXUEqf4jHz5u7D4drcVP67ncF1pDrS+GtEeMWug31DwRyHRKZx8QutXLqsqDuBR2d5XCyEkbZI2sP9UbBjdD+LTid9XBadcceoxfTNfoq6dBF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793269265; c=relaxed/simple; bh=jeW9TCxZQXITUpD/AsiQoytfBlY/7hG4YuK4/iCKwmU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=cBYUDxqrpc6JtW0Lv4BdqwUF0iQEuCUnDdHSj/VGzRj8kcXGQzQojt6Q4Com2IkBRIbX7qQeAdGjko8TZJI1pJVlyLSI+aK7SxA/VgMaKzVAQR7/Snk5Cz/n9cpNbp5zgVMatPPmtUFYlBP+dzxtDhauGUK2MqxUaF8ElJZckj0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W1UP98pJ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61E0F4BA23EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793269264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MbXLOQ1TRVFak38q63hji2rdApLSlcWOCoxb/BF3GbY=; b=W1UP98pJXXm5TgMC4c9ZWLKKOW2cs8vF7IwzK2OggqglQeP3msBUbQ3c1TLw7tJav7qtFS vjz0DdL4AEOrZEtAqVQQ9oAfFmImHSy9oaXJ1N9qJznsZskrXkMN9PnrPktZIPLxDizRWq 5P4qioNMdPHCyRNzEn19VFB44ih+NZE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-711-Tia0d3CiN0WTAaAI5a_0mw-1; Thu, 29 Oct 2026 06:21:03 -0400 X-MC-Unique: Tia0d3CiN0WTAaAI5a_0mw-1 X-Mimecast-MFC-AGG-ID: Tia0d3CiN0WTAaAI5a_0mw_1793269262 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48dff112181so1724429f8f.3 for ; Thu, 29 Oct 2026 03:21:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793269262; x=1793874062; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=MbXLOQ1TRVFak38q63hji2rdApLSlcWOCoxb/BF3GbY=; b=Nm1VBuZ833w6bZmw0AwKxCF0diwHNBFdUyZukEVNgZLC34S11eRmhJNMAKYo3KqKjT LNKaZXFz+0nQyideZjvV0Mb9KSAX8qaRkvEt3n0hEVgjFKi1dwIWte47JN3MYujhmNKy UgS95j+nQhPf7rqxFSRjR5D/cA9O++sZNldBaEZD+clqWQdOJNdpxrrwZ1B2xiJFGvzC JFAD4K7Y1LLVL5c0fmAcBDWdzX5p5nyOlmFkzp2uqaNGRLQtLo3rsBpW68sGCZdKaCEJ E6kzTLWJX+Qq++3DIWtQot5jsDnxJ3XVE/IHOvv4vmIiVpjTzdJbpgTJj3DP8VohklUY CgOg== X-Gm-Message-State: AFq9FYLkXaIoO0N5eAgSdhe741J0f+DPA+GYpsRl4CLcdYi6V/1yY68+ QF1AvrgceUUWhVrFqP9ehAFqSLAQQ1oXKc6i4jTcDEc9bnt/C5uAEeiLdgLjvhFSmgn0LylPqCv kpiLsyNkHS2QwPqsvtEyj9EPkH1EgnbxgUHfwE454uQChkj7PgW177LnlQY35bfWHSHWMNpNBnw lpgaqQma6h4cxPXF8G7a/IQxwws6WSD/BByEicLBljaljfIe0= X-Gm-Gg: AYBFou0Q2lm7aEBGbN8a0GSH6hl/iZPwQQ2q5ZBrlTEvohYMl6Zz9nZnXrTLM2hnxpf GnEcD37Egs2AO52qFn4hDNS+Q7qx4nHTzD1TZAqIVrQumF5YViEThmyDH2UhV0OGFzn5nT4jpS2 pYGwP34aK8rRqOYU0pM38Rk/wOctnQvpV0PLSBeNPfmN2xGhJXmn/XZHP19ZsDPJJoRVbzW/BSA DUJ+BZKaZmnzPLoSU6iX51Pbf/b29OxcYgJZGtjQCgRT4gTcjIGztlPY6ifgSr66rJxrU5HonmZ y282VTNvF7VGzcRBefsJQvf0T+Ymgo/qRRmVVMngigQuIaHn/8m/V+B+BvpknUICZPMXFveytk+ nHurUXJSih3GJC5ClkYXS1jtsvpU2q0D0WcVRgYu/KwQMUyA= X-Received: by 2002:a05:600c:3541:b0:4a1:f68a:9736 with SMTP id 5b1f17b1804b1-4a9672014d4mr116538875e9.26.1793269261584; Thu, 29 Oct 2026 03:21:01 -0700 (PDT) X-Received: by 2002:a05:600c:3541:b0:4a1:f68a:9736 with SMTP id 5b1f17b1804b1-4a9672014d4mr116538215e9.26.1793269261009; Thu, 29 Oct 2026 03:21:01 -0700 (PDT) Received: from localhost ([2a00:23c6:e11d:fb01:6748:4fce:3e30:6e23]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ebcb846sm33775401f8f.25.2026.10.29.03.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2026 03:20:59 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , Pedro Alves Subject: [PATCHv10 2/5] gdb: rename program_space::entry_point_address* functions Date: Thu, 29 Oct 2026 10:20:48 +0000 Message-Id: <0218116b07c0f7f81a2831e0bde5227ca0b3e874.1793268860.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: G9p4KF0JzhxdUjbI7eenCvCfX6FnjIcs6Z1Obu4Pank_1793269262 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 Rename program_space::entry_point_address to program_space::exec_entry_point_address and program_space::entry_point_address_query to program_space::exec_entry_point_address_if_available. There are two aspects to this renaming. First I replace 'query' with 'if_available' in one of the functions. I feel this better describes the function, and also is inline with how other, similar, functions are named in GDB. The second part of the renaming is to add the 'exec_' prefix to the front of both function names. When a dynamically linked inferior is started the first instruction executed is actually within the run-time linker, not within the main executable, so it could be argued that the actual entry address for the inferior is not the entry address of the main executable. However, there is an equally valid argument that the entry address of the executable is also something worth finding. The existing entry address within the inferior is used for a number of tasks in GDB, for example displaced stepping (arch-utils.c), inferior function calls (arc-tdep.c and infcall.c), and for detecting the "entry" frame. This last one, the entry frame detection is interesting. In a dynamically linked executable it could be argued that there are two entry frames. The very first frame that is executed in the inferior, this is where 'starti' stops the inferior. And then the very first frame within the main executable. I think that both of these are valid. Currently, as we can only find the entry address within the main executable, we can only identify the first frame of the main executable. And this can cause some problems, consider: (gdb) starti Starting program: /tmp/hello Program stopped. 0x00007ffff7fd3110 in _start () from /lib64/ld-linux-x86-64.so.2 (gdb) bt #0 0x00007ffff7fd3110 in _start () from /lib64/ld-linux-x86-64.so.2 #1 0x0000000000000001 in ?? () #2 0x00007fffffffac13 in ?? () #3 0x0000000000000000 in ?? () (gdb) Here frames #1 to #3 are all bogus, created by GDB based on whatever values happen to be in the registers when the inferior starts. In a later commit I'd like to fix this problem, however, I would prefer that the other users of program_space::entry_point_address continue to use the address within the main executable. So, in order to keep the distinction between the two different types of entry point, I'm renaming the existing functions with the 'exec_' prefix. There should be no user visible changes after this commit. Approved-By: Pedro Alves --- gdb/arc-tdep.c | 2 +- gdb/arch-utils.c | 2 +- gdb/frame.c | 4 ++-- gdb/infcall.c | 2 +- gdb/linux-tdep.c | 2 +- gdb/progspace.c | 6 +++--- gdb/progspace.h | 12 ++++++------ gdb/solib-frv.c | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 4936a5c8fbb..7ed83c4cae6 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -860,7 +860,7 @@ arc_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, struct regcache *regcache) { *real_pc = funaddr; - *bp_addr = current_program_space->entry_point_address (); + *bp_addr = current_program_space->exec_entry_point_address (); return sp; } diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 473a352e781..3560b1b9072 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -57,7 +57,7 @@ displaced_step_at_entry_point (struct gdbarch *gdbarch) CORE_ADDR addr; int bp_len; - addr = current_program_space->entry_point_address (); + addr = current_program_space->exec_entry_point_address (); /* Inferior calls also use the entry point as a breakpoint location. We don't want displaced stepping to interfere with those diff --git a/gdb/frame.c b/gdb/frame.c index 6b02c5f559a..1ef7bd2111c 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2704,7 +2704,7 @@ static bool inside_entry_func (const frame_info_ptr &this_frame) { std::optional entry_point - = current_program_space->entry_point_address_query (); + = current_program_space->exec_entry_point_address_if_available (); if (!entry_point.has_value ()) return false; @@ -2780,7 +2780,7 @@ get_prev_frame (const frame_info_ptr &this_frame) added to work around that (now fixed) case. */ /* NOTE: cagney/2003-07-15: danielj (if I'm reading it right) suggested having the inside_entry_func test use the - inside_main_func() msymbol trick (along with entry_point_address() + inside_main_func() msymbol trick (along with exec_entry_point_address() I guess) to determine the address range of the start function. That should provide a far better stopper than the current heuristics. */ diff --git a/gdb/infcall.c b/gdb/infcall.c index 4c40f6cb06e..0daf8c4e67e 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -1308,7 +1308,7 @@ call_function_by_hand_dummy (struct value *function, CORE_ADDR dummy_addr; real_pc = funaddr; - dummy_addr = current_program_space->entry_point_address (); + dummy_addr = current_program_space->exec_entry_point_address (); /* A call dummy always consists of just a single breakpoint, so its address is the same as the address of the dummy. diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 4f6910694d5..86709b5555a 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -3040,7 +3040,7 @@ linux_displaced_step_location (struct gdbarch *gdbarch) /* Determine entry point from target auxiliary vector. This avoids the need for symbols. Also, when debugging a stand-alone SPU - executable, entry_point_address () will point to an SPU + executable, exec_entry_point_address () will point to an SPU local-store address and is thus not usable as displaced stepping location. The auxiliary vector gets us the PowerPC-side entry point address instead. */ diff --git a/gdb/progspace.c b/gdb/progspace.c index a9d13c91598..e5cea97bcc1 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -345,7 +345,7 @@ program_space::empty () /* See progspace.h. */ std::optional -program_space::entry_point_address_query () const +program_space::exec_entry_point_address_if_available () const { objfile *objf = symfile_object_file; if (objf == NULL || !objf->per_bfd->ei.entry_point_p) @@ -358,9 +358,9 @@ program_space::entry_point_address_query () const /* See progspace.h. */ CORE_ADDR -program_space::entry_point_address () const +program_space::exec_entry_point_address () const { - std::optional retval = entry_point_address_query (); + std::optional retval = exec_entry_point_address_if_available (); if (!retval.has_value ()) error (_("Entry point address is not known.")); diff --git a/gdb/progspace.h b/gdb/progspace.h index 513f5c157b6..9d23347b9ee 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -348,13 +348,13 @@ struct program_space return m_target_sections; } - /* If there is a valid and known entry point in this program space, - return it. Otherwise return an empty optional. */ - std::optional entry_point_address_query () const; + /* If there is a valid and known entry point in the main executable of + this program space, return it. Otherwise return an empty optional. */ + std::optional exec_entry_point_address_if_available () const; - /* Get the entry point address in this program space. Call error if - it is not known. */ - CORE_ADDR entry_point_address () const; + /* Get the entry point address for the main executable in this program + space. Call error if it is not known. */ + CORE_ADDR exec_entry_point_address () const; /* Return true if any objfile of this program space has partial symbols. */ diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index d616fa8a6dd..f5ac0e25a67 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -689,7 +689,7 @@ enable_break (void) } std::optional entry_point - = current_program_space->entry_point_address_query (); + = current_program_space->exec_entry_point_address_if_available (); if (!entry_point.has_value ()) { solib_debug_printf ("Symbol file has no entry point."); -- 2.25.4