From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4D4FE3842405 for ; Mon, 12 Dec 2022 13:17:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4D4FE3842405 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 2BCDHTsM009228 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Dec 2022 08:17:34 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 2BCDHTsM009228 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1670851054; bh=gQy8wwn8+803K1doR5eOQGIQKjDTpFuSb3921ejuY6I=; h=Date:Subject:To:References:From:In-Reply-To:From; b=D/RyVKJexdrG4ZiGZOQOab5hpjVdtchqErGwTqlQEdcLztvXjDgXDCthJV+O5dz3l 5iXuITPZgCufI1aTECv9KW/Sy2kRfm4YF/rfnQxfFGPku9NdOgK4zx0k82XUrkAK/i jUPQ8ES5BrJ8/g3TOcIqaKXBDHarS3+7qKLFq+cY= Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 86B801E0CB; Mon, 12 Dec 2022 08:17:29 -0500 (EST) Message-ID: Date: Mon, 12 Dec 2022 08:17:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH 3/6] gdb: make user-created frames reinflatable Content-Language: en-US To: Bruno Larsen , gdb-patches@sourceware.org References: <20221202180052.212745-1-simon.marchi@polymtl.ca> <20221202180052.212745-4-simon.marchi@polymtl.ca> From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 12 Dec 2022 13:17:29 +0000 X-Spam-Status: No, score=-3038.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >> diff --git a/gdb/frame-info.c b/gdb/frame-info.c >> index 40a872ea152d..d61fb7ed0e95 100644 >> --- a/gdb/frame-info.c >> +++ b/gdb/frame-info.c >> @@ -21,6 +21,9 @@ >> #include "frame-info.h" >> #include "frame.h" >> +#include "gdbsupport/selftest.h" >> +#include "scoped-mock-context.h" >> +#include "test-target.h" >> /* See frame-info-ptr.h. */ >> @@ -33,7 +36,8 @@ frame_info_ptr::prepare_reinflate () >> { >> m_cached_level = frame_relative_level (*this); >> - if (m_cached_level != 0) >> + if (m_cached_level != 0 >> + || (m_ptr != nullptr && frame_is_user_created (m_ptr))) >> m_cached_id = get_frame_id (*this); >> } >> @@ -54,7 +58,13 @@ frame_info_ptr::reinflate () >> /* Frame #0 needs special handling, see comment in select_frame. */ >> if (m_cached_level == 0) >> - m_ptr = get_current_frame ().get (); >> + { >> + if (!frame_id_p (m_cached_id)) > You seem to be using the stack being valid to check if the frame is stack -> frame id? > user created, but in the commit message you mention that you use null > frame id. Wouldn't it be more reliable to check if m_cached_id == > null_frame_id ? Comparing anything against null_frame_id (even a null frame id) yields false: if (stack_status == FID_STACK_INVALID || r.stack_status == FID_STACK_INVALID) /* Like a NaN, if either ID is invalid, the result is false. Note that a frame ID is invalid iff it is the null frame ID. */ eq = false; From: https://gitlab.com/gnutools/binutils-gdb/-/blob/a28fedbc3f582ce7c8bad2eb017b1dc072bb1da7/gdb/frame.c#L759-763 I don't really understand the point, I think it would be useful to be able to compare a frame id to null_frame_id, like we compare pointers to nullptr. But currently, the correct (and only?) way of checking if we have a frame id or not in a frame_id is frame_id_p. When the commit message says: for user-created frames, m_cached_id is a non-null frame id, whereas for the current target frame, m_cached_id is left null. I could say "is valid" and "is invalid" instead. Simon