From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ySLqEbJCPWpE9RcAWB0awg (envelope-from ) for ; Thu, 25 Jun 2026 11:01:06 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=c8+yBRxN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 45C6C1E098; Thu, 25 Jun 2026 11:01:06 -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 BBEBF1E024 for ; Thu, 25 Jun 2026 11:01:05 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5CD114BA23DD for ; Thu, 25 Jun 2026 15:01:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CD114BA23DD Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=c8+yBRxN Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by sourceware.org (Postfix) with ESMTPS id CE74A4BA23E7 for ; Thu, 25 Jun 2026 14:59:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE74A4BA23E7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CE74A4BA23E7 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782399546; cv=none; b=YlRm7/NJ7Bvuzcx90aU64BczJ/Gnz5hD/c3m5J0sJuZWJRM8Fc+gyimmHO+cenTQIC6P2EslOjkYx8OYfoY9t+M5PxfigYcaJoSKyAAxNasxBZsSUP5UOgSbYVZgADwqJDIjIgWkMwwu/S/uKWyjUaHWAODtd6pll9A0cTJwtwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782399546; c=relaxed/simple; bh=6mJsXuh06iEhFI1Gspc3eZ6Qe4JBbkDUC2oYo/zXbE0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=l+vMK06fIAGQ7Sr//LOR2GhS08eDyTNFdxN/g8Gh+Fr2G4pL8Ys1pcPNRRMKZpUvWbiKHUn1KVjf0av3SJ+wVTIChvB5OH6GQ4cRxN/4o+f5tObj0GOaDgggYgEgI2IwS316PBP2CeRw291s8hIyhCBdt0qjY9r0k9sRyAbVtuQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=c8+yBRxN DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE74A4BA23E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1782399546; x=1813935546; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=6mJsXuh06iEhFI1Gspc3eZ6Qe4JBbkDUC2oYo/zXbE0=; b=c8+yBRxNmkAU/j7n/3DGKd3IrSdV09rJ4EzNx3ayUo0YCJrtfEeKV/6g rixJ70r2pqt2Qb3d4/8vHFzkLNWXojyo1NbuzTd7MXmF5oz8Pqx8jttbx violFgYfo4ap0J4lsAfilWbeg/gH5IxHEYShI4VoV5x+V9VprANgz+X5g ujnvrC6uWNV/22lyCom6r8AEML/SFvWyH6fk4z2nbvwWDp/lvYhc0yHx8 6NnoRpaicMxIB7nuB+FPcvqAmJLgZZaABoSwAihs8w6tKBwArqTMf0Kma MAySMG65WjXSKdWm0hyWXVYU1CAMf3arECIg3+Ug3SghBw3pvwL1npsti A==; X-CSE-ConnectionGUID: 5nQw+SRtRiO2Hr5EYfL0gw== X-CSE-MsgGUID: sNJjtqSYRzGpfXPdz7bW6w== X-IronPort-AV: E=McAfee;i="6800,10657,11827"; a="83367772" X-IronPort-AV: E=Sophos;i="6.24,224,1774335600"; d="scan'208";a="83367772" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2026 07:59:06 -0700 X-CSE-ConnectionGUID: 1H0SutT8Tpu0fSsgjWqlkA== X-CSE-MsgGUID: R2MmGb76SNi5C9Gxsd7Wug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,224,1774335600"; d="scan'208";a="250408642" Received: from dut1013pvc.igk.intel.com (HELO localhost) ([10.211.176.215]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2026 07:59:05 -0700 From: Stephan Rohr To: gdb-patches@sourceware.org Subject: [PATCH 1/1] gdb: set the cache information in 'get_prev_frame_maybe_check_cycle' Date: Thu, 25 Jun 2026 14:58:50 +0000 Message-ID: <20260625145850.3104079-2-stephan.rohr@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260625145850.3104079-1-stephan.rohr@intel.com> References: <20260625145850.3104079-1-stephan.rohr@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 From: "Rohr, Stephan" 'get_prev_frame_maybe_check_cycle' retrieves the previous frame and computes the frame id. At this point, the frame id is not cached yet, which prevents the frame from being reinflated once the frane cache is flushed. Explicitly update the cache information before returning 'prev_frame' so the frame can be reinflated properly. The 'up' command invokes the following sequence. 1. Build the 'prev_frame' and eventually calls 'get_prev_frame_maybe_check_cycle'. The frame_id is only computed for the raw frame pointer, the wrapping 'frame_info_ptr' it not updated. 2. Printing the frame calls 'do_print_frame_info'. 3. If a pretty-printer runs an inferior call, the frame cache is flushed. 4. This triggers the assertion when reinflating the frame_info_ptr. Extend the 'gdb.python/pretty-print-call-by-hand.exp' testcase to cover this use-case. --- gdb/frame.c | 18 +++++++++++++++++- gdb/frame.h | 4 ++++ .../gdb.python/pretty-print-call-by-hand.exp | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gdb/frame.c b/gdb/frame.c index 4137e1d5edd..1d4e231ea81 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2332,6 +2332,12 @@ get_prev_frame_maybe_check_cycle (const frame_info_ptr &this_frame) throw; } + /* No cycle and the frame is added to the frame stash, update the cache + information to ensure the frame can be reinflated after the cache is + flushed. */ + if (prev_frame) + prev_frame.update_cache (); + return prev_frame; } @@ -3431,7 +3437,17 @@ frame_info_ptr::frame_info_ptr (struct frame_info *ptr) if (m_ptr == nullptr) return; - m_cached_level = ptr->level; + update_cache (); +} + +/* See frame-info-ptr.h. */ + +void +frame_info_ptr::update_cache () +{ + gdb_assert (m_ptr != nullptr); + + 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; diff --git a/gdb/frame.h b/gdb/frame.h index f6553fb7b6d..897518371b2 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -332,6 +332,10 @@ class frame_info_ptr : public intrusive_list_node m_ptr = nullptr; } + /* Update the cached copies of frame_id and the frame level based on the + underlying pointer. */ + void update_cache (); + private: /* We sometimes need to construct frame_info_ptr objects around the sentinel_frame, which has level -1. Therefore, make the invalid frame 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.*"] } } -- 2.43.0 Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928