Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use our MIEngine instead of relying on one being installed #163

Merged
merged 1 commit into from
Jul 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "MIEngine"]
path = MIEngine
url = https://github.com/PistonDevelopers/MIEngine.git
branch = master
1 change: 1 addition & 0 deletions MIEngine
Submodule MIEngine added at 126314
25 changes: 3 additions & 22 deletions VisualRust.Project/DefaultRustLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Text;
using System.Xml;
using Microsoft.MIDebugEngine;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudioTools;
Expand Down Expand Up @@ -60,10 +61,7 @@ public int LaunchFile(string file, bool debug)
{
if (debug)
{
if (_projectConfig.DebugType == Constants.BuiltinDebugger)
LaunchInBuiltinDebugger(file);
else
LaunchInGdbDebugger(file);
LaunchInGdbDebugger(file);
}
else
{
Expand All @@ -75,29 +73,12 @@ public int LaunchFile(string file, bool debug)

}

private void LaunchInBuiltinDebugger(string file)
{
VsDebugTargetInfo4[] targets = new VsDebugTargetInfo4[1];
targets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
targets[0].guidLaunchDebugEngine = Constants.NativeOnlyEngine;
targets[0].bstrExe = file;
if (!string.IsNullOrEmpty(_debugConfig.CommandLineArgs))
targets[0].bstrArg = _debugConfig.CommandLineArgs;
if (!string.IsNullOrEmpty(_debugConfig.WorkingDir))
targets[0].bstrCurDir = _debugConfig.WorkingDir;

VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[targets.Length];

IVsDebugger4 vsDebugger = (IVsDebugger4)_project.GetService(typeof(SVsShellDebugger));
vsDebugger.LaunchDebugTargets4((uint)targets.Length, targets, results);
}

private void LaunchInGdbDebugger(string file)
{
VsDebugTargetInfo4[] targets = new VsDebugTargetInfo4[1];
targets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
targets[0].bstrExe = file;
targets[0].guidLaunchDebugEngine = Constants.GdbEngine;
targets[0].guidLaunchDebugEngine = new Guid(EngineConstants.EngineId);

string gdbPath = GetDebuggingProperty<string>("DebuggerLocation");
if (string.IsNullOrWhiteSpace(gdbPath))
Expand Down
6 changes: 6 additions & 0 deletions VisualRust.Project/VisualRust.Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.Build" />
<Reference Include="Microsoft.VisualStudio.Debugger.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Debugger.InteropA, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
Expand Down Expand Up @@ -162,6 +164,10 @@
<Project>{cacb60a9-1e76-4f92-8831-b134a658c695}</Project>
<Name>Microsoft.VisualStudio.Project</Name>
</ProjectReference>
<ProjectReference Include="..\MIEngine\src\MIDebugEngine\MIDebugEngine.csproj">
<Project>{6D2688FE-6FD8-44A8-B96A-6037457F72A7}</Project>
<Name>MIDebugEngine</Name>
</ProjectReference>
<ProjectReference Include="..\VisualRust.Build\VisualRust.Build.csproj">
<Project>{9cf556ab-76fe-4c3d-ad0a-b64b3b9989b4}</Project>
<Name>VisualRust.Build</Name>
Expand Down
160 changes: 160 additions & 0 deletions VisualRust.sln

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions VisualRust/ProvideDebugEngineAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Microsoft.VisualStudio.Shell;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisualRust
{
class ProvideDebugEngineAttribute : RegistrationAttribute
{
readonly string name;
readonly Type provider;
readonly Type engine;
readonly string id;

public ProvideDebugEngineAttribute(string name, Type programProvider, Type debugEngine, string id)
{
this.name = name;
this.id = id;
this.provider = programProvider;
this.engine = debugEngine;
}

public override void Register(RegistrationContext context)
{
var engineKey = context.CreateKey("AD7Metrics\\Engine\\" + id);
engineKey.SetValue("Name", name);
engineKey.SetValue("CLSID", engine.GUID.ToString("B"));
engineKey.SetValue("ProgramProvider", provider.GUID.ToString("B"));
engineKey.SetValue("PortSupplier", "{708C1ECA-FF48-11D2-904F-00C04FA302A1}");

engineKey.SetValue("Attach", 1);
engineKey.SetValue("AlwaysLoadLocal", 1);
engineKey.SetValue("AlwaysLoadProgramProviderLocal", 1);
engineKey.SetValue("Disassembly", 1);
engineKey.SetValue("EnginePriority", 0x51);
engineKey.SetValue("SetNextStatement", 1);

var debuggerRegKey = context.CreateKey("CLSID\\" + engine.GUID.ToString("B"));
debuggerRegKey.SetValue("Assembly", engine.Assembly.GetName().Name);
debuggerRegKey.SetValue("Class", engine.FullName);
debuggerRegKey.SetValue("InprocServer32", context.InprocServerPath);
debuggerRegKey.SetValue("CodeBase", Path.Combine(context.ComponentPath, engine.Module.Name));

var provRegKey = context.CreateKey("CLSID\\" + provider.GUID.ToString("B"));
provRegKey.SetValue("Assembly", provider.Assembly.GetName().Name);
provRegKey.SetValue("Class", provider.FullName);
provRegKey.SetValue("InprocServer32", context.InprocServerPath);
provRegKey.SetValue("CodeBase", Path.Combine(context.ComponentPath, provider.Module.Name));
}

public override void Unregister(RegistrationContext context)
{
}
}
}
7 changes: 7 additions & 0 deletions VisualRust/VisualRust.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Debugger.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Debugger.InteropA, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Editor, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Language.Intellisense, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Language.StandardClassification, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
Expand Down Expand Up @@ -195,6 +197,7 @@
<Compile Include="Forms\RustOptionsPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProvideDebugEngineAttribute.cs" />
<Compile Include="Racer\RacerSingleton.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="RunningDocTableEventsListener.cs" />
Expand Down Expand Up @@ -266,6 +269,10 @@
<Project>{cacb60a9-1e76-4f92-8831-b134a658c695}</Project>
<Name>Microsoft.VisualStudio.Project</Name>
</ProjectReference>
<ProjectReference Include="..\MIEngine\src\MIDebugEngine\MIDebugEngine.csproj">
<Project>{6D2688FE-6FD8-44A8-B96A-6037457F72A7}</Project>
<Name>MIDebugEngine</Name>
</ProjectReference>
<ProjectReference Include="..\RustLexer\RustLexer.csproj">
<Project>{e983e989-f83a-4643-896a-ad496bf647d0}</Project>
<Name>RustLexer</Name>
Expand Down
2 changes: 2 additions & 0 deletions VisualRust/VisualRustPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using System.ComponentModel.Design;
using System.ComponentModel.Composition;
using Microsoft.MIDebugEngine;
using Microsoft.Win32;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
Expand Down Expand Up @@ -66,6 +67,7 @@ namespace VisualRust
[ProvideOptionPage(typeof(RustOptionsPage), "Visual Rust", "General", 110, 113, true)]
[ProvideOptionPage(typeof(DebuggingOptionsPage), "Visual Rust", "Debugging", 110, 114, true)]
[ProvideProfile(typeof(RustOptionsPage), "Visual Rust", "General", 110, 113, true)]
[ProvideDebugEngine("Rust GDB", typeof(AD7ProgramProvider), typeof(AD7Engine), EngineConstants.EngineId)]
public class VisualRustPackage : CommonProjectPackage
{
private RunningDocTableEventsListener docEventsListener;
Expand Down