llvm-project/clang/docs/tools
Adrian Vogelsgesang 91389000ab [LLDB] Add data formatter for std::coroutine_handle
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 newly 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

Differential Revision: https://reviews.llvm.org/D132415
2022-08-24 14:40:53 -07:00
..
clang-formatted-files.txt [LLDB] Add data formatter for std::coroutine_handle 2022-08-24 14:40:53 -07:00
dump_ast_matchers.py [AST Matchers] Update dump_ast_matchers.py to query only class index page. 2021-10-08 17:45:10 +00:00
dump_format_help.py [clang-format] Add execute permission to dump_format_help.py 2022-04-09 07:58:33 -07:00
dump_format_style.py [clang-format] Handle deprecated options in dump_format_style.py 2022-06-12 23:35:48 -07:00
generate_formatted_state.py [clang-format][NFC] improve the visual of the "clang-formatted %" 2021-10-09 19:37:03 +01:00
plurals.txt [clang-format][docs] Fix documentation of clang-format BasedOnStyle type 2021-09-24 08:15:55 +01:00