From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EcZrCe4AUWpD0QEAWB0awg (envelope-from ) for ; Fri, 10 Jul 2026 10:25:50 -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=KAKxC2jP; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 236AF1E098; Fri, 10 Jul 2026 10:25:50 -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 [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 124F61E070 for ; Fri, 10 Jul 2026 10:25:49 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30BCC4BA23E0 for ; Fri, 10 Jul 2026 14:25:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30BCC4BA23E0 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=KAKxC2jP Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id B40CE4BA2E15 for ; Fri, 10 Jul 2026 14:24:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B40CE4BA2E15 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 B40CE4BA2E15 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783693459; cv=none; b=HfsJz5R/SenyGQz+oWwZly4G1xwMSaf07Z8iG+eFfBs64gRgu2Hvl7kUORDy7xzczEcXwa8QkLsadC1De9RBCYTBgcNkrox6u1duSyviaP77m3UlDIU+IEuNznGaDlZC0uuLfOU7GJPWV+Lybns/pQQOSlUwHehRMwtSl1ZvfwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783693459; c=relaxed/simple; bh=kHKNF8tJZf23/Xrkl0g7ZVxChbzFcbCtdt6f8S+fb5Q=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ZUfmKTzmJhqq+CojUnXl6FdQhNOKGidQoHo97lPMqNTMR/p410BJ2anqvVKprnPY51JqIX6l6dziOCzgAmByFK4cwPiAO2g/ZxKiCVaDnuattchy0w1c32LwfIXZoKWAjEkgrpE++bYq0usdLCgDqaDClypfkVOZ43BLbN0Ahhw= 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=KAKxC2jP DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B40CE4BA2E15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783693459; 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=Gy5lAyrsruVVQe+ujUccoRGoLZIMDCI8r+vPhtBLh0Y=; b=KAKxC2jPBLaCcdm7jaW9hbu5fUmU1K0eo8e9sraNozwKuptMu9W2i9sUH/w3IXc5xJa6Ky gE0J+y5ZXSimlD/jSmPvk/FCxWRNkgKTgdpE68j38RvQz4hukrazepv3jClPLU0SUKGS+n TDZ8oYm8M3cbI9OTDwwuLqtknb+Ok+M= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-jwsseozLMgGjOWfiwCc8RA-1; Fri, 10 Jul 2026 10:24:15 -0400 X-MC-Unique: jwsseozLMgGjOWfiwCc8RA-1 X-Mimecast-MFC-AGG-ID: jwsseozLMgGjOWfiwCc8RA_1783693455 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-492488f8583so12265655e9.2 for ; Fri, 10 Jul 2026 07:24:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783693454; x=1784298254; 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=Gy5lAyrsruVVQe+ujUccoRGoLZIMDCI8r+vPhtBLh0Y=; b=DO2WY0VjEUw+d7sXQcMK3EfsLbJc212hu1wTzu8ex/di3pOEoXWBpux+rccmWQWKpR wnre8scf6ecv5UCnhsIG7C/sxFNAvBRTJFQ36biThrZNsN5FLSFSgVKeUzCqa1yWBuls sEaHZO2saJY/9BLqQ0WAVVtYE+NrliqIoJ1dvMUwWtt67tKTQmUcFQwdy2Y38azMtNg1 Vw56DZDPfoE4wZkl1U/xu6RD6pE2ZAJWX4RnagUV11LDKQke4q3VX3LDOnmElX7BhGLQ P+sJ6AA9PBc73t6TszDiuG//BYd+SsqT5RXpo82WLoBcyqEamspnug0uPpbLn9HywPb7 QtvQ== X-Gm-Message-State: AOJu0Yxo9yg2GjmtoRYmk3EEY5BW20SJkGZWStLIlq2neJLnWlJd9t94 WXiO1TvStphM2ZapupnzFlibnYYMpATFMlVnmZ3BWhUvduo/jqibhShd/a8dkXs3vcVdB9FHvWg A9U8OgPm1XJD8C4GrmEoRPjP5n+l3L6P4oKb7o1lZe/DPAVjg+0xw6BKFa54GikUiz2HtyXRxAQ qVxlFvP6OV0h9HzvMlIcdYO2qrl5t1MMJsQrwBcfs6ZQwOvDQ= X-Gm-Gg: AfdE7ckHpVzSKza3Ruz04vxR6N7y2LUrtm3ZaeaF7jRtFv+TZbVXZ3umW3PuPtKqe1n 9mnus4CjXEfXPGSzVUlmJ9yoKxb9mO7veF9lmAcoYM31MXqToSZxRAEGIoUZBlKQUzZuWFnw+F5 uWtWCuFvLg/SUl9xJF93wixvFTJ3+7cc1/tznVWJk8D25HnIccF2WsbtohF4Jsu4DT0LNgMExrW 1kZm4Lf651nHnJEcWeNXaO0R90KpHzBfE4MW0SvJpJ93xWUZWjLNIl2LO9Rj8OBf6jhPnmrDZJr TyyMGOFAZ+F7JxK1ynGydeW1hzpFh9mqAYTDCELDXMc/PbgVpiv8lwEXVosso05r1ufI6BQIvdv 89RcnMCc= X-Received: by 2002:a05:600c:8284:b0:493:e504:cbef with SMTP id 5b1f17b1804b1-493e68508f0mr121751985e9.0.1783693454362; Fri, 10 Jul 2026 07:24:14 -0700 (PDT) X-Received: by 2002:a05:600c:8284:b0:493:e504:cbef with SMTP id 5b1f17b1804b1-493e68508f0mr121751505e9.0.1783693453732; Fri, 10 Jul 2026 07:24:13 -0700 (PDT) Received: from localhost ([31.111.209.233]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493eb6f3b85sm231678805e9.2.2026.07.10.07.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 07:24:12 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , Pedro Alves Subject: [PATCHv6 1/4] gdb: rename program_space::entry_point_address* functions Date: Fri, 10 Jul 2026 15:24:06 +0100 Message-Id: <2fcb2cc5bcb92c8bb96b9e7dfd6b830bb5c32379.1783693321.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: vluodttS58vmwsbeVnOrHu-JRpH8mwok9vsaRc7jQ8c_1783693455 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 e959788bd3b..88047731ce6 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 cefdde5ed1e..9881dd54a1f 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2695,7 +2695,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; @@ -2771,7 +2771,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 e6b24ff5310..6d26841ede3 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -1300,7 +1300,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 a7381677498..d03e4768792 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2952,7 +2952,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 1407b058dfd..0e8516f4640 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -263,7 +263,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) @@ -276,9 +276,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 e9261ff8590..1ae1e42f3bb 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -323,13 +323,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 4f0aac31e73..69b882e534a 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