This commit is contained in:
mterwoord_cp 2010-08-11 07:52:11 +00:00
parent 99c7f96792
commit f19e133ef6
6 changed files with 91 additions and 78 deletions

View file

@ -6,6 +6,8 @@ using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Debugger.Interop; using Microsoft.VisualStudio.Debugger.Interop;
using System.Diagnostics; using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Collections.Specialized;
using Cosmos.Debug.Common;
namespace Cosmos.Debug.VSDebugEngine namespace Cosmos.Debug.VSDebugEngine
{ {
@ -355,6 +357,9 @@ namespace Cosmos.Debug.VSDebugEngine
{ {
m_engineCallback = new EngineCallback(this, aAD7Callback); m_engineCallback = new EngineCallback(this, aAD7Callback);
var xDebugInfo = new NameValueCollection();
NameValueCollectionHelper.LoadFromString(xDebugInfo, aDebugInfo);
//string commandLine = EngineUtils.BuildCommandLine(exe, args); //string commandLine = EngineUtils.BuildCommandLine(exe, args);
//ProcessLaunchInfo processLaunchInfo = new ProcessLaunchInfo(exe, commandLine, dir, env, options, launchFlags, hStdInput, hStdOutput, hStdError); //ProcessLaunchInfo processLaunchInfo = new ProcessLaunchInfo(exe, commandLine, dir, env, options, launchFlags, hStdInput, hStdOutput, hStdError);
// We are being asked to debug a process when we currently aren't debugging anything // We are being asked to debug a process when we currently aren't debugging anything
@ -365,53 +370,52 @@ namespace Cosmos.Debug.VSDebugEngine
// var m_debuggedProcess = Worker.LaunchProcess(m_engineCallback, processLaunchInfo); // var m_debuggedProcess = Worker.LaunchProcess(m_engineCallback, processLaunchInfo);
//})); //}));
AD7EngineCreateEvent.Send(this);
AD7EngineCreateEvent.Send(this); var xProcess = new AD7Process(xDebugInfo, m_engineCallback, this, aPort);
var xProcess = new AD7Process(aDebugInfo, m_engineCallback, this, aPort); aProcess = xProcess;
aProcess = xProcess; mProcess = xProcess;
mProcess = xProcess; m_ad7ProgramId = xProcess.mID;
m_ad7ProgramId = xProcess.mID; //AD7ThreadCreateEvent.Send(this, xProcess.Thread);
//AD7ThreadCreateEvent.Send(this, xProcess.Thread); mModule = new AD7Module();
mModule = new AD7Module(); mProgNode = new AD7ProgramNode(EngineUtils.GetProcessId(xProcess));
mProgNode = new AD7ProgramNode(EngineUtils.GetProcessId(xProcess));
// DebuggedModule^ module = m_moduleList->First->Value; // DebuggedModule^ module = m_moduleList->First->Value;
//CComBSTR bstrModuleName; //CComBSTR bstrModuleName;
//CComBSTR bstrSymbolPath; //CComBSTR bstrSymbolPath;
//bstrModuleName.Attach((BSTR)(System::Runtime::InteropServices::Marshal::StringToBSTR(module->Name).ToInt32())); //bstrModuleName.Attach((BSTR)(System::Runtime::InteropServices::Marshal::StringToBSTR(module->Name).ToInt32()));
//// Load symbols for the application's exe. This is the only symbol file the sample engine will load. //// Load symbols for the application's exe. This is the only symbol file the sample engine will load.
//if (m_pSymbolEngine->LoadSymbolsForModule(bstrModuleName, &bstrSymbolPath)) //if (m_pSymbolEngine->LoadSymbolsForModule(bstrModuleName, &bstrSymbolPath))
//{ //{
// module->SymbolsLoaded = true; // module->SymbolsLoaded = true;
// module->SymbolPath = gcnew String(bstrSymbolPath); // module->SymbolPath = gcnew String(bstrSymbolPath);
//} //}
//m_entrypointModule = module; //m_entrypointModule = module;
//DebuggedThread^ thread = CreateThread(m_lastDebugEvent.dwThreadId, m_lastDebugEvent.u.CreateProcessInfo.hThread, (DWORD_PTR)m_lastDebugEvent.u.CreateProcessInfo.lpStartAddress); //DebuggedThread^ thread = CreateThread(m_lastDebugEvent.dwThreadId, m_lastDebugEvent.u.CreateProcessInfo.hThread, (DWORD_PTR)m_lastDebugEvent.u.CreateProcessInfo.lpStartAddress);
//if (m_debugMethod == Launch) //if (m_debugMethod == Launch)
//{ //{
// // Because of Com-re-entrancy, the engine must wait to send the fake mod-load and thread create events until after the // // Because of Com-re-entrancy, the engine must wait to send the fake mod-load and thread create events until after the
// // launch is complete. Save these references so the call to ResumeFromLaunch can send the events. // // launch is complete. Save these references so the call to ResumeFromLaunch can send the events.
// m_entrypointModule = module; // m_entrypointModule = module;
// m_entrypointThread = thread; // m_entrypointThread = thread;
// // Do not continue the create process event until after the call to ResumeFromLaunch. // // Do not continue the create process event until after the call to ResumeFromLaunch.
// fContinue = false; // fContinue = false;
//} //}
//else //else
//{ //{
// // This is an attach. // // This is an attach.
// // Fake up a thread create event for the entrypoint module and the first thread in the process for attach // // Fake up a thread create event for the entrypoint module and the first thread in the process for attach
//m_callback->OnModuleLoad(module); //m_callback->OnModuleLoad(module);
//m_callback->OnSymbolSearch(module, module->SymbolPath, module->SymbolsLoaded); //m_callback->OnSymbolSearch(module, module->SymbolPath, module->SymbolsLoaded);
// m_callback->OnThreadStart(thread); // m_callback->OnThreadStart(thread);
//} //}
return VSConstants.S_OK; return VSConstants.S_OK;
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -123,12 +123,13 @@ namespace Cosmos.Debug.VSDebugEngine {
public string mISO; public string mISO;
public string mProjectFile; public string mProjectFile;
internal AD7Process(string aDebugInfo, EngineCallback aCallback, AD7Engine aEngine, IDebugPort2 aPort) { internal AD7Process(NameValueCollection aDebugInfo, EngineCallback aCallback, AD7Engine aEngine, IDebugPort2 aPort)
{
mCallback = aCallback; mCallback = aCallback;
// Load passed in values // Load passed in values
mDebugInfo = new NameValueCollection(); mDebugInfo = aDebugInfo;
NameValueCollectionHelper.LoadFromString(mDebugInfo, aDebugInfo);
// //
mISO = mDebugInfo["ISOFile"]; mISO = mDebugInfo["ISOFile"];
mProjectFile = mDebugInfo["ProjectFile"]; mProjectFile = mDebugInfo["ProjectFile"];

View file

@ -14,7 +14,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<BuildTarget>VMWare</BuildTarget> <BuildTarget>ISO</BuildTarget>
<Framework>MicrosoftNET</Framework> <Framework>MicrosoftNET</Framework>
<UseInternalAssembler>False</UseInternalAssembler> <UseInternalAssembler>False</UseInternalAssembler>
<DebugMode>Source</DebugMode> <DebugMode>Source</DebugMode>
@ -47,7 +47,7 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\BreakpointsKernel\BreakpointsKernel.csproj"> <ProjectReference Include="..\Breakpoints\BreakpointsKernel.csproj">
<Name>BreakpointsKernel</Name> <Name>BreakpointsKernel</Name>
<Project>{91cbd640-c07d-4556-b4cb-6f8cd88c67c9}</Project> <Project>{91cbd640-c07d-4556-b4cb-6f8cd88c67c9}</Project>
<Private>True</Private> <Private>True</Private>

View file

@ -143,7 +143,7 @@ namespace Cosmos.VS.Package {
private void comboTarget_SelectedIndexChanged(object sender, EventArgs e) { private void comboTarget_SelectedIndexChanged(object sender, EventArgs e) {
var xEnumValue = (EnumValue)comboTarget.SelectedItem; var xEnumValue = (EnumValue)comboTarget.SelectedItem;
var xValue = (TargetHost)xEnumValue.Value; var xValue = (TargetHost)xEnumValue.Value;
if (xValue != TargetHost.VMWare) { if (xValue != TargetHost.VMWare && xValue != TargetHost.ISO) {
MessageBox.Show("This type is temporarily unsupported."); MessageBox.Show("This type is temporarily unsupported.");
} }
} }

View file

@ -18,6 +18,7 @@ namespace Cosmos.VS.Package.Templates.Wizards
public void ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem) public void ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem)
{ {
} }
public void RunFinished() public void RunFinished()

View file

@ -29,46 +29,53 @@ namespace Cosmos.VS.Package
LogUtility.LogString("Entering Cosmos.VS.Package.VsProjectConfig.DebugLaunch({0})", aLaunch); LogUtility.LogString("Entering Cosmos.VS.Package.VsProjectConfig.DebugLaunch({0})", aLaunch);
try try
{ {
// http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.vsdebugtargetinfo_members.aspx if (String.Equals(this.GetConfigurationProperty("BuildTarget", true), "ISO", StringComparison.InvariantCultureIgnoreCase))
var xInfo = new VsDebugTargetInfo(); {
xInfo.cbSize = (uint)Marshal.SizeOf(xInfo); return VSConstants.S_OK;
}
else
{
// http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.vsdebugtargetinfo_members.aspx
var xInfo = new VsDebugTargetInfo();
xInfo.cbSize = (uint)Marshal.SizeOf(xInfo);
xInfo.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; xInfo.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
xInfo.fSendStdoutToOutputWindow = 0; // App keeps its stdout xInfo.fSendStdoutToOutputWindow = 0; // App keeps its stdout
xInfo.grfLaunch = aLaunch; // Just pass through for now. xInfo.grfLaunch = aLaunch; // Just pass through for now.
xInfo.bstrRemoteMachine = null; // debug locally xInfo.bstrRemoteMachine = null; // debug locally
// On first call, reset the cache, following calls will use the cached values // On first call, reset the cache, following calls will use the cached values
// Think we will change this to a dummy program when we get our debugger working // Think we will change this to a dummy program when we get our debugger working
// This is the program that gest launched after build // This is the program that gest launched after build
var xValues = new NameValueCollection(); var xValues = new NameValueCollection();
xValues.Add("ISOFile", Path.Combine(Path.GetDirectoryName(ProjectMgr.GetOutputAssembly(this.ConfigName)), Path.GetFileNameWithoutExtension(ProjectMgr.GetOutputAssembly(this.ConfigName)) + ".iso")); xValues.Add("ISOFile", Path.Combine(Path.GetDirectoryName(ProjectMgr.GetOutputAssembly(this.ConfigName)), Path.GetFileNameWithoutExtension(ProjectMgr.GetOutputAssembly(this.ConfigName)) + ".iso"));
xValues.Add("BinFormat", this.GetConfigurationProperty("BinFormat", true)); xValues.Add("BinFormat", this.GetConfigurationProperty("BinFormat", true));
xValues.Add("EnableGDB", this.GetConfigurationProperty("EnableGDB", true)); xValues.Add("EnableGDB", this.GetConfigurationProperty("EnableGDB", true));
xValues.Add("DebugMode", this.GetConfigurationProperty("DebugMode", true)); xValues.Add("DebugMode", this.GetConfigurationProperty("DebugMode", true));
xValues.Add("TraceAssemblies", this.GetConfigurationProperty("TraceAssemblies", true)); xValues.Add("TraceAssemblies", this.GetConfigurationProperty("TraceAssemblies", true));
xValues.Add("BuildTarget", this.GetConfigurationProperty("BuildTarget", true)); xValues.Add("BuildTarget", this.GetConfigurationProperty("BuildTarget", true));
xValues.Add("ProjectFile", Path.Combine(ProjectMgr.ProjectFolder, ProjectMgr.ProjectFile)); xValues.Add("ProjectFile", Path.Combine(ProjectMgr.ProjectFolder, ProjectMgr.ProjectFile));
xValues.Add("VMWareFlavor", this.GetConfigurationProperty("VMWareFlavor", true)); xValues.Add("VMWareFlavor", this.GetConfigurationProperty("VMWareFlavor", true));
xValues.Add("StartCosmosGDB", this.GetConfigurationProperty("StartCosmosGDB", true)); xValues.Add("StartCosmosGDB", this.GetConfigurationProperty("StartCosmosGDB", true));
xInfo.bstrExe = NameValueCollectionHelper.DumpToString(xValues); xInfo.bstrExe = NameValueCollectionHelper.DumpToString(xValues);
LogUtility.LogString("Parameters = '{0}'", xInfo.bstrExe); LogUtility.LogString("Parameters = '{0}'", xInfo.bstrExe);
// Select the debugger // Select the debugger
// Managed debugger // Managed debugger
//xInfo.clsidCustom = VSConstants.CLSID_ComPlusOnlyDebugEngine; //xInfo.clsidCustom = VSConstants.CLSID_ComPlusOnlyDebugEngine;
// Our debugger - a work in progress // Our debugger - a work in progress
xInfo.clsidCustom = new Guid(AD7Engine.ID); xInfo.clsidCustom = new Guid(AD7Engine.ID);
xInfo.clsidPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}"); xInfo.clsidPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}");
// Sample Debug Engine // Sample Debug Engine
//xInfo.clsidCustom = new Guid("{D951924A-4999-42a0-9217-1EB5233D1D5A}"); //xInfo.clsidCustom = new Guid("{D951924A-4999-42a0-9217-1EB5233D1D5A}");
VsShellUtilities.LaunchDebugger(ProjectMgr.Site, xInfo); VsShellUtilities.LaunchDebugger(ProjectMgr.Site, xInfo);
LogUtility.LogString("Returning VSConstants.S_OK"); LogUtility.LogString("Returning VSConstants.S_OK");
return VSConstants.S_OK; return VSConstants.S_OK;
}
} }
catch (Exception e) catch (Exception e)
{ {