<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div dir="auto" style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div dir="auto" style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hi Kyle,<div><br></div><div>Apologies for the delay, this fell off my radar! <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">The reality is a bit more complicated to what was described in a previous email in this thread.</span></div><div><br></div><div>> 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.</div><div><br></div><div>There are two things to keep in mind here:</div>A) When performing some kind of stepping operation, LLDB uses the notion of ThreadPlans to guide the stepping procedure. Each thread has a ThreadPlanStack, containing all the plans to guide the debugger on when to stop a thread. As the name implies, the ThreadPlanStack is a property of each Thread.<div>B) In Swift, each await operation may cause the currently executing Task to suspend and yield the Thread to a different Task. The previous Task may later be resumed on a different Thread entirely.</div><div><div><br></div><div>Taking these two together, LLDB has to move ThreadPlanStacks from one Thread to another in sync to how a Task is moved from one Thread to another.</div><div><br></div><div>You can find the mechanics of this by looking for `Process::FindDetachedPlanExplainingStop`: <a href="https://github.com/swiftlang/llvm-project/blob/stable/20240723/lldb/source/Target/Process.cpp#L1380">https://github.com/swiftlang/llvm-project/blob/stable/20240723/lldb/source/Target/Process.cpp#L1380</a></div><div><br></div><div><br></div><div><br></div><div><br><blockquote type="cite"><div>On Oct 9, 2024, at 07:40, Kyle Huey via Dwarf-discuss <dwarf-discuss@lists.dwarfstd.org> wrote:</div><br class="Apple-interchange-newline"><div><div>Hi Felipe,<br><br>Any chance you could point me in the right direction?<br><br>- Kyle<br><br>On Tue, Oct 1, 2024 at 9:41 AM Adrian Prantl <aprantl@apple.com> wrote:<br><blockquote type="cite"><br>CC'ing Felipe, who is currently reworking a lot of this code and is much deeper in the subject matter than me.<br><br>-- adrian<br><br><blockquote type="cite">On Oct 1, 2024, at 8:42 AM, Kyle Huey <khuey@pernos.co> wrote:<br><br>On Wed, Feb 28, 2024 at 10:02 AM Adrian Prantl <aprantl@apple.com> wrote:<br><blockquote type="cite">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.<br></blockquote><br>Out of curiosity where does this code actually live?<br><br>- Kyle<br></blockquote><br></blockquote>-- <br>Dwarf-discuss mailing list<br>Dwarf-discuss@lists.dwarfstd.org<br>https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss<br></div></div></blockquote></div><br></div></div></div></body></html>