[llvm-bugs] [Bug 39651] New: Stepping for C++ coroutines is broken

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 13 14:13:42 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39651

            Bug ID: 39651
           Summary: Stepping for C++ coroutines is broken
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: llvm-bugs at lists.llvm.org, modocache at gmail.com

#include <experimental/coroutine>

using namespace std::experimental;

coroutine_handle<> g;

struct coro {
  struct promise_type {
    coro get_return_object() {
      g = coroutine_handle<promise_type>::from_promise(*this);
      return {};
    }
    suspend_never initial_suspend() { return {}; }
    suspend_never final_suspend() { return {}; }
    void return_void() {}
    void unhandled_exception() {}
  };
};

coro f() {
  int i = 0;
  ++i; // break here
  co_await suspend_always();
  ++i; // break here
  co_await suspend_always();
  int j = 0; // break here
  ++i; // break here
  ++j;
  co_await suspend_always();
  ++j; // break here
}

int main() {
  f();
  g.resume();
  g.resume();
  g.resume();
}


# Run inside lldb:

Process 59665 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x000000010000100d a.out`main at coro.cpp:35:5
   32   
   33   int main() {
   34     f();
-> 35     g.resume();
   36     g.resume();
   37     g.resume();
   38   }
(lldb) s
Process 59665 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x0000000100001019 a.out`main at coro.cpp:36:5
   33   int main() {
   34     f();
   35     g.resume();
-> 36     g.resume();
   37     g.resume();
   38   }

So `step` skips entirely the resumption thunk inside the coroutine.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181113/0758d439/attachment.html>


More information about the llvm-bugs mailing list