From 4323177f07e170a10b67d0cb194a254b00f587be Mon Sep 17 00:00:00 2001 From: Jonathan Emmett Date: Fri, 26 Mar 2021 09:59:01 -0400 Subject: [PATCH] Improve coroutine_handle visualization with intrinsics This improves the visualization of `std::coroutine_handle`. These are implemented by native visualization code and will require an updated Visual Studio to work. All take the frame pointer `_Ptr` as an argument. * `primary_function` returns the address of the user coroutine function. This is used in the display name of the coroutine_handle to indicate with which coroutine it is associated instead of the compiler-generated resume function. * `suspend_point` returns the suspend point index at which the coroutine is currently suspended. The natvis rules will display friendly names for the special suspend points for initial (1) and final (0, -1) suspend. * `suspend_point_line` returns the line number of the current suspend point. This requires additional debugging info in the .PDB which is not present in the initial compiler releases with standard coroutine support. The natvis rules will omit the line number if it's not available. --- stl/debugger/STL.natvis | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/stl/debugger/STL.natvis b/stl/debugger/STL.natvis index 008bb6ddb97..aed5ae4210d 100644 --- a/stl/debugger/STL.natvis +++ b/stl/debugger/STL.natvis @@ -1599,7 +1599,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - + *reinterpret_cast<$T1 *>(reinterpret_cast<char*>(_Ptr) + 2*sizeof(void*)) @@ -1607,8 +1607,20 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - {*reinterpret_cast<void(__cdecl**)(void*)>(_Ptr),na} - {*(reinterpret_cast<void(__cdecl**)(void*)>(_Ptr) + 1),na} + + + + + + + + + + empty + {primary_function(_Ptr),na} #final suspend + {primary_function(_Ptr),na} #initial suspend + {primary_function(_Ptr),na} #suspend point {suspend_point(_Ptr)} + {primary_function(_Ptr),na} #suspend point {suspend_point(_Ptr)}, line {suspend_point_line(_Ptr)} this,view(ViewPromise)