From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cXMOCWQe42pbuAYAWB0awg (envelope-from ) for ; Thu, 29 Oct 2026 06:22:28 -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=ULlSNrpv; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 1E6BC378003; Thu, 29 Oct 2026 06:22:28 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,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 03A57378002 for ; Thu, 29 Oct 2026 06:22:27 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7F4C4BA23DA for ; Thu, 29 Oct 2026 10:22:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7F4C4BA23DA 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=ULlSNrpv 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 2708D4BA23F8 for ; Thu, 29 Oct 2026 10:21:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2708D4BA23F8 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 2708D4BA23F8 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=1793269272; cv=none; b=CWnoxTXRzTWkXXP3X/JmlKHV6CFqmwV7z0UAg9o9aTrPuOrL8KjChQCoFH2e0bXBolp4yKzREzQHn6vAcJW/nojjyI4wsc9fq9zMblnDH2dELbTHCY5BRl/J8t9l1pmVZ7oZiU08sCICedUT6sD4jvlGxGQUCAkOc0pm+JQ5MHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793269272; c=relaxed/simple; bh=6dEJvxQ0z/3iyg2+OiFbAYMRK/IkezqChsD3DjIbkQY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=FapR3Za8CBB71vWZURohR/dfoUVYJRHFaLs1+9hyKjeyMcfXqBAv2RDAaflu/I2OGThFbZWkixUC4+rQCgWQ55SavsRE5lg23aAfdGxvZLfsfWRvjDA7BLOMgAxcNzLsU94UO95ZMf465axo1r8TFFfrTcv1AQ/3zqd44tK0nfk= 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=ULlSNrpv DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2708D4BA23F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793269271; 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=733BkvUfc99YrjS4FVDb9KWc5fW6kr66oNg1N1mqVVA=; b=ULlSNrpvP32WdUWJSy2C/x8TpxzL0EmWxhw52Uf1KUUnYOFj8/qkQgyamTFltcU7HYm2Um Dd4FWSn3lQDrMmAGgKI09NVG3YQed1/S6RnXXG+6oatiE18Sdi7VHspt9TuZE/hQcoAl/g 8WTGIHYZoc/NgiU9tGyJ1u2rFyu9lrY= 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-654-wunUnuI2OcSbDxbUJ-OacQ-1; Thu, 29 Oct 2026 06:21:09 -0400 X-MC-Unique: wunUnuI2OcSbDxbUJ-OacQ-1 X-Mimecast-MFC-AGG-ID: wunUnuI2OcSbDxbUJ-OacQ_1793269268 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a027f2e364so14628125e9.3 for ; Thu, 29 Oct 2026 03:21:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793269268; x=1793874068; 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=733BkvUfc99YrjS4FVDb9KWc5fW6kr66oNg1N1mqVVA=; b=I+kMlmQmfY7R0ksGzwk43vkz0qyMV8wZLakJMq1W3pHabaWULk7SV9UuKhXsWtJX/N GTLegtCuxz/HUjS/Id3xoy9bjt/Vx6g1h5j1wG3IhDb3CZA6UGqpHSdVmebC6BrWRWsE dE1/JT1Ew16BoqW2wfi7vuXcvxtYGP9louBW4fxTAACUy2IDnzjfTjhpR+jwW/S3o/8f +iwEzXPke4pPfZjCkVlYuDi6d1rCoUuKDzK4ZKFrXrajsiNq6x2If+xkxqQlA4h4POBY v81iSrUpPpHaetODTpawSSXOKEgAzk5nDwkV+Zlus80oVYx+rERBbNeZDqvH8tF9f8Vh x1CA== X-Gm-Message-State: AFq9FYJe5S07ngTukefcTlufTnT5FVq8aifiAbVYxUscUbW2HVpA70fT 2SfExwFerHBgrx1FVK4mzRgQ0zewQ9zvWpY0I70IQymqhlpdMmWax3PVMvCLUNMLH39zaq1qFUV svndWmMJo9Kg6IN3sXelcpTRkug5NyvSdKk4GDoGXZWmMeNcz2HMwhquKJjAr95vwwhVXahsSTO kwPu3y/wCHLPwL342G6sOczGCnKNpXne3TCL8zqiFs2NzXMeU= X-Gm-Gg: AYBFou2l8mYy6EVUhWSjtZaXeysvVafnHl0GMSWOL9KOVItGpP0W9NLyr49J1l62Rbn 4kmFZo/smQsGc6UMOGA6ESd58qb06mDTAbPempXyi1cJrXFN++JCbTf4rfswAflQ0bP9WwDgS+H RjJMcvs8tXoY7pO4k9uySXIFOAaTgIXajPjNTtxnxr38TtE0wvGh4IYawdoUcFD9LzKl9Tqy/c0 a+G9ML9I7idWEW+gzWHZke9WZYeSwsKnHBIW/oBHgvyXL8RBn+cEGsYMCUG5d4wcUg3I9NTS52Q JcFnQ77TP45ddYv5SK+WHtGRBL2NiRTDoUtHCuOpfD7mAFucyUWHuTph4LNys63I7WkdeQCA6Ek 3lOQ/HHagm9hrKBi1rA7L1PJA9xJE5aNFHl+hW9AWG0xLWVI= X-Received: by 2002:a05:600c:4f55:b0:4a2:1398:dd05 with SMTP id 5b1f17b1804b1-4a9661ab508mr113688335e9.16.1793269267817; Thu, 29 Oct 2026 03:21:07 -0700 (PDT) X-Received: by 2002:a05:600c:4f55:b0:4a2:1398:dd05 with SMTP id 5b1f17b1804b1-4a9661ab508mr113687705e9.16.1793269267216; Thu, 29 Oct 2026 03:21:07 -0700 (PDT) Received: from localhost ([2a00:23c6:e11d:fb01:6748:4fce:3e30:6e23]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a94f629d5fsm46641555e9.3.2026.10.29.03.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2026 03:21:06 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv10 5/5] gdb: cache program space entry point information Date: Thu, 29 Oct 2026 10:20:51 +0000 Message-Id: <2c9ddc321a22311a9848f5482a0f27881aa74e7f.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: JJ3x8lqfPAFYZlRqjHI-UWo9nPNaewID7PiV2tQLeSM_1793269268 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 After the previous two patches, there are now two places where we check if a frame is an entry point frame, these are in get_prev_frame and frame_unwind_caller_frame. Both of these locations call inside_entry_func, which then calls program_space::get_entry_point_info. The calls to program_space::get_entry_point_info are not crazy expensive, but they are not free either, there are reads from target memory to read the auxv vector and the entry address offset, so on remote targets this could introduce a small delay. However, the result from program_space::get_entry_point_info is not expected to change from one call to the next. This information should be a property of the executable and libraries, so we really only need to figure it out once. This commit caches the entry point information within program_space, clearing it whenever an inferior starts or exits, whenever the executable is updated, or whenever the inferior execs. After clearing GDB will compute, and cache the updated information the next time it is needed, which will be whenever GDB needs to unwind a frame. It will be possible to observe this change by, for example, monitoring the remote target packets, but as far as the normal GDB output is concerned, there should be no user visible changes after this commit. --- gdb/progspace.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- gdb/progspace.h | 11 ++++++++++- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/gdb/progspace.c b/gdb/progspace.c index 3347eb7dacc..b7282b6fd64 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -371,9 +371,12 @@ program_space::exec_entry_point_address () const /* See progspace.h. */ -entry_point_info +const entry_point_info & program_space::get_entry_point_info () const { + if (m_entry_point_info.has_value ()) + return m_entry_point_info.value (); + std::optional exec_entry_address = this->exec_entry_point_address_if_available (); @@ -389,8 +392,9 @@ program_space::get_entry_point_info () const break; } - return entry_point_info (std::move (inferior_entry_address), - std::move (exec_entry_address)); + m_entry_point_info.emplace (std::move (inferior_entry_address), + std::move (exec_entry_address)); + return m_entry_point_info.value (); } /* Implement the 'maint info entry-address' command. */ @@ -628,11 +632,46 @@ program_space::clear_solib_cache () deleted_solibs.clear (); } +/* Clear cached entry point information in the program space of INF. */ + +static void +clear_cached_entry_point_info_for_inferior (inferior *inf) +{ + inf->pspace->clear_cached_entry_point_info (); +} + +/* Clear cached entry point information in the program space PSPACE. */ + +static void +clear_cached_entry_point_info_for_pspace (program_space *pspace, + bool /* reload */) +{ + pspace->clear_cached_entry_point_info (); +} + +/* Clear cached entry point information in the program space of EXEC_INF. */ + +static void +clear_cached_entry_point_info_after_exec (inferior *exec_inf, + inferior */* follow_inf */) +{ + exec_inf->pspace->clear_cached_entry_point_info (); +} + /* See progspace.h. */ void initialize_progspace () { + gdb::observers::inferior_created.attach + (clear_cached_entry_point_info_for_inferior, "program-space"); + gdb::observers::inferior_exit.attach + (clear_cached_entry_point_info_for_inferior, "program-space"); + gdb::observers::executable_changed.attach + (clear_cached_entry_point_info_for_pspace, "program-space"); + gdb::observers::inferior_execd.attach + (clear_cached_entry_point_info_after_exec, "program-space"); + add_cmd ("program-spaces", class_maintenance, maintenance_info_program_spaces_command, _("Info about currently known program spaces."), diff --git a/gdb/progspace.h b/gdb/progspace.h index b9576bd8e64..efa7d333db0 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -395,7 +395,13 @@ struct program_space /* Return information about the entry point in the main executable, and the entry point for the inferior, which might be different from the main executable. */ - entry_point_info get_entry_point_info () const; + const entry_point_info &get_entry_point_info () const; + + /* Clear any cached entry point information. */ + void clear_cached_entry_point_info () + { + m_entry_point_info.reset (); + } /* If there is a valid and known entry point in the main executable of this program space, return it. Otherwise return an empty optional. */ @@ -488,6 +494,9 @@ struct program_space /* See `exec_filename`. */ gdb::unique_xmalloc_ptr m_exec_filename; + + /* Cached entry point information. See get_entry_point_info. */ + mutable std::optional m_entry_point_info; }; /* The list of all program spaces. There's always at least one. */ -- 2.25.4