Hi Kyle,

Apologies for the delay, this fell off my radar! The reality is a bit more 
complicated to what was described in a previous email in this thread.

> 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.

There are two things to keep in mind here:
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.
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.

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.

You can find the mechanics of this by looking for 
`Process::FindDetachedPlanExplainingStop`: 
https://github.com/swiftlang/llvm-project/blob/stable/20240723/lldb/source/Target/Process.cpp#L1380




> On Oct 9, 2024, at 07:40, Kyle Huey via Dwarf-discuss 
> <dwarf-discuss@lists.dwarfstd.org> wrote:
> 
> Hi Felipe,
> 
> Any chance you could point me in the right direction?
> 
> - Kyle
> 
> On Tue, Oct 1, 2024 at 9:41 AM Adrian Prantl <apra...@apple.com> wrote:
>> 
>> CC'ing Felipe, who is currently reworking a lot of this code and is much 
>> deeper in the subject matter than me.
>> 
>> -- adrian
>> 
>>> On Oct 1, 2024, at 8:42 AM, Kyle Huey <kh...@pernos.co> wrote:
>>> 
>>> On Wed, Feb 28, 2024 at 10:02 AM Adrian Prantl <apra...@apple.com> wrote:
>>>> 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.
>>> 
>>> Out of curiosity where does this code actually live?
>>> 
>>> - Kyle
>> 
> -- 
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to