[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 7 10:11:02 PST 2025


clayborg wrote:

> > Is there a way we can use the LLDB platform layer to pick processes?
> 
> See discussion further up in the thread ([first comment](https://github.com/llvm/llvm-project/pull/128943#issuecomment-2686308012) and follow-up messages). It seems the [final blocker](https://github.com/llvm/llvm-project/pull/128943#issuecomment-2686357602) was that we didn't have access to the `debugAdapterExecutable` variable - which turned out to be wrong, we do actually have access to that variable, also see [this comment](https://github.com/llvm/llvm-project/pull/128943#discussion_r1976269198).
> 
> That being said, I am not sure if it's worth using the lldb layer for that...
> 
> > This code, IIUC is just running a local command to pick the process from the current host. But people might be debugging remotely by connecting to a remote platform.
> 
> When you SSH-connect into a remote host, the complete `lldb-dap` VS-Code extension is actually installed in the remote host, not on your local machine. As such, the call to `ps` actually happens on the remote host, and lists the process from the remote host. So at least from that point of view, I think we are fine.
> 
> However, if the user does connect remotely from lldb via gdbserver to some other host, then we would indeed be running the `ps` command on the wrong machine. Not sure if we even support this today, though...
> 
> Does
> 
> ```
> {
>   "name": "Local Debug Server",
>   "type": "lldb-dap",
>   "request": "attach",
>    "gdb-remote-hostname": "hostname",
>   "gdb-remote-port": 2345,
>   "pid": 1234
> }
> ```
> 
> currently even work? 

Yes it works. LLDB actually always uses GDB remote for all local debug sessions by spawning a lldb-server to debug the binary, so yes remote debugging is very well supported in lldb. 

> Also, does the gdb-remote protocol even offer capabilities for process-picking? (Not sure, I seldomly used gdb-remote functionality so far, except for connect to `rr` - for which I am impatiently awaiting first-class lldb-support 🙂 )

Our lldb-server can be run in two modes: debug or platform. When running in platform mode it does give us the connection we need to the remote server. So yes this can and does work. You can spawn a GDB remote platform on a remote linux machine with `lldb-server platform ...`, then you can `platform connection <host>:<port>` to connect with it. 

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


More information about the lldb-commits mailing list