From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id ABCF8385841D for ; Wed, 1 Sep 2021 10:51:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ABCF8385841D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 89937 invoked from network); 1 Sep 2021 10:51:17 -0000 X-APM-Out-ID: 16304934768993 X-APM-Authkey: 257869/1(257869/1) 2 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 1 Sep 2021 10:51:17 -0000 From: Iain Sandoe Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [PATCH 0/8] coroutines: Use DECL_VALUE_EXPRs to assist in debug [PR99215] Message-Id: <4C7B8763-1292-450A-96FE-A56B66926540@sandoe.co.uk> Date: Wed, 1 Sep 2021 11:51:16 +0100 To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2021 10:51:29 -0000 Hi, As discussed with Jason at WG21 in Prague - last year, this amends the way in which the coroutine frame copies of variables are represented in the front end lowering. Instead of an explicit pointer->field we now apply a DECL_VALUE_EXPR to each instead (where that value is the pointer->field). Although this was initially targeted at improving the debug experience in fact it simplifies and shortens the code, and makes subsequent bug- fixes easier to implement. Therefore, I'm posting this series first. In addition to the change applied to local variables: - there is an implementation of a mechanism to make the original function arguments debug-visible. These are actually copied into the frame by the ramp function, so we create proxy vars for them and attach a DECL_VALUE_EXPR for the frame copy. - It is likely that someone debugging a coroutine will want to inspect parts of the implementation state (especially items such as the suspend index and the promise object). Although these are not a direct part of the user's source code, we expose them as synthetic variables in the implementation name-space _Coro_xxxxxx. Patches to follow: coroutines: Use DECL_VALUE_EXPR instead of rewriting vars. coroutines: Add a helper for creating local vars. coroutines: Support for debugging implementation state. coroutines: Make some of the artificial names more debugger-friendly. coroutines: Define and populate accessors for debug state. coroutines: Convert implementation variables to debug-friendly form. coroutines: Make proxy vars for the function arg copies. coroutines: Make the continue handle visible to debug. gcc/cp/coroutines.cc | 701 +++++++++++++++++++------------------------ 1 file changed, 304 insertions(+), 397 deletions(-) This has been tested quite a bit over some months on x86_64-darwin and on x86_64, powerpc64-linux, OK for master? backports? thanks, Iain *** I've tested with GDB and LLDB that we now have visibility of the coro state, local variables and function parameters. However the debug experience is still a little "jumpy" in respect of stepping through the code - this is because synthesized expressions default to using 'input_location' as their location - which is typically pointing to the closing brace of the function. So I think there is more that can be done for PR99215, but it's a different kind of problem from the one being solved with the DECL_VALUE_EXPRs.