Added extended-remote support#1260
Conversation
I tried a scenario where only Also checked the log, MIEngine sends |
|
@xisui-MSFT it sounds like you did some testing against this already, which gdbserver scenarios did you test exactly? A few questions:
|
chuckries
left a comment
There was a problem hiding this comment.
This needs more testing:
- Applicable Android and iOS scenarios.
- lldbserver (@WardenGnaw do we have any known lldbserver scnearios?)
- lldb in general as I'm not sure if we know if lldb-mi supports -target-select extended-remote
- gdbserver when it is launched with --attach
| } | ||
|
|
||
| string targetCommand = string.Format(CultureInfo.InvariantCulture, "-target-select remote localhost:{0}", _remotePorts.IDeviceDebugServerProxyPort.ToString(CultureInfo.InvariantCulture)); | ||
| string targetCommand = string.Format(CultureInfo.InvariantCulture, "-target-select extended-remote localhost:{0}", _remotePorts.IDeviceDebugServerProxyPort.ToString(CultureInfo.InvariantCulture)); |
There was a problem hiding this comment.
IIRC, iOS would use some form of lldbserver on the device. We have no idea if that supports extended-remote or not. We would need to test it against iOS scenarios, and those haven't been run in some time.
| if (!string.IsNullOrWhiteSpace(destination)) | ||
| { | ||
| commands.Add(new LaunchCommand("-target-select remote " + destination, string.Format(CultureInfo.CurrentCulture, ResourceStrings.ConnectingMessage, destination))); | ||
| commands.Add(new LaunchCommand("-target-select extended-remote " + destination, string.Format(CultureInfo.CurrentCulture, ResourceStrings.ConnectingMessage, destination))); |
There was a problem hiding this comment.
I believe this would get used in android scenarios. We would need to test the android scenarios that we still support in order to ensure those versions of gdbserver support extended-remote.
| } | ||
| else // gdbserver is already attached when using LocalLaunchOptions | ||
|
|
||
| string processId = localLaunchOptions?.ProcessId.Value.ToString(CultureInfo.InvariantCulture); |
There was a problem hiding this comment.
dropping the else here seems problemeatic.
Just because gdb is connected to the remote with extended-remote doesn't mean the server is not already attached. i.e. the current code always expects gdbserver to be launched with --attach for an attach and then connect to it with -target-select remote. extended-remote can still be used in conjuction with gdbserver --attach. Therefore it is not correct to blindly issue an attach command just because we connected with extended-remote, we would need to know exactly how gdbserver was launched.
There was a problem hiding this comment.
Tried this, but not sure how valid is this scenario.
For attach mode, a processId must be specified (so there isn't a case where midebuggerserveraddress is specified but processID isn't). And if gdbserver is lauched with --attach option, while both processId and midebuggerserveraddress are specified, attach will fail with message failed to attach to process ....
Therefore, launch mode should always be used for this case. And launch mode isn't compatible with processId.
So what do you think?
| if (!string.IsNullOrWhiteSpace(destination)) | ||
| { | ||
| commands.Add(new LaunchCommand("-target-select remote " + destination, string.Format(CultureInfo.CurrentCulture, ResourceStrings.ConnectingMessage, destination))); | ||
| commands.Add(new LaunchCommand("-target-select extended-remote " + destination, string.Format(CultureInfo.CurrentCulture, ResourceStrings.ConnectingMessage, destination))); |
There was a problem hiding this comment.
same as previous, not sure if its safe to do this at all times.
I only tested with some basic gdb cases. Trying to answer your questions:
|
|
@xisui-MSFT MI is GDB's "Machine Interface" (this is where the MI in MIEngine comes from). For most versions of gdb, we invoke it with --interpreter=mi and we are in MI mode instead of the standard GDB CLI. For LLDB, the interpreter flag is not available and typically MI is only available through another executable called |
|
Because lldb-mi is under Apache License v2.0, we can look at the source which shows it does not support From the source We would need to not change it to |
|
@WardenGnaw are there any supported scenarios where we are not picking up the lldb-mi that we ship ourselves? one thing to check would be if
|
|
According to this the start of the documentation that was linked to (https://sourceware.org/gdb/onlinedocs/gdb/Connecting.html):
It sounds like we need a new option to indicate if |
|
I guess the other option is: only use |
|
Looks like most discuss are around how compatible are remote and extended-remote, and lldb. While I didn't find a case where remote and extended-remote are incompatible, I agree that we should provide the option to use remote or extended remote. So I'll change this PR to add a |
|
@WardenGnaw @chuckries @gregg-miskelly I've added an option "useExtendedRemote" to control when to use extended-remote mode, and modified the title and description of this PR. Can someone please re-review? Thanks! |

As discussed in microsoft/vscode-cpptools#8497, this PR introduces a way to attach to a process after making remote connection.
A launch option field "useExtendedRemote" is added, which when being set to true, extended-remote mode will be used.
A known limitation is we can't guarantee the specified PID exists. We'll probably need to add a remote process picker in the future.