This patch adds a formatter for std::coroutine_handle, both for libc++
and libstdc++. For the type-erased coroutine_handle<>, it shows the
resume and destroy function pointers. For a non-type-erased
coroutine_handle<promise_type> it also shows the promise value.
With this change, executing the v t command on the example from
https://clang.llvm.org/docs/DebuggingCoroutines.html now outputs
(task) t = { handle = coro frame = 0x55555555b2a0 { resume = 0x0000555555555a10 (a.out`coro_task(int, int) at llvm-example.cpp:36) destroy = 0x0000555555556090 (a.out`coro_task(int, int) at llvm-example.cpp:36) } }
instead of just
(task) t = { handle = { __handle_ = 0x55555555b2a0 } }
Note, how the symbols for the resume and destroy function pointer
reveal which coroutine is stored inside the std::coroutine_handle.
A follow-up commit will use this fact to infer the coroutine's promise
type and the representation of its internal coroutine state based on
the resume and destroy pointers.
The same formatter is used for both libc++ and libstdc++. It would
also work for MSVC's standard library, however it is not registered
for MSVC, given that lldb does not provide pretty printers for other
MSVC types, either.
The formatter is in a new added Coroutines.{h,cpp} file because there
does not seem to be an already existing place where we could share
formatters across libc++ and libstdc++. Also, I expect this code to grow
as we improve debugging experience for coroutines further.
Testing
- Added API test
I need to remove this. This is a left-over from an earlier implementation sketch