Skip to content

Commit

Permalink
add support for applying post remote connect commands on attach
Browse files Browse the repository at this point in the history
  • Loading branch information
swermin authored and Ermin Hrkalovic committed Feb 29, 2024
1 parent 0af7c17 commit 10ff42f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/MICore/LaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,8 +1490,12 @@ internal static SupplementalLaunchOptions GetOptionsFromFile(Logger logger)
string optFile = Path.Combine(slnRoot, "Microsoft.MIEngine.Options.xml");
if (File.Exists(optFile))
{
var reader = File.OpenText(optFile);
string suppOptions = reader.ReadToEnd();
string suppOptions = null;
using (var reader = File.OpenText(optFile))
{
suppOptions = reader.ReadToEnd();
}

if (!string.IsNullOrEmpty(suppOptions))
{
try
Expand Down Expand Up @@ -1555,6 +1559,11 @@ private void Merge(AttachOptionsForConnection suppOptions)
setupCmds.AddRange(newSetupCmds);
SetupCommands = new ReadOnlyCollection<LaunchCommand>(setupCmds);

var postRemoteConnectCmds = this.PostRemoteConnectCommands.ToList();
var newPostRemoteConnectCmds = LaunchCommand.CreateCollection(suppOptions.PostRemoteConnectCommands);
postRemoteConnectCmds.AddRange(newPostRemoteConnectCmds);
PostRemoteConnectCommands = new ReadOnlyCollection<LaunchCommand>(postRemoteConnectCmds);

MergeMap(suppOptions.SourceMap);
if (!string.IsNullOrWhiteSpace(suppOptions.AdditionalSOLibSearchPath))
{
Expand Down Expand Up @@ -1847,6 +1856,7 @@ protected void InitializeCommonOptions(Xml.LaunchOptions.BaseLaunchOptions sourc
this.WaitDynamicLibLoad = source.WaitDynamicLibLoad;

this.SetupCommands = LaunchCommand.CreateCollection(source.SetupCommands);
this.PostRemoteConnectCommands = LaunchCommand.CreateCollection(source.PostRemoteConnectCommands);

if (source.CustomLaunchSetupCommands != null)
{
Expand Down
10 changes: 10 additions & 0 deletions src/MICore/LaunchOptions.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@
<xs:documentation>One or more GDB/LLDB commands to execute in order to setup the underlying debugger. These are not required.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="PostRemoteConnectCommands" minOccurs="0" maxOccurs="1" type="CommandList">
<xs:annotation>
<xs:documentation>One or more commands to execute after the connection has been made, in order to set up the remote connection. These are not required.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="SourceMap" type="SourceMapList" minOccurs="0" maxOccurs="1">
</xs:element>
<xs:element name="ServerOptions" type="ServerOptions" minOccurs="0" maxOccurs="1">
Expand Down Expand Up @@ -482,6 +487,11 @@
<xs:documentation>One or more GDB/LLDB commands to execute in order to setup the underlying debugger. These are not required.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="PostRemoteConnectCommands" minOccurs="0" maxOccurs="1" type="CommandList">
<xs:annotation>
<xs:documentation>One or more commands to execute after the connection has been made, in order to set up the remote connection. These are not required.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CustomLaunchSetupCommands" minOccurs="0" maxOccurs="1" type="CommandList">
<xs:annotation>
<xs:documentation>
Expand Down
12 changes: 10 additions & 2 deletions src/MICore/LaunchOptions.xsd.types.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10ff42f

Please sign in to comment.