[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Thu May 15 21:49:55 PDT 2025


ashgti wrote:

> Summarizing the problem to make sure I understand: with the new launch/attach flow, we set the breakpoints in the dummy target before the actual target is created. If the target is created through launch commands, we're calling SetTarget with the currently selected target after we're done running the launch commands. By that time, we may have already missed events belong to the new target.
> 
> With this PR, we mimic what the default event handler does, which is listen to all target events. I think the problem with this approach is that now we're going to be broadcasting events for targets that are not the focus of the current debug session (i.e. the selected target). It should be easy to verify this by running a script that creates a second target and seeing if we now broadcast the events. If my theory is correct, then we would have to filter events not belonging to the selected target.

I had thought about also including a check on the target to see if it was the `DAP.target`, but again during launch or attach commands we may not know which target we need to focus on yet.

> Interestingly, I was thinking about multi-target/multi-process support in DAP earlier this week. I had someone reach out to ask questions about this. I'll file an issue to track this, but we should keep that use case in mind as we design this.

We do support the `startDebugging` reverse request https://microsoft.github.io/debug-adapter-protocol/specification#Reverse_Requests_StartDebugging. I use this to attach to multiple processes when tests are running from some scripts that involve multiple processes. I use the script hook we have https://github.com/llvm/llvm-project/blob/680b3b742da02972bc0b5298b6f472d2b95ca90a/lldb/tools/lldb-dap/DAP.h#L135 to call this from a python script. With the lldb-dap server mode we can handle multiple DAP sessions from the same binary, or you can have lldb-dap launch one instance per debug session. The DAP doesn't really have a way to have multiple processes per debug session, but it does allow for multiple debug sessions in general. Compound launch configurations are one way to get this setup https://code.visualstudio.com/docs/debugtest/debugging-configuration#_compound-launch-configurations for example, you could have a server and a client in a compound launch configuration. 

https://github.com/llvm/llvm-project/pull/140142


More information about the lldb-commits mailing list