microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.45k stars 1.53k forks source link

How can I attach to a remote debug server without a PID or program name? #3382

Open NSExceptional opened 5 years ago

NSExceptional commented 5 years ago

For example, debugging something on an iOS device from a laptop. When debugging an iOS process remotely with lldb, a debugserver instance runs on the remote host. debugserver is given a program to launch or a process to attach to, so the local lldb instance doesn't need any of this information. I've looked at Pipe Transport and it requires a PID. I see there is a command:pickRemoteProcess option, but where do I supply a way to start the remote server? Perhaps something with setupCommands?

Under the hood, Xcode communicates with the device and launches an instance of debugserver, supplying a port. If you're not familiar, the workflow by hand is something like this. On the remote host:

$ debugserver --attach=$pidOrProcessName *:12345
  Waiting for connection from *:12345...

On the local host:

$ lldb
(lldb) platform select remote-ios
(lldb) platform connect connect://$deviceIP:12345
<debugging starts>

Is this a supported configuration?

EthanArbuckle commented 5 years ago

+1. I have experienced the same issue trying to remotely debug iOS executables (on jailbroken iOS).

If anyone has successfully achieved this, please share details of how you did it

pieandcakes commented 5 years ago

Honestly this is not a scenario I've tried so if someone in the community can attempt it and post, that would be great.

The command:pickRemoteProcess option fires before any of the launch.json is parsed so you wouldn't be able to start the debugServer through the setupCommands.

NSExceptional commented 5 years ago

Hmmm. That tells me it's just not something VS Code supports right now, since you have to pick a process—in this scenario, the process is already chosen for you.

mrx23dot commented 2 months ago

Why not just connect over IP to a gdb server, that's how STM32s are debugged.