From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7cZ+HrfES2qg6ikAWB0awg (envelope-from ) for ; Mon, 06 Jul 2026 11:07:35 -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=EAv1Vq/D; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 684761E024; Mon, 06 Jul 2026 11:07:35 -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 8D7081E024 for ; Mon, 06 Jul 2026 11:07:34 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9BA7E4BA2E08 for ; Mon, 6 Jul 2026 15:07:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BA7E4BA2E08 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=EAv1Vq/D 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 97BA94BA2E0E for ; Mon, 6 Jul 2026 15:07:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97BA94BA2E0E 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 97BA94BA2E0E 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=1783350420; cv=none; b=sIlNjfn9CfZerVlOm2dKKEBYASotTuovvOBnGRIBoGtQJ932oTbjukxyKBW7jUaYEOZ65H6xHLMm8M+mObRZe7C6ASbvVAp0QdVqa6AubMGa9l9oc7TF8HDpTzGS3p2MP0h3Er+ELZUVyEqo6Y/13e7Oby35JqmOxDPI57AsOm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783350420; c=relaxed/simple; bh=EgcJ/2uXUvjuDcQKZZ2BQWuMAnd7L7OPb2uqiqXoutg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=h+97nx/sanGYAyz7FXJkE09Ar+xuuU34Hi81MUwO304hNFqA0mb4I0rreWYxKyq6N2NqiVgMjVfqv5L3MKaSp9v0O0Q/5EYHMOYQGc31y/YfwwrnBShy0hiD8Remz6mHZmlEkzvGAbrU20JIzh6oxuOOZlmxFi037pvi057a19g= 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=EAv1Vq/D DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97BA94BA2E0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783350420; 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: in-reply-to:in-reply-to:references:references; bh=1NwXpAS5fWbibvK7sdOsIoz7ZADZYSg2yF1nnWVgPIU=; b=EAv1Vq/Dyhv5gTTQy73KT2aHPmmuRYGDsjZci9/RKexPlTi7MO1/3RMVIpSKygHVc+Rqh5 Gm9IYs6O1bqrC/F7QHyfrXnchOkI9jOAOyEFIkrmlbrX/pQ5bHKrP2gxt5y0MON2Vi+wjB uR+tvkJSR2Zh17lM6UI8EaJ8L4SiXHY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-97-32s5c0vMNwW1ERIukfXzPA-1; Mon, 06 Jul 2026 11:06:58 -0400 X-MC-Unique: 32s5c0vMNwW1ERIukfXzPA-1 X-Mimecast-MFC-AGG-ID: 32s5c0vMNwW1ERIukfXzPA_1783350417 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-493b54823bdso24448685e9.0 for ; Mon, 06 Jul 2026 08:06:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783350417; x=1783955217; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1NwXpAS5fWbibvK7sdOsIoz7ZADZYSg2yF1nnWVgPIU=; b=qpgBtJY/8ngPQUto0b4iPJtL5sUFpxd6J051I3Hk9vfWgYfyKkH6Eb7jO88mz4tvn9 FXhngI3SH7YcMpmdqMytxHChemCf8cVZTVsn+ZgBI9z6DoKYnsBC+dLJaopI87zUuGDr g3/bLOSTbjL2+zDnIgsmR48KMvnatGusiItm9M8XCWfxH0NMVb+si5HUcsXRREPzjzVm uXru0CTa7E8v4y7++VFM07SLfnsQWGETA+DPw30kXeiEytneDw8qNIKXLz+2TPYksHr6 mr3/L1PGNuBXD5ZoAXRQ9mUgvLdWQQ9RB4Ysvifv79tCyRySV2oDmkeMrx9XfdSi3ZcN 6/2A== X-Gm-Message-State: AOJu0Yxbf/ybBEmmApKOXXVGPdiE5GbvRKyzq+cSiY7gwcxzVDfKK28N R8xhZk1ocSfenVpQVg1vOfDLCAsQ043ywUvF4Nig+vcozt38NH2D1oexTOFNflXT9SV2ZF0TOGA KkX+1b0uxuzL/s4gSfCGqLjx7cf9II4Pl5A312utjMZpaeaIFq3iWdsTDKVk5V+i4gBSwB2Y= X-Gm-Gg: AfdE7clwUmkvX+pTYTlhthUGMukg75fVOn6d7PRyzYiJ/ue6PIYEe89GitCG8VXfA4S fZA7D+p0IQdPFUp+LQbAXQ1A01W9qOItVEwQEwAR5qRVRWEk98xAplchbkz/x6TQc0mPJyYnpe4 w6IYncWMYW56r0vtyTJbP3cgARefBuCalk+yrTZDy8l2Wct8Jxz/3V+eJjTtz8qdOm1biiFlLo5 8T5JiWKPSRRtp3KDOX3R5zP0erkfnazSbrYJRxUvQg4Ftuh5l757mCIOzn5ypc6zWrycn6QFpql Tw/a8VM27lpJxgy2P5AxLPWXQMnMp52OSMtpcpdOZej27h3RBWnueNdkQeOEJ7aapLBid9vMdIX B4yq3EV4= X-Received: by 2002:a05:600c:8b12:b0:493:b698:9247 with SMTP id 5b1f17b1804b1-493dececcd3mr11642845e9.14.1783350417112; Mon, 06 Jul 2026 08:06:57 -0700 (PDT) X-Received: by 2002:a05:600c:8b12:b0:493:b698:9247 with SMTP id 5b1f17b1804b1-493dececcd3mr11642285e9.14.1783350416445; Mon, 06 Jul 2026 08:06:56 -0700 (PDT) Received: from localhost ([31.111.209.233]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493ccd9d607sm365089695e9.2.2026.07.06.08.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:06:55 -0700 (PDT) From: Andrew Burgess To: "Rohr, Stephan" , Tom Tromey Cc: "gdb-patches@sourceware.org" Subject: RE: [PATCH 1/1] gdb: set the cache information in 'get_prev_frame_maybe_check_cycle' In-Reply-To: References: <20260625145850.3104079-1-stephan.rohr@intel.com> <20260625145850.3104079-2-stephan.rohr@intel.com> <87se69wdbt.fsf@tromey.com> Date: Mon, 06 Jul 2026 16:06:54 +0100 Message-ID: <87zf04tawh.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eUIao5XBpCmt2x5Vvo6XGKCEQalFvYpKA5DeJQzubnI_1783350417 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 "Rohr, Stephan" writes: > Hi Tom, > > thank you for your feedback! I will fix the typos in v2 of the patch. > > I'll try to explain the problem in more detail now: > > 1. If you run an inferior call after the up command invalidates > the selected frame. > 2. The selected frame is rebuild following the chain > > get_selected_frame () -> lookup_selected_frame () > -> get_prev_frame_always_1 () > -> get_prev_frame_maybe_check_cycle () > > 3. At this point, the frame_info_ptr is constructed before the > frame-id is computed. The cache Information is not updated as > 'compute_frame_id' only updates the frame id of the internal > 'frame_info' pointer. > > 4. If we now run the "frame" command in combination with a > pretty-printer, this invokes another infcall to evaluate the > pretty-printer. > > 5. This clears the 'm_ptr' member of the frame_info_ptr. Since the cache > id is not set, a subsequent reinflate fails. > > A very simple fix for this could be: > > @@ -2332,7 +2361,7 @@ get_prev_frame_maybe_check_cycle (const frame_info_ptr &this_frame) > throw; > } > > - return prev_frame; > + return frame_info_ptr (prev_frame.get ()); > } > > It constructs a new frame_info_ptr using the updated raw pointer > of 'prev_frame'. This is somewhat redundant as another frame_info_ptr > is added to the frame list in the frame_info_ptr ctor. > > The frame list entry from > > frame_info_ptr prev_frame = get_prev_frame_raw (this_frame); > > is removed again by the frame_info_ptr's dtor. > > This would add some overhead. > > I didn't find a better solution. We could modify 'get_prev_frame_raw' to > return a raw pointer instead (it is the only location where is this called at > all). But we'd need a temporary copy of the frame_info_ptr anyways, > either to pass a frame_info_ptr to 'compute_frame_id' or inside of > 'compute_frame_id' (to forward the frame id to > 'frame_unwind_find_by_frame'). Changing these functions to > accept a raw frame_info pointer is not desired in my point of view. > > I appreciate your feedback. > Hi Stephan, I ran into a similar problem myself recently, and had a different fix queued up, but it was part of a larger change. I've pulled it out and the patch is below, along with your test change. The test still passes. There's no commit message yet, I still need to think about exactly what's going on in this case a bit more, it's still not clear to me how (or where) the frame_info_ptr without the frame-id is actually created, as I thought frames (after 0) always got a frame-id before they were placed into a frame_info_ptr. I'm sharing this now just so you can take a look at the change and let me know what you think, I'll dig into this a little more and write up a commit message tomorrow, but I'd like to hear what you think of this approach. Thanks, Andrew --- diff --git a/gdb/frame.c b/gdb/frame.c index cefdde5ed1e..7a0f313f4db 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2190,15 +2190,15 @@ reinit_frame_cache (void) sentinel_frame = nullptr; } + for (frame_info_ptr &iter : frame_info_ptr::frame_list) + iter.invalidate (); + frame_stash_invalidate (); /* Since we can't really be sure what the first object allocated was. */ obstack_free (&frame_cache_obstack, 0); obstack_init (&frame_cache_obstack); - for (frame_info_ptr &iter : frame_info_ptr::frame_list) - iter.invalidate (); - frame_debug_printf ("generation=%d", frame_cache_generation); } @@ -3435,10 +3435,21 @@ frame_info_ptr::frame_info_ptr (struct frame_info *ptr) if (m_ptr == nullptr) return; - m_cached_level = ptr->level; + m_cached_level = m_ptr->level; +} + +void +frame_info_ptr::invalidate () +{ + if (m_ptr == nullptr) + return; + + gdb_assert (m_cached_level == m_ptr->level); if (m_cached_level != 0 || m_ptr->this_id.value.user_created_p) m_cached_id = m_ptr->this_id.value; + + m_ptr = nullptr; } /* See frame-info-ptr.h. */ diff --git a/gdb/frame.h b/gdb/frame.h index f6553fb7b6d..b386303d895 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -327,10 +327,7 @@ class frame_info_ptr : public intrusive_list_node } /* Invalidate this pointer. */ - void invalidate () - { - m_ptr = nullptr; - } + void invalidate (); private: /* We sometimes need to construct frame_info_ptr objects around the diff --git a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp index 52162fc9952..a2a29c4d0f8 100644 --- a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp +++ b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp @@ -108,6 +108,8 @@ with_test_prefix "frame movement down" { with_test_prefix "frame movement up" { if { [start_test "TAG: final frame"] == 0 } { gdb_test "up" [multi_line "#1 .*in g \\(mt=mytype is .*\\, depth=1\\).*" ".*first frame.*"] + gdb_test "p f ()" " = 2" + gdb_test "frame" [multi_line "#1 .*in g \\(mt=mytype is .*\\, depth=1\\).*" ".*first frame.*"] } }