[Dwarf-discuss] Coroutines

Adrian Prantl aprantl@apple.com
Wed Feb 28 18:02:23 GMT 2024



> On Feb 27, 2024, at 1:53 PM, Kyle Huey via Dwarf-discuss <dwarf-discuss@lists.dwarfstd.org> wrote:
> 
> Put another way (forgive my pseudo code), if you have
> 
> function silly_print() {
>     delay = rand();
>     // Point 1
>     async_sleep(delay).await;
>     // Point 2
>     printf("Hello" );
> }
> 
> function do_stuff() {
>     runtime.async_dispatch(silly_print());
>     runtime.async_dispatch(silly_print());
> }
> 
> When stepping from point 1 to point 2, the breakpoint on the post-await funclet at point 2 has to be conditional on being on the async_context being the same async_context the debugger was using at point 1, right? And then you have to be able to determine what the "same async_context" is.


LLDB implements this in a custom stepping plan that creates a conditional breakpoint where two async contexts are compared: First, there's the active async context at the time of the step. Next, the active async context at the time the breakpoint is hit. If the two async contexts are equal, then the breakpoint is discarded and the step has completed.

-- adrian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20240228/6ffd30d4/attachment.htm>


More information about the Dwarf-discuss mailing list