Code cleanup.

This commit is contained in:
José Pedro 2018-12-13 21:29:22 +00:00
parent b17ce14982
commit 960cf85617
No known key found for this signature in database
GPG key ID: B8247B9301707B83
16 changed files with 146 additions and 196 deletions

View file

@ -27,12 +27,12 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl {
int IDebugBreakpointResolution2.GetResolutionInfo(enum_BPRESI_FIELDS dwFields, BP_RESOLUTION_INFO[] pBPResolutionInfo) { int IDebugBreakpointResolution2.GetResolutionInfo(enum_BPRESI_FIELDS dwFields, BP_RESOLUTION_INFO[] pBPResolutionInfo) {
if ((dwFields & enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) != enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) { if ((dwFields & enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) != enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) {
// The sample engine only supports code breakpoints. // The sample engine only supports code breakpoints.
BP_RESOLUTION_LOCATION location = new BP_RESOLUTION_LOCATION(); var location = new BP_RESOLUTION_LOCATION();
location.bpType = (uint)enum_BP_TYPE.BPT_CODE; location.bpType = (uint)enum_BP_TYPE.BPT_CODE;
// The debugger will not QI the IDebugCodeContex2 interface returned here. We must pass the pointer // The debugger will not QI the IDebugCodeContex2 interface returned here. We must pass the pointer
// to IDebugCodeContex2 and not IUnknown. // to IDebugCodeContex2 and not IUnknown.
AD7MemoryAddress codeContext = new AD7MemoryAddress(m_engine, m_address); var codeContext = new AD7MemoryAddress(m_engine, m_address);
codeContext.SetDocumentContext(m_documentContext); codeContext.SetDocumentContext(m_documentContext);
location.unionmember1 = Marshal.GetComInterfaceForObject(codeContext, typeof(IDebugCodeContext2)); location.unionmember1 = Marshal.GetComInterfaceForObject(codeContext, typeof(IDebugCodeContext2));
pBPResolutionInfo[0].bpResLocation = location; pBPResolutionInfo[0].bpResLocation = location;
@ -40,7 +40,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl {
} }
if (dwFields.HasFlag(enum_BPRESI_FIELDS.BPRESI_PROGRAM)) { if (dwFields.HasFlag(enum_BPRESI_FIELDS.BPRESI_PROGRAM)) {
pBPResolutionInfo[0].pProgram = (IDebugProgram2)m_engine; pBPResolutionInfo[0].pProgram = m_engine;
pBPResolutionInfo[0].dwFields |= enum_BPRESI_FIELDS.BPRESI_PROGRAM; pBPResolutionInfo[0].dwFields |= enum_BPRESI_FIELDS.BPRESI_PROGRAM;
} }
@ -67,5 +67,4 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl {
} }
} }
} }

View file

@ -42,23 +42,14 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// This object facilitates calling from this thread into the worker thread of the engine. This is necessary because the Win32 debugging // This object facilitates calling from this thread into the worker thread of the engine. This is necessary because the Win32 debugging
// api requires thread affinity to several operations. // api requires thread affinity to several operations.
// This object manages breakpoints in the sample engine. // This object manages breakpoints in the sample engine.
protected BreakpointManager mBPMgr; public BreakpointManager BPMgr { get; }
public BreakpointManager BPMgr
{
get { return mBPMgr; }
}
public AD7Engine() public AD7Engine()
{ {
mBPMgr = new BreakpointManager(this); BPMgr = new BreakpointManager(this);
} }
// Used to send events to the debugger. Some examples of these events are thread create, exception thrown, module load. internal EngineCallback Callback { get; private set; }
EngineCallback mEngineCallback;
internal EngineCallback Callback
{
get { return mEngineCallback; }
}
#region Startup Methods #region Startup Methods
// During startup these methods are called in this order: // During startup these methods are called in this order:
@ -81,7 +72,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
oProcess = null; oProcess = null;
try try
{ {
mEngineCallback = new EngineCallback(this, aAD7Callback); Callback = new EngineCallback(this, aAD7Callback);
var xDebugInfo = new Dictionary<string, string>(); var xDebugInfo = new Dictionary<string, string>();
DictionaryHelper.LoadFromString(xDebugInfo, aDebugInfo); DictionaryHelper.LoadFromString(xDebugInfo, aDebugInfo);
@ -91,7 +82,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
//var processLaunchInfo = new ProcessLaunchInfo(exe, xCmdLine, dir, env, options, launchFlags, hStdInput, hStdOutput, hStdError); //var processLaunchInfo = new ProcessLaunchInfo(exe, xCmdLine, dir, env, options, launchFlags, hStdInput, hStdOutput, hStdError);
AD7EngineCreateEvent.Send(this); AD7EngineCreateEvent.Send(this);
oProcess = mProcess = new AD7Process(xDebugInfo, mEngineCallback, this, aPort); oProcess = mProcess = new AD7Process(xDebugInfo, Callback, this, aPort);
// We only support one process, so just use its ID for the program ID // We only support one process, so just use its ID for the program ID
mProgramID = mProcess.ID; mProgramID = mProcess.ID;
//AD7ThreadCreateEvent.Send(this, xProcess.Thread); //AD7ThreadCreateEvent.Send(this, xProcess.Thread);
@ -121,7 +112,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
if (aCeltPrograms != 1) if (aCeltPrograms != 1)
{ {
System.Diagnostics.Debug.Fail("Cosmos Debugger only supports one debug target at a time."); System.Diagnostics.Debug.Fail("Cosmos Debugger only supports one debug target at a time.");
throw new ArgumentException(); throw new InvalidOperationException();
} }
try try
@ -153,16 +144,15 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
// Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
// which will complete the hookup with AD7 // which will complete the hookup with AD7
var xProcess = aProcess as AD7Process; if (!(aProcess is AD7Process xProcess))
if (xProcess == null)
{ {
return VSConstants.E_INVALIDARG; return VSConstants.E_INVALIDARG;
} }
IDebugPort2 xPort;
EngineUtils.RequireOk(aProcess.GetPort(out xPort)); EngineUtils.RequireOk(aProcess.GetPort(out var xPort));
var xDefPort = (IDebugDefaultPort2)xPort; var xDefPort = (IDebugDefaultPort2)xPort;
IDebugPortNotify2 xNotify; EngineUtils.RequireOk(xDefPort.GetPortNotify(out var xNotify));
EngineUtils.RequireOk(xDefPort.GetPortNotify(out xNotify));
// This triggers Attach // This triggers Attach
EngineUtils.RequireOk(xNotify.AddProgramNode(mProgNode)); EngineUtils.RequireOk(xNotify.AddProgramNode(mProgNode));
@ -208,7 +198,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
if (aEvent is AD7ProgramDestroyEvent) if (aEvent is AD7ProgramDestroyEvent)
{ {
mEngineCallback = null; Callback = null;
mProgramID = Guid.Empty; mProgramID = Guid.Empty;
mThread = null; mThread = null;
mProgNode = null; mProgNode = null;
@ -268,7 +258,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
mProcess.Terminate(); mProcess.Terminate();
mEngineCallback.OnProcessExit(0); Callback.OnProcessExit(0);
mProgram = null; mProgram = null;
} }
catch (Exception e) catch (Exception e)
@ -278,7 +268,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
return VSConstants.S_OK; return VSConstants.S_OK;
} }
public int Continue(IDebugThread2 aThread) public int Continue(IDebugThread2 pThread)
{ {
// We don't appear to use or support this currently. // We don't appear to use or support this currently.
@ -286,7 +276,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// but have stepping state remain. An example is when a tracepoint is executed, // but have stepping state remain. An example is when a tracepoint is executed,
// and the debugger does not want to actually enter break mode. // and the debugger does not want to actually enter break mode.
var xThread = (AD7Thread)aThread; var xThread = (AD7Thread)pThread;
//if (AfterBreak) { //if (AfterBreak) {
//Callback.OnBreak(xThread); //Callback.OnBreak(xThread);
//} //}
@ -327,22 +317,22 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
return VSConstants.S_OK; return VSConstants.S_OK;
} }
public int GetEngineInfo(out string engineName, out Guid engineGuid) public int GetEngineInfo(out string pbstrEngine, out Guid pguidEngine)
{ {
// Gets the name and identifier of the debug engine (DE) running this program. // Gets the name and identifier of the debug engine (DE) running this program.
engineName = "Cosmos Debug Engine"; pbstrEngine = "Cosmos Debug Engine";
engineGuid = EngineID; pguidEngine = EngineID;
return VSConstants.S_OK; return VSConstants.S_OK;
} }
public int GetProgramId(out Guid aGuidProgramId) public int GetProgramId(out Guid pguidProgramId)
{ {
// Gets a GUID for this program. A debug engine (DE) must return the program identifier originally passed to the IDebugProgramNodeAttach2::OnAttach // Gets a GUID for this program. A debug engine (DE) must return the program identifier originally passed to the IDebugProgramNodeAttach2::OnAttach
// or IDebugEngine2::Attach methods. This allows identification of the program across debugger components. // or IDebugEngine2::Attach methods. This allows identification of the program across debugger components.
aGuidProgramId = mProgramID; pguidProgramId = mProgramID;
return VSConstants.S_OK; return VSConstants.S_OK;
} }
@ -350,7 +340,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
// This method is deprecated. Use the IDebugProcess3::Step method instead. // This method is deprecated. Use the IDebugProcess3::Step method instead.
mProcess.Step((enum_STEPKIND)sk); mProcess.Step(sk);
return VSConstants.S_OK; return VSConstants.S_OK;
} }
@ -368,19 +358,19 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// Gets the name of the program. // Gets the name of the program.
// The name returned by this method is always a friendly, user-displayable name that describes the program. // The name returned by this method is always a friendly, user-displayable name that describes the program.
public int GetName(out string programName) public int GetName(out string pbstrName)
{ {
// The Sample engine uses default transport and doesn't need to customize the name of the program, // The Sample engine uses default transport and doesn't need to customize the name of the program,
// so return NULL. // so return NULL.
programName = null; pbstrName = null;
return VSConstants.S_OK; return VSConstants.S_OK;
} }
// This method gets the Edit and Continue (ENC) update for this program. A custom debug engine always returns E_NOTIMPL // This method gets the Edit and Continue (ENC) update for this program. A custom debug engine always returns E_NOTIMPL
public int GetENCUpdate(out object update) public int GetENCUpdate(out object ppUpdate)
{ {
// The sample engine does not participate in managed edit & continue. // The sample engine does not participate in managed edit & continue.
update = null; ppUpdate = null;
return VSConstants.S_OK; return VSConstants.S_OK;
} }
@ -445,17 +435,14 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// The debugger calls CauseBreak when the user clicks on the pause button in VS. The debugger should respond by entering // The debugger calls CauseBreak when the user clicks on the pause button in VS. The debugger should respond by entering
// breakmode. // breakmode.
public int CauseBreak() public int CauseBreak() => mProcess.CauseBreak();
{
return this.mProcess.CauseBreak();
}
// EnumCodePaths is used for the step-into specific feature -- right click on the current statment and decide which // EnumCodePaths is used for the step-into specific feature -- right click on the current statment and decide which
// function to step into. This is not something that the SampleEngine supports. // function to step into. This is not something that the SampleEngine supports.
public int EnumCodePaths(string hint, IDebugCodeContext2 start, IDebugStackFrame2 frame, int fSource, out IEnumCodePaths2 pathEnum, out IDebugCodeContext2 safetyContext) public int EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource, out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety)
{ {
pathEnum = null; ppEnum = null;
safetyContext = null; ppSafety = null;
return VSConstants.E_NOTIMPL; return VSConstants.E_NOTIMPL;
} }
@ -472,9 +459,9 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// The debugger calls this when it needs to obtain the IDebugDisassemblyStream2 for a particular code-context. // The debugger calls this when it needs to obtain the IDebugDisassemblyStream2 for a particular code-context.
// The sample engine does not support dissassembly so it returns E_NOTIMPL // The sample engine does not support dissassembly so it returns E_NOTIMPL
public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 codeContext, out IDebugDisassemblyStream2 disassemblyStream) public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream)
{ {
disassemblyStream = null; ppDisassemblyStream = null;
return VSConstants.E_NOTIMPL; return VSConstants.E_NOTIMPL;
} }
@ -583,11 +570,11 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
return VSConstants.E_NOTIMPL; return VSConstants.E_NOTIMPL;
} }
public int GetProcess(out IDebugProcess2 process) public int GetProcess(out IDebugProcess2 ppProcess)
{ {
System.Diagnostics.Debug.Fail("This function is not called by the debugger"); System.Diagnostics.Debug.Fail("This function is not called by the debugger");
process = null; ppProcess = null;
return VSConstants.E_NOTIMPL; return VSConstants.E_NOTIMPL;
} }

View file

@ -27,67 +27,64 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
} }
// Adds a specified value to the current context's address to create a new context. // Adds a specified value to the current context's address to create a new context.
public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress) public int Add(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
{ {
newAddress = new AD7MemoryAddress(m_engine, (uint)dwCount + m_address); ppMemCxt = new AD7MemoryAddress(m_engine, (uint)dwCount + m_address);
return VSConstants.S_OK; return VSConstants.S_OK;
} }
// Compares the memory context to each context in the given array in the manner indicated by compare flags, // Compares the memory context to each context in the given array in the manner indicated by compare flags,
// returning an index of the first context that matches. // returning an index of the first context that matches.
public int Compare(enum_CONTEXT_COMPARE uContextCompare, IDebugMemoryContext2[] compareToItems, uint compareToLength, out uint foundIndex) public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext)
{ {
foundIndex = uint.MaxValue; pdwMemoryContext = UInt32.MaxValue;
try try
{ {
enum_CONTEXT_COMPARE contextCompare = (enum_CONTEXT_COMPARE)uContextCompare; for (uint c = 0; c < dwMemoryContextSetLen; c++)
for (uint c = 0; c < compareToLength; c++)
{ {
AD7MemoryAddress compareTo = compareToItems[c] as AD7MemoryAddress; if (!(rgpMemoryContextSet[c] is AD7MemoryAddress compareTo))
if (compareTo == null)
{ {
continue; continue;
} }
if (!AD7Engine.ReferenceEquals(this.m_engine, compareTo.m_engine)) if (!ReferenceEquals(m_engine, compareTo.m_engine))
{ {
continue; continue;
} }
bool result; bool result;
switch (contextCompare) switch (Compare)
{ {
case enum_CONTEXT_COMPARE.CONTEXT_EQUAL: case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
result = (this.m_address == compareTo.m_address); result = (m_address == compareTo.m_address);
break; break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN: case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
result = (this.m_address < compareTo.m_address); result = (m_address < compareTo.m_address);
break; break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN: case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
result = (this.m_address > compareTo.m_address); result = (m_address > compareTo.m_address);
break; break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL: case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
result = (this.m_address <= compareTo.m_address); result = (m_address <= compareTo.m_address);
break; break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL: case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
result = (this.m_address >= compareTo.m_address); result = (m_address >= compareTo.m_address);
break; break;
// The sample debug engine doesn't understand scopes or functions // The sample debug engine doesn't understand scopes or functions
case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE: case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION: case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
result = (this.m_address == compareTo.m_address); result = (m_address == compareTo.m_address);
break; break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE: case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
result = (this.m_address == compareTo.m_address); result = (m_address == compareTo.m_address);
if (result == false) if (result == false)
{ {
//DebuggedModule module = m_engine.DebuggedProcess.ResolveAddress(m_address); //DebuggedModule module = m_engine.DebuggedProcess.ResolveAddress(m_address);
@ -111,7 +108,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
if (result) if (result)
{ {
foundIndex = c; pdwMemoryContext = c;
return VSConstants.S_OK; return VSConstants.S_OK;
} }
} }

View file

@ -5,16 +5,17 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Microsoft.Internal.VisualStudio.PlatformUI;
using Microsoft.VisualStudio; using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Debugger.Interop; using Microsoft.VisualStudio.Debugger.Interop;
using Cosmos.Build.Common; using Cosmos.Build.Common;
using Cosmos.Debug.Common; using Cosmos.Debug.Common;
using Cosmos.Debug.DebugConnectors; using Cosmos.Debug.DebugConnectors;
using Cosmos.Debug.Hosts; using Cosmos.Debug.Hosts;
using IL2CPU.Debug.Symbols;
using Cosmos.VS.DebugEngine.Engine.Impl; using Cosmos.VS.DebugEngine.Engine.Impl;
using Cosmos.VS.DebugEngine.Utilities; using Cosmos.VS.DebugEngine.Utilities;
using IL2CPU.Debug.Symbols;
using Label = IL2CPU.Debug.Symbols.Label; using Label = IL2CPU.Debug.Symbols.Label;
namespace Cosmos.VS.DebugEngine.AD7.Impl namespace Cosmos.VS.DebugEngine.AD7.Impl
@ -281,8 +282,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
mDbgConnector = null; mDbgConnector = null;
string xPort; mDebugInfo.TryGetValue(BuildPropertyNames.VisualStudioDebugPortString, out var xPort);
mDebugInfo.TryGetValue(BuildPropertyNames.VisualStudioDebugPortString, out xPort);
// using (var xDebug = new StreamWriter(@"e:\debug.info", false)) // using (var xDebug = new StreamWriter(@"e:\debug.info", false))
// { // {
@ -298,10 +298,10 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
mDebugInfo.TryGetValue(BuildPropertyNames.CosmosDebugPortString, out xPort); mDebugInfo.TryGetValue(BuildPropertyNames.CosmosDebugPortString, out xPort);
} }
var xParts = (null == xPort) ? null : xPort.Split(' '); var xParts = xPort?.Split(' ');
if ((null == xParts) || (2 > xParts.Length)) if ((null == xParts) || (2 > xParts.Length))
{ {
throw new Exception(string.Format("Unable to parse VS debug port: '{0}'", xPort)); throw new Exception(String.Format("Unable to parse VS debug port: '{0}'", xPort));
//throw new Exception(string.Format( //throw new Exception(string.Format(
// "The '{0}' Cosmos project file property is either ill-formed or missing.", // "The '{0}' Cosmos project file property is either ill-formed or missing.",
// BuildProperties.VisualStudioDebugPortString)); // BuildProperties.VisualStudioDebugPortString));
@ -497,11 +497,10 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
OutputText("Using ISO file " + mISO + "."); OutputText("Using ISO file " + mISO + ".");
mProjectFile = mDebugInfo["ProjectFile"]; mProjectFile = mDebugInfo["ProjectFile"];
// //
bool xUseGDB = string.Equals(mDebugInfo[BuildPropertyNames.EnableGDBString], "true", StringComparison.InvariantCultureIgnoreCase); bool xUseGDB = String.Equals(mDebugInfo[BuildPropertyNames.EnableGDBString], "true", StringComparison.InvariantCultureIgnoreCase);
OutputText("GDB " + (xUseGDB ? "Enabled" : "Disabled") + "."); OutputText("GDB " + (xUseGDB ? "Enabled" : "Disabled") + ".");
// //
var xGDBClient = false; Boolean.TryParse(mDebugInfo[BuildPropertyNames.StartCosmosGDBString], out var xGDBClient);
Boolean.TryParse(mDebugInfo[BuildPropertyNames.StartCosmosGDBString], out xGDBClient);
switch (mLaunch) switch (mLaunch)
{ {
@ -543,7 +542,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
string bochsConfigurationFileName; string bochsConfigurationFileName;
mDebugInfo.TryGetValue(BuildProperties.BochsEmulatorConfigurationFileString, out bochsConfigurationFileName); mDebugInfo.TryGetValue(BuildProperties.BochsEmulatorConfigurationFileString, out bochsConfigurationFileName);
if (string.IsNullOrEmpty(bochsConfigurationFileName)) if (String.IsNullOrEmpty(bochsConfigurationFileName))
{ {
bochsConfigurationFileName = BuildProperties.BochsDefaultConfigurationFileName; bochsConfigurationFileName = BuildProperties.BochsDefaultConfigurationFileName;
} }
@ -598,9 +597,9 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
protected void LaunchGdbClient() protected void LaunchGdbClient()
{ {
OutputText("Launching GDB client."); OutputText("Launching GDB client.");
if (File.Exists(Cosmos.Build.Common.CosmosPaths.GdbClientExe)) if (File.Exists(CosmosPaths.GdbClientExe))
{ {
var xPSInfo = new ProcessStartInfo(Cosmos.Build.Common.CosmosPaths.GdbClientExe); var xPSInfo = new ProcessStartInfo(CosmosPaths.GdbClientExe);
xPSInfo.Arguments = "\"" + Path.ChangeExtension(mProjectFile, ".cgdb") + "\"" + @" /Connect"; xPSInfo.Arguments = "\"" + Path.ChangeExtension(mProjectFile, ".cgdb") + "\"" + @" /Connect";
xPSInfo.UseShellExecute = false; xPSInfo.UseShellExecute = false;
xPSInfo.RedirectStandardInput = false; xPSInfo.RedirectStandardInput = false;
@ -611,9 +610,9 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
} }
else else
{ {
AD7Util.MessageBox(string.Format( AD7Util.MessageBox(String.Format(
"The GDB-Client could not be found at \"{0}\". Please deactivate it under \"Properties/Debug/Enable GDB\"", "The GDB-Client could not be found at \"{0}\". Please deactivate it under \"Properties/Debug/Enable GDB\"",
Cosmos.Build.Common.CosmosPaths.GdbClientExe), "GDB-Client"); CosmosPaths.GdbClientExe), "GDB-Client");
} }
} }
@ -686,13 +685,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
mCallback.OnOutputStringUser(obj + "\r\n"); mCallback.OnOutputStringUser(obj + "\r\n");
} }
internal AD7Thread Thread internal AD7Thread Thread => mThread;
{
get
{
return mThread;
}
}
void DbgCmdTrace(uint aAddress) void DbgCmdTrace(uint aAddress)
{ {
@ -1173,7 +1166,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
string currentASMLine = mCurrentASMLine; string currentASMLine = mCurrentASMLine;
if (string.IsNullOrEmpty(currentASMLine)) if (String.IsNullOrEmpty(currentASMLine))
{ {
mDbgConnector.SendCmd(Vs2Ds.AsmStepInto); mDbgConnector.SendCmd(Vs2Ds.AsmStepInto);
} }
@ -1186,7 +1179,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
//Get the line after the call //Get the line after the call
string nextASMLine = mNextASMLine1; string nextASMLine = mNextASMLine1;
uint? nextAddress = mNextAddress1; uint? nextAddress = mNextAddress1;
if (string.IsNullOrEmpty(nextASMLine) || !nextAddress.HasValue) if (String.IsNullOrEmpty(nextASMLine) || !nextAddress.HasValue)
{ {
mDbgConnector.SendCmd(Vs2Ds.AsmStepInto); mDbgConnector.SendCmd(Vs2Ds.AsmStepInto);
} }
@ -1276,7 +1269,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
xCurrentLabel = xCurrentLabels.OrderBy(q => q.Length).Last(); xCurrentLabel = xCurrentLabels.OrderBy(q => q.Length).Last();
} }
if (string.IsNullOrEmpty(xCurrentLabel)) if (String.IsNullOrEmpty(xCurrentLabel))
{ {
xCurrentLabel = "NO_METHOD_LABEL_FOUND"; xCurrentLabel = "NO_METHOD_LABEL_FOUND";
} }

View file

@ -26,13 +26,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
const uint mArrayFirstElementOffset = 16; const uint mArrayFirstElementOffset = 16;
private const string NULL = "null"; private const string NULL = "null";
protected Int32 OFFSET protected int OFFSET => mDebugInfo.OFFSET;
{
get
{
return mDebugInfo.OFFSET;
}
}
public AD7Property(DebugLocalInfo localInfo, AD7Process process, AD7StackFrame stackFrame) public AD7Property(DebugLocalInfo localInfo, AD7Process process, AD7StackFrame stackFrame)
{ {
@ -124,17 +118,17 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
} }
if (xDataLength > 0) if (xDataLength > 0)
{ {
if (this.m_variableInformation.Children.Count == 0) if (m_variableInformation.Children.Count == 0)
{ {
for (int i = 0; i < xDataLength; i++) for (int i = 0; i < xDataLength; i++)
{ {
DebugLocalInfo inf = new DebugLocalInfo(); var inf = new DebugLocalInfo();
inf.IsReference = true; inf.IsReference = true;
inf.Type = typeof(T).FullName; inf.Type = typeof(T).FullName;
inf.Offset = (int)(mArrayFirstElementOffset + (System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)) * i)); inf.Offset = (int)(mArrayFirstElementOffset + (System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)) * i));
inf.Pointer = (uint)(xPointer + mArrayFirstElementOffset + (System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)) * i)); inf.Pointer = (uint)(xPointer + mArrayFirstElementOffset + (System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)) * i));
inf.Name = "[" + i.ToString() + "]"; inf.Name = "[" + i.ToString() + "]";
this.m_variableInformation.Children.Add(new AD7Property(inf, this.mProcess, this.mStackFrame)); m_variableInformation.Children.Add(new AD7Property(inf, mProcess, mStackFrame));
} }
} }
} }
@ -149,7 +143,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// Construct a DEBUG_PROPERTY_INFO representing this local or parameter. // Construct a DEBUG_PROPERTY_INFO representing this local or parameter.
public DEBUG_PROPERTY_INFO ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS dwFields) public DEBUG_PROPERTY_INFO ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS dwFields)
{ {
DEBUG_PROPERTY_INFO propertyInfo = new DEBUG_PROPERTY_INFO(); var propertyInfo = new DEBUG_PROPERTY_INFO();
try try
{ {
@ -320,9 +314,13 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
for (int i = 0; (i / 2) < xDataLength; i += 2) for (int i = 0; (i / 2) < xDataLength; i += 2)
{ {
if (!first) if (!first)
{
xSB.Append(", "); xSB.Append(", ");
}
char c = BitConverter.ToChar(xData, i); char c = BitConverter.ToChar(xData, i);
xSB.Append('\''); xSB.Append('\'');
if (c == '\0') if (c == '\0')
{ {
xSB.Append("\\0"); xSB.Append("\\0");
@ -331,6 +329,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
xSB.Append(c); xSB.Append(c);
} }
xSB.Append('\''); xSB.Append('\'');
first = false; first = false;
@ -494,7 +493,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
inf.Offset = xFieldInfo.OFFSET; inf.Offset = xFieldInfo.OFFSET;
inf.Pointer = (uint)(xPointer + xFieldInfo.OFFSET + 12); inf.Pointer = (uint)(xPointer + xFieldInfo.OFFSET + 12);
inf.Name = GetFieldName(xFieldInfo); inf.Name = GetFieldName(xFieldInfo);
this.m_variableInformation.Children.Add(new AD7Property(inf, this.mProcess, this.mStackFrame)); m_variableInformation.Children.Add(new AD7Property(inf, mProcess, mStackFrame));
} }
propertyInfo.bstrValue = String.Format("{0} (0x{1})", xPointer, xPointer.ToString("X").ToUpper()); propertyInfo.bstrValue = String.Format("{0} (0x{1})", xPointer, xPointer.ToString("X").ToUpper());
} }
@ -521,7 +520,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// The sample does not support writing of values displayed in the debugger, so mark them all as read-only. // The sample does not support writing of values displayed in the debugger, so mark them all as read-only.
propertyInfo.dwAttrib = enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_READONLY; propertyInfo.dwAttrib = enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_READONLY;
if (this.m_variableInformation.Children.Count > 0) if (m_variableInformation.Children.Count > 0)
{ {
propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_OBJ_IS_EXPANDABLE; propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_OBJ_IS_EXPANDABLE;
} }
@ -565,9 +564,9 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
ppEnum = null; ppEnum = null;
if (this.m_variableInformation.Children.Count > 0) if (m_variableInformation.Children.Count > 0)
{ {
List<DEBUG_PROPERTY_INFO> infs = new List<DEBUG_PROPERTY_INFO>(); var infs = new List<DEBUG_PROPERTY_INFO>();
foreach (AD7Property dp in m_variableInformation.Children) foreach (AD7Property dp in m_variableInformation.Children)
{ {
infs.Add(dp.ConstructDebugPropertyInfo(dwFields)); infs.Add(dp.ConstructDebugPropertyInfo(dwFields));

View file

@ -1,11 +1,11 @@
using System; using System;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Debugger.Interop;
using Cosmos.VS.DebugEngine.AD7.Definitions; using Cosmos.VS.DebugEngine.AD7.Definitions;
using Cosmos.VS.DebugEngine.Engine.Impl; using Cosmos.VS.DebugEngine.Engine.Impl;
using Microsoft.VisualStudio.Debugger.Interop;
using IL2CPU.Debug.Symbols; using IL2CPU.Debug.Symbols;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
namespace Cosmos.VS.DebugEngine.AD7.Impl namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
@ -24,8 +24,8 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// Must have empty holders, some code looks at length and can run // Must have empty holders, some code looks at length and can run
// before we set them. // before we set them.
internal LOCAL_ARGUMENT_INFO[] mLocalInfos = new LOCAL_ARGUMENT_INFO[] { }; internal LOCAL_ARGUMENT_INFO[] mLocalInfos = Array.Empty<LOCAL_ARGUMENT_INFO>();
internal LOCAL_ARGUMENT_INFO[] mArgumentInfos = new LOCAL_ARGUMENT_INFO[] { }; internal LOCAL_ARGUMENT_INFO[] mArgumentInfos = Array.Empty<LOCAL_ARGUMENT_INFO>();
// An array of this frame's parameters // An array of this frame's parameters
private DebugLocalInfo[] mParams; private DebugLocalInfo[] mParams;
@ -42,7 +42,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
var xProcess = mEngine.mProcess; var xProcess = mEngine.mProcess;
if (mHasSource = xProcess.mCurrentAddress.HasValue) if (mHasSource = xProcess.mCurrentAddress.HasValue)
{ {
UInt32 xAddress = xProcess.mCurrentAddress.Value; var xAddress = xProcess.mCurrentAddress.Value;
var xSourceInfos = xProcess.mDebugInfoDb.GetSourceInfos(xAddress); var xSourceInfos = xProcess.mDebugInfoDb.GetSourceInfos(xAddress);
if (!xSourceInfos.ContainsKey(xAddress)) if (!xSourceInfos.ContainsKey(xAddress))
{ {
@ -293,7 +293,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
for (int i = 0; i < mLocals.Length; i++) for (int i = 0; i < mLocals.Length; i++)
{ {
AD7Property property = new AD7Property(mLocals[i], this.mProcess, this); var property = new AD7Property(mLocals[i], mProcess, this);
propInfo[i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); propInfo[i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD);
} }
} }
@ -302,7 +302,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
for (int i = 0; i < mParams.Length; i++) for (int i = 0; i < mParams.Length; i++)
{ {
AD7Property property = new AD7Property(mParams[i], this.mProcess, this); var property = new AD7Property(mParams[i], mProcess, this);
propInfo[localsLength + i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); propInfo[localsLength + i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD);
} }
} }
@ -335,7 +335,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
for (int i = 0; i < propInfo.Length; i++) for (int i = 0; i < propInfo.Length; i++)
{ {
AD7Property property = new AD7Property(mParams[i], mProcess, this); var property = new AD7Property(mParams[i], mProcess, this);
propInfo[i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); propInfo[i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD);
} }
@ -459,7 +459,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
// or IDebugExpression2::EvaluateAsync methods to evaluate the parsed expression. // or IDebugExpression2::EvaluateAsync methods to evaluate the parsed expression.
int IDebugStackFrame2.GetExpressionContext(out IDebugExpressionContext2 ppExprCxt) int IDebugStackFrame2.GetExpressionContext(out IDebugExpressionContext2 ppExprCxt)
{ {
ppExprCxt = (IDebugExpressionContext2)this; ppExprCxt = this;
return VSConstants.S_OK; return VSConstants.S_OK;
} }
@ -468,7 +468,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
try try
{ {
SetFrameInfo((enum_FRAMEINFO_FLAGS)dwFieldSpec, out pFrameInfo[0]); SetFrameInfo(dwFieldSpec, out pFrameInfo[0]);
return VSConstants.S_OK; return VSConstants.S_OK;
} }

View file

@ -55,7 +55,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl {
xFrameInfoArray = new FRAMEINFO[1]; xFrameInfoArray = new FRAMEINFO[1];
var xFrame = new AD7StackFrame(mEngine, this, mProcess); var xFrame = new AD7StackFrame(mEngine, this, mProcess);
xFrame.SetFrameInfo((enum_FRAMEINFO_FLAGS)aFieldSpec, out xFrameInfoArray[0]); xFrame.SetFrameInfo(aFieldSpec, out xFrameInfoArray[0]);
//} else { //} else {
//frameInfoArray = new FRAMEINFO[numStackFrames]; //frameInfoArray = new FRAMEINFO[numStackFrames];

View file

@ -1,57 +1,26 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Debugger.Interop; using Microsoft.VisualStudio.Debugger.Interop;
namespace Cosmos.VS.DebugEngine.AD7.Impl namespace Cosmos.VS.DebugEngine.AD7.Impl
{ {
public class DebugLocalInfo public class DebugLocalInfo
{ {
public bool IsLocal public bool IsLocal { get; set; }
{
get;
set;
}
public bool IsReference public bool IsReference { get; set; }
{
get;
set;
}
public string Type public string Type { get; set; }
{
get;
set;
}
public string Name public string Name { get; set; }
{
get;
set;
}
public int Offset public int Offset { get; set; }
{
get;
set;
}
public uint Pointer [SuppressMessage("Naming", "CA1720:Identifier contains type name", Scope = "member")]
{ public uint Pointer { get; set; }
get;
set;
}
public int Index public int Index { get; set; }
{
get;
set;
}
private List<IDebugProperty2> m_children = new List<IDebugProperty2>(); public List<IDebugProperty2> Children { get; } = new List<IDebugProperty2>();
public List<IDebugProperty2> Children
{
get { return m_children; }
set { m_children = value; }
}
} }
} }

View file

@ -14,6 +14,8 @@ namespace Cosmos.VS.DebugEngine
public static void MessageBox(string message, string title = "Cosmos Debug Engine") public static void MessageBox(string message, string title = "Cosmos Debug Engine")
{ {
ThreadHelper.ThrowIfNotOnUIThread();
VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider, message, title, VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider, message, title,
OLEMSGICON.OLEMSGICON_NOICON, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); OLEMSGICON.OLEMSGICON_NOICON, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
} }

View file

@ -40,9 +40,9 @@ namespace Cosmos.VS.DebugEngine.Commands
return VSConstants.S_OK; return VSConstants.S_OK;
} }
protected static bool IsQueryParameterList(System.IntPtr pvaIn, System.IntPtr pvaOut, uint nCmdexecopt) protected static bool IsQueryParameterList(IntPtr pvaIn, IntPtr pvaOut, uint nCmdexecopt)
{ {
ushort lo = (ushort)(nCmdexecopt & (uint)0xffff); ushort lo = (ushort)(nCmdexecopt & 0xffff);
ushort hi = (ushort)(nCmdexecopt >> 16); ushort hi = (ushort)(nCmdexecopt >> 16);
if (lo == (ushort)OLECMDEXECOPT.OLECMDEXECOPT_SHOWHELP) if (lo == (ushort)OLECMDEXECOPT.OLECMDEXECOPT_SHOWHELP)
{ {

View file

@ -2,6 +2,7 @@
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft;
using Microsoft.VisualStudio; using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Shell.Interop;
@ -43,6 +44,8 @@ namespace Cosmos.VS.DebugEngine.Commands
} }
var parseCommandLine = (IVsParseCommandLine)serviceProvider.GetService(typeof(SVsParseCommandLine)); var parseCommandLine = (IVsParseCommandLine)serviceProvider.GetService(typeof(SVsParseCommandLine));
Assumes.Present(parseCommandLine);
hr = parseCommandLine.ParseCommandTail(arguments, iMaxParams: -1); hr = parseCommandLine.ParseCommandTail(arguments, iMaxParams: -1);
if (ErrorHandler.Failed(hr)) if (ErrorHandler.Failed(hr))
@ -119,6 +122,8 @@ namespace Cosmos.VS.DebugEngine.Commands
ThreadHelper.ThrowIfNotOnUIThread(); ThreadHelper.ThrowIfNotOnUIThread();
var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(IVsDebugger)); var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(IVsDebugger));
Assumes.Present(debugger);
var debugTargets = new VsDebugTargetInfo4[1]; var debugTargets = new VsDebugTargetInfo4[1];
debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
debugTargets[0].bstrExe = filePath; debugTargets[0].bstrExe = filePath;

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft;
using Microsoft.VisualStudio; using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Shell.Interop;
@ -23,13 +24,13 @@ namespace Cosmos.VS.DebugEngine.Commands
{ {
} }
public override int Execute(uint nCmdLogOpt, IntPtr pvaIn, IntPtr pvaOut) public override int Execute(uint nCmdExecOpt, IntPtr pvaIn, IntPtr pvaOut)
{ {
ThreadHelper.ThrowIfNotOnUIThread(); ThreadHelper.ThrowIfNotOnUIThread();
int hr; int hr;
if (IsQueryParameterList(pvaIn, pvaOut, nCmdLogOpt)) if (IsQueryParameterList(pvaIn, pvaOut, nCmdExecOpt))
{ {
Marshal.GetNativeVariantForObject("$ /switchdefs:\"" + DebugLogCommandSyntax + "\"", pvaOut); Marshal.GetNativeVariantForObject("$ /switchdefs:\"" + DebugLogCommandSyntax + "\"", pvaOut);
return VSConstants.S_OK; return VSConstants.S_OK;
@ -43,6 +44,8 @@ namespace Cosmos.VS.DebugEngine.Commands
} }
var parseCommandLine = (IVsParseCommandLine)serviceProvider.GetService(typeof(SVsParseCommandLine)); var parseCommandLine = (IVsParseCommandLine)serviceProvider.GetService(typeof(SVsParseCommandLine));
Assumes.Present(parseCommandLine);
hr = parseCommandLine.ParseCommandTail(arguments, iMaxParams: -1); hr = parseCommandLine.ParseCommandTail(arguments, iMaxParams: -1);
if (ErrorHandler.Failed(hr)) if (ErrorHandler.Failed(hr))
@ -106,6 +109,8 @@ namespace Cosmos.VS.DebugEngine.Commands
catch (Exception e) catch (Exception e)
{ {
var commandWindow = (IVsCommandWindow)serviceProvider.GetService(typeof(SVsCommandWindow)); var commandWindow = (IVsCommandWindow)serviceProvider.GetService(typeof(SVsCommandWindow));
Assumes.Present(commandWindow);
commandWindow.Print(String.Format(CultureInfo.CurrentCulture, "Error: {0}\r\n", e.Message)); commandWindow.Print(String.Format(CultureInfo.CurrentCulture, "Error: {0}\r\n", e.Message));
} }
} }

View file

@ -24,7 +24,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
// A helper method used to construct a new pending breakpoint. // A helper method used to construct a new pending breakpoint.
public void CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, out IDebugPendingBreakpoint2 ppPendingBP) { public void CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, out IDebugPendingBreakpoint2 ppPendingBP) {
var pendingBreakpoint = new AD7PendingBreakpoint(pBPRequest, mEngine, this); var pendingBreakpoint = new AD7PendingBreakpoint(pBPRequest, mEngine, this);
ppPendingBP = (IDebugPendingBreakpoint2)pendingBreakpoint; ppPendingBP = pendingBreakpoint;
mPendingBPs.Add(pendingBreakpoint); mPendingBPs.Add(pendingBreakpoint);
} }

View file

@ -14,10 +14,9 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
} }
public void Send(IDebugEvent2 eventObject, string iidEvent, IDebugProgram2 program, IDebugThread2 thread) { public void Send(IDebugEvent2 eventObject, string iidEvent, IDebugProgram2 program, IDebugThread2 thread) {
uint attributes;
var riidEvent = new Guid(iidEvent); var riidEvent = new Guid(iidEvent);
EngineUtils.RequireOk(eventObject.GetAttributes(out attributes)); EngineUtils.RequireOk(eventObject.GetAttributes(out var attributes));
EngineUtils.RequireOk(m_ad7Callback.Event(m_engine, null, program, thread, eventObject, ref riidEvent, attributes)); EngineUtils.RequireOk(m_ad7Callback.Event(m_engine, null, program, thread, eventObject, ref riidEvent, attributes));
} }
@ -39,7 +38,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
// System.Diagnostics.Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId); // System.Diagnostics.Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId);
//} //}
AD7ModuleLoadEvent eventObject = new AD7ModuleLoadEvent(aModule, true /* this is a module load */); var eventObject = new AD7ModuleLoadEvent(aModule, true /* this is a module load */);
Send(eventObject, AD7ModuleLoadEvent.IID, null); Send(eventObject, AD7ModuleLoadEvent.IID, null);
} }
@ -74,7 +73,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
public void OnProcessExit(uint exitCode) { public void OnProcessExit(uint exitCode) {
//System.Diagnostics.Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId); //System.Diagnostics.Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId);
AD7ProgramDestroyEvent eventObject = new AD7ProgramDestroyEvent(exitCode); var eventObject = new AD7ProgramDestroyEvent(exitCode);
Send(eventObject, AD7ProgramDestroyEvent.IID, null); Send(eventObject, AD7ProgramDestroyEvent.IID, null);
} }
@ -98,7 +97,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
// System.Diagnostics.Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId); // System.Diagnostics.Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId);
//} //}
AD7ThreadCreateEvent eventObject = new AD7ThreadCreateEvent(); var eventObject = new AD7ThreadCreateEvent();
Send(eventObject, AD7ThreadCreateEvent.IID, debuggedThread); Send(eventObject, AD7ThreadCreateEvent.IID, debuggedThread);
} }
@ -120,8 +119,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
// The sample engine does not support these features. // The sample engine does not support these features.
var boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints); var boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);
var eventObject = new AD7BreakpointEvent(boundBreakpointsEnum); var eventObject = new AD7BreakpointEvent(boundBreakpointsEnum);
var ad7Thread = (AD7Thread)thread; Send(eventObject, AD7BreakpointEvent.IID, thread);
Send(eventObject, AD7BreakpointEvent.IID, ad7Thread);
} }
public void OnException() { //DebuggedThread thread, uint code) public void OnException() { //DebuggedThread thread, uint code)
@ -155,7 +153,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
} }
public void OnProgramDestroy(uint exitCode) { public void OnProgramDestroy(uint exitCode) {
AD7ProgramDestroyEvent eventObject = new AD7ProgramDestroyEvent(exitCode); var eventObject = new AD7ProgramDestroyEvent(exitCode);
Send(eventObject, AD7ProgramDestroyEvent.IID, null); Send(eventObject, AD7ProgramDestroyEvent.IID, null);
} }
@ -163,17 +161,16 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
public void OnSymbolSearch(AD7Module module, string status, enum_MODULE_INFO_FLAGS dwStatusFlags) { public void OnSymbolSearch(AD7Module module, string status, enum_MODULE_INFO_FLAGS dwStatusFlags) {
string statusString = (dwStatusFlags == enum_MODULE_INFO_FLAGS.MIF_SYMBOLS_LOADED ? "Symbols Loaded - " : "No symbols loaded") + status; string statusString = (dwStatusFlags == enum_MODULE_INFO_FLAGS.MIF_SYMBOLS_LOADED ? "Symbols Loaded - " : "No symbols loaded") + status;
AD7SymbolSearchEvent eventObject = new AD7SymbolSearchEvent(module, statusString, dwStatusFlags); var eventObject = new AD7SymbolSearchEvent(module, statusString, dwStatusFlags);
Send(eventObject, AD7SymbolSearchEvent.IID, null); Send(eventObject, AD7SymbolSearchEvent.IID, null);
} }
// Engines notify the debugger that a breakpoint has bound through the breakpoint bound event. // Engines notify the debugger that a breakpoint has bound through the breakpoint bound event.
public void OnBreakpointBound(object objBoundBreakpoint, uint address) { public void OnBreakpointBound(object objBoundBreakpoint, uint address) {
AD7BoundBreakpoint boundBreakpoint = (AD7BoundBreakpoint)objBoundBreakpoint; var boundBreakpoint = (AD7BoundBreakpoint)objBoundBreakpoint;
IDebugPendingBreakpoint2 pendingBreakpoint; ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out var pendingBreakpoint);
((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint);
AD7BreakpointBoundEvent eventObject = new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint); var eventObject = new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint);
Send(eventObject, AD7BreakpointBoundEvent.IID, null); Send(eventObject, AD7BreakpointBoundEvent.IID, null);
} }

View file

@ -14,7 +14,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
} }
if (exe[0] == '\"') { if (exe[0] == '\"') {
startQuote = string.Empty; startQuote = String.Empty;
if (exe.Length == 1) { if (exe.Length == 1) {
//throw new ComponentException(Constants.E_WIN32_INVALID_NAME); //throw new ComponentException(Constants.E_WIN32_INVALID_NAME);
} }
@ -25,7 +25,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
if (exe.Length == 2 || endQuote != exe.Length - 1) { if (exe.Length == 2 || endQuote != exe.Length - 1) {
//throw new ComponentException(Constants.E_WIN32_INVALID_NAME); //throw new ComponentException(Constants.E_WIN32_INVALID_NAME);
} }
afterExe = string.Empty; afterExe = String.Empty;
} }
} else { } else {
// If it doesn't start with a quote, it shouldn't have any // If it doesn't start with a quote, it shouldn't have any
@ -36,7 +36,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
if (args == null) { if (args == null) {
args = ""; args = "";
} else if (args != String.Empty) { } else if (args.Length != 0) {
afterExe = "\" "; afterExe = "\" ";
} else { } else {
afterExe = " "; afterExe = " ";
@ -47,9 +47,8 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
public static string GetAddressDescription(/*DebuggedModule module,*/AD7Engine engine, uint ip) public static string GetAddressDescription(/*DebuggedModule module,*/AD7Engine engine, uint ip)
{ {
AD7StackFrame d = new AD7StackFrame(engine, engine.mThread, engine.mProcess); var d = new AD7StackFrame(engine, engine.mThread, engine.mProcess);
FRAMEINFO info; d.SetFrameInfo(enum_FRAMEINFO_FLAGS.FIF_FUNCNAME | enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS, out var info);
d.SetFrameInfo(enum_FRAMEINFO_FLAGS.FIF_FUNCNAME | enum_FRAMEINFO_FLAGS.FIF_FUNCNAME_ARGS, out info);
return info.m_bstrFuncName; return info.m_bstrFuncName;
//string location = ip.ToString("x8", CultureInfo.InvariantCulture); //string location = ip.ToString("x8", CultureInfo.InvariantCulture);
@ -76,8 +75,8 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
} }
public static int GetProcessId(IDebugProcess2 process) { public static int GetProcessId(IDebugProcess2 process) {
AD_PROCESS_ID[] pid = new AD_PROCESS_ID[1]; var pid = new AD_PROCESS_ID[1];
EngineUtils.RequireOk(process.GetPhysicalProcessId(pid)); RequireOk(process.GetPhysicalProcessId(pid));
if (pid[0].ProcessIdType != (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM) { if (pid[0].ProcessIdType != (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM) {
return 0; return 0;
@ -87,9 +86,7 @@ namespace Cosmos.VS.DebugEngine.Engine.Impl {
} }
public static int GetProcessId(IDebugProgram2 program) { public static int GetProcessId(IDebugProgram2 program) {
IDebugProcess2 process; RequireOk(program.GetProcess(out var process));
RequireOk(program.GetProcess(out process));
return GetProcessId(process); return GetProcessId(process);
} }

View file

@ -12,7 +12,7 @@ namespace Cosmos.VS.DebugEngine.Utilities
{ {
if (aMethod == null) if (aMethod == null)
{ {
throw new ArgumentNullException("aMethod"); throw new ArgumentNullException(nameof(aMethod));
} }
var xBuilder = new StringBuilder(256); var xBuilder = new StringBuilder(256);
var xParts = aMethod.ToString().Split(' '); var xParts = aMethod.ToString().Split(' ');