[Lldb-commits] [PATCH] D132624: [LLDB] Devirtualize coroutine promise types for `std::coroutine_handle`

Adrian Vogelsgesang via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 25 09:01:10 PDT 2022


avogelsgesang added a comment.

> leads me to believe that the data formatter is creating the synthetic children as non pointer objects (e.g. by automatically dereferencing any nested pointers), even though the structures clearly contain some pointers inside

Yes, that is correct. The formatter (introduced recently in https://reviews.llvm.org/D132415) does dereference the pointer internally. It replaces the

  (std::coroutine_handle<>) hdl = {
    __handle_ = 0x55555555b2a0
  }

by

  (std::coroutine_handle<>) hdl = {
      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)
  }

by dereferencing the pointer and directly exposing its children.

I could not find a good way to not dereference the pointer internally. Maybe you can help me find a better way?

I tried to just adjust the pointer type of the `__handle_` member, but then I got multiple problems:

1. Unnecessary clutter:

  (std::coroutine_handle<>) hdl = {
      __handle_ = {
          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)
      }
  }

The additional `__handle_` in it is just visual clutter.

Not expanded by default:

By default, if I write `p hdl`, LLDB did not expand its children and just displayed

  (std::coroutine_handle<>) hdl = {
    __handle_ = 0x55555555b2a0
  }

without an indication that there was more to see inside the pointer.

Also, when I write `p hdl.__handle_`, LLDB did not expand the pointer. Because now the `hdl.__handle_` access is done with C++ semantics, returning a `void*` and hence the data formatter for `std::exception_handle` did not kick in


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132624/new/

https://reviews.llvm.org/D132624



More information about the lldb-commits mailing list