From ab87777e1c9570be9922ac894ba518e40912bfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Tue, 20 Dec 2005 23:40:37 +0000 Subject: [PATCH] CorDebugger wrapper used by the debugger git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@930 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Breakpoints/Breakpoint.cs | 7 ++++--- .../Src/Breakpoints/NDebugger-Breakpoints.cs | 4 ++-- .../Project/Src/Debugger/Internal/MTA2STA.cs | 3 ++- .../Src/Debugger/Internal/ManagedCallback.cs | 10 +++++----- .../Src/Debugger/Internal/ManagedCallbackProxy.cs | 14 +++++++------- .../Project/Src/Debugger/NDebugger-StateControl.cs | 2 +- .../Project/Src/Debugger/NDebugger.cs | 8 +++++--- .../Debugger.Core/Project/Src/Modules/Module.cs | 10 +++++----- .../Project/Src/Modules/NDebugger-Modules.cs | 2 +- .../Debugger.Core/Project/Src/Threads/Exception.cs | 2 +- .../Debugger.Core/Project/Src/Threads/Function.cs | 10 +++++----- .../Project/Src/Threads/NDebugger-Processes.cs | 2 +- .../Project/Src/Threads/NDebugger-Threads.cs | 2 +- .../Debugger.Core/Project/Src/Threads/Process.cs | 6 +++--- .../Project/Src/Threads/SourcecodeSegment.cs | 2 +- .../Debugger.Core/Project/Src/Threads/Stepper.cs | 2 +- .../Debugger.Core/Project/Src/Threads/Thread.cs | 10 +++++----- .../Project/Src/Variables/ArrayValue.cs | 4 ++-- .../Project/Src/Variables/Evals/Eval.cs | 2 +- .../Project/Src/Variables/Evals/NDebugger-Evals.cs | 2 +- .../Project/Src/Variables/NullValue.cs | 2 +- .../Project/Src/Variables/ObjectValue.cs | 12 ++++++------ .../Project/Src/Variables/PrimitiveValue.cs | 10 +++++----- .../Project/Src/Variables/PropertyVariable.cs | 2 +- .../Project/Src/Variables/UnavailableValue.cs | 2 +- .../Debugger.Core/Project/Src/Variables/Value.cs | 14 +++++++------- .../Project/Src/Variables/Variable.cs | 2 +- .../Project/Src/Variables/VariableCollection.cs | 2 +- 28 files changed, 77 insertions(+), 73 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs index a39580585d..0f84fae073 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs @@ -10,7 +10,7 @@ using System.Diagnostics.SymbolStore; using System.Collections; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { @@ -100,7 +100,7 @@ namespace Debugger public override bool Equals(object obj) { - return base.Equals(obj) || corBreakpoint == obj; + return base.Equals(obj) || corBreakpoint == (obj as ICorDebugFunctionBreakpoint); } public override int GetHashCode() @@ -134,7 +134,8 @@ namespace Debugger hadBeenSet = true; corBreakpoint.Activate(enabled?1:0); - pBreakpoint = Marshal.GetComInterfaceForObject(corBreakpoint, typeof(ICorDebugFunctionBreakpoint)); + pBreakpoint = Marshal.GetComInterfaceForObject(corBreakpoint.WrappedObject, typeof(Debugger.Interop.CorDebug.ICorDebugFunctionBreakpoint)); + OnBreakpointStateChanged(); return true; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs index 0e43245a11..36d0a90822 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs @@ -9,7 +9,7 @@ using System; using System.Runtime.InteropServices; using System.Collections.Generic; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; namespace Debugger @@ -60,7 +60,7 @@ namespace Debugger internal Breakpoint GetBreakpoint(ICorDebugBreakpoint corBreakpoint) { foreach(Breakpoint breakpoint in breakpointCollection) { - if (breakpoint == corBreakpoint) { + if (breakpoint.Equals(corBreakpoint)) { return breakpoint; } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs index 51990dfd97..8da2e43445 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs @@ -185,7 +185,8 @@ namespace Debugger return Marshal.PtrToStringAuto((IntPtr)param); } // Marshal a COM object - return Marshal.GetTypedObjectForIUnknown((IntPtr)param, outputType); + object comObject = Marshal.GetObjectForIUnknown(param); + return Activator.CreateInstance(outputType, comObject); } /// diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs index 3aaca0c557..31f4c95623 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs @@ -15,7 +15,7 @@ using System; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { @@ -473,10 +473,10 @@ namespace Debugger public void MDANotification(ICorDebugController c, ICorDebugThread t, ICorDebugMDA mda) { - if (c is ICorDebugAppDomain) { - EnterCallback("MDANotification", (ICorDebugAppDomain)c); - } else if (c is ICorDebugProcess){ - EnterCallback("MDANotification", (ICorDebugProcess)c); + if (c.Is()) { + EnterCallback("MDANotification", c.CastTo()); + } else if (c.Is()){ + EnterCallback("MDANotification", c.CastTo()); } else { throw new System.Exception("Unknown callback argument"); } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs index 2e96fdb8bc..b82d1c6059 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs @@ -11,7 +11,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; // Regular expresion: // ^{\t*}{(:Ll| )*{:i} *\(((.# {:i}, |\))|())^6\)*}\n\t*\{(.|\n)@\t\} @@ -23,7 +23,7 @@ using Debugger.Interop.CorDebug; namespace Debugger { - class ManagedCallbackProxy :ICorDebugManagedCallback, ICorDebugManagedCallback2 + class ManagedCallbackProxy : Debugger.Interop.CorDebug.ICorDebugManagedCallback, Debugger.Interop.CorDebug.ICorDebugManagedCallback2 { NDebugger debugger; ManagedCallback realCallback; @@ -52,7 +52,7 @@ namespace Debugger MTA2STA.MarshalIntPtrTo(pAppDomain), MTA2STA.MarshalIntPtrTo(pThread), MTA2STA.MarshalIntPtrTo(pStepper), - reason + (CorDebugStepReason)reason ); }); } @@ -357,7 +357,7 @@ namespace Debugger }); } - public void Exception(IntPtr pAppDomain, IntPtr pThread, IntPtr pFrame, uint nOffset, CorDebugExceptionCallbackType dwEventType, uint dwFlags) + public void Exception(IntPtr pAppDomain, IntPtr pThread, IntPtr pFrame, uint nOffset, Debugger.Interop.CorDebug.CorDebugExceptionCallbackType dwEventType, uint dwFlags) { Call(delegate { realCallback.Exception2( @@ -365,19 +365,19 @@ namespace Debugger MTA2STA.MarshalIntPtrTo(pThread), MTA2STA.MarshalIntPtrTo(pFrame), nOffset, - dwEventType, + (CorDebugExceptionCallbackType)dwEventType, dwFlags ); }); } - public void ExceptionUnwind(IntPtr pAppDomain, IntPtr pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags) + public void ExceptionUnwind(IntPtr pAppDomain, IntPtr pThread, Debugger.Interop.CorDebug.CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags) { Call(delegate { realCallback.ExceptionUnwind( MTA2STA.MarshalIntPtrTo(pAppDomain), MTA2STA.MarshalIntPtrTo(pThread), - dwEventType, + (CorDebugExceptionUnwindCallbackType)dwEventType, dwFlags ); }); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs index 5f89265a47..b8500032dc 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs @@ -11,7 +11,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; using System.Collections.Generic; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs index b10a5e4758..13c4500349 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs @@ -11,7 +11,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; using System.Collections.Generic; @@ -105,13 +105,15 @@ namespace Debugger } this.debuggeeVersion = version; - NativeMethods.CreateDebuggingInterfaceFromVersion(3, version, out corDebug); + Debugger.Interop.CorDebug.ICorDebug rawCorDebug; + NativeMethods.CreateDebuggingInterfaceFromVersion(3, version, out rawCorDebug); + corDebug = new ICorDebug(rawCorDebug); managedCallback = new ManagedCallback(this); managedCallbackProxy = new ManagedCallbackProxy(managedCallback); corDebug.Initialize(); - corDebug.SetManagedHandler(managedCallbackProxy); + corDebug.SetManagedHandler(new ICorDebugManagedCallback(managedCallbackProxy)); localVariables.Updating += OnUpdatingLocalVariables; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs index 027af8b1d6..264d1b0784 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs @@ -10,7 +10,7 @@ using System.IO; using System.Diagnostics.SymbolStore; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; namespace Debugger @@ -117,8 +117,8 @@ namespace Debugger public bool JMCStatus { set { uint unused = 0; - if (corModule is ICorDebugModule2) { // Is the debuggee .NET 2.0? - ((ICorDebugModule2)corModule).SetJMCStatus(value?1:0, 0, ref unused); + if (corModule.Is()) { // Is the debuggee .NET 2.0? + (corModule.CastTo()).SetJMCStatus(value?1:0, 0, ref unused); } } } @@ -186,8 +186,8 @@ namespace Debugger public void ApplyChanges(byte[] metadata, byte[] il) { - if (corModule is ICorDebugModule2) { // Is the debuggee .NET 2.0? - (corModule as ICorDebugModule2).ApplyChanges((uint)metadata.Length, metadata, (uint)il.Length, il); + if (corModule.Is()) { // Is the debuggee .NET 2.0? + (corModule.CastTo()).ApplyChanges((uint)metadata.Length, metadata, (uint)il.Length, il); } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/NDebugger-Modules.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/NDebugger-Modules.cs index 5884ff54e7..8b11eff5d5 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/NDebugger-Modules.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/NDebugger-Modules.cs @@ -8,7 +8,7 @@ using System; using System.Collections.Generic; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs index faca9b37c2..938a5c1439 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs @@ -10,7 +10,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; namespace Debugger diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs index 5bd09176c6..4393318415 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs @@ -10,7 +10,7 @@ using System.Diagnostics.SymbolStore; using System.Runtime.InteropServices; using System.Threading; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; using System.Collections.Generic; @@ -203,9 +203,9 @@ namespace Debugger if (stepIn) { CorILFrame.CreateStepper(out stepper); - if (stepper is ICorDebugStepper2) { // Is the debuggee .NET 2.0? + if (stepper.Is()) { // Is the debuggee .NET 2.0? stepper.SetUnmappedStopMask(CorDebugUnmappedStop.STOP_NONE); - (stepper as ICorDebugStepper2).SetJMC(1 /* true */); + (stepper.CastTo()).SetJMC(1 /* true */); } fixed (int* ranges = nextSt.StepRanges) { @@ -220,9 +220,9 @@ namespace Debugger CorILFrame.CreateStepper(out stepper); - if (stepper is ICorDebugStepper2) { // Is the debuggee .NET 2.0? + if (stepper.Is()) { // Is the debuggee .NET 2.0? stepper.SetUnmappedStopMask(CorDebugUnmappedStop.STOP_NONE); - (stepper as ICorDebugStepper2).SetJMC(1 /* true */); + (stepper.CastTo()).SetJMC(1 /* true */); } fixed (int* ranges = nextSt.StepRanges) { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs index 6ac9880898..b39f647906 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs @@ -9,7 +9,7 @@ using System; using System.Collections.Generic; using System.Text; using System.Threading; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs index 869fdce40b..125173b704 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs @@ -8,7 +8,7 @@ using System; using System.Collections.Generic; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs index 2992ed253c..88620e395f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs @@ -10,7 +10,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; namespace Debugger @@ -87,10 +87,10 @@ namespace Debugger { debugger.TraceMessage("Executing " + filename); - _SECURITY_ATTRIBUTES secAttr = new _SECURITY_ATTRIBUTES(); + Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES secAttr = new Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES(); secAttr.bInheritHandle = 0; secAttr.lpSecurityDescriptor = IntPtr.Zero; - secAttr.nLength = (uint)sizeof(_SECURITY_ATTRIBUTES); //=12? + secAttr.nLength = (uint)sizeof(Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES); //=12? uint[] processStartupInfo = new uint[17]; processStartupInfo[0] = sizeof(uint) * 17; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/SourcecodeSegment.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/SourcecodeSegment.cs index 84394399f3..bf04f567a4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/SourcecodeSegment.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/SourcecodeSegment.cs @@ -8,7 +8,7 @@ using System; using System.Diagnostics.SymbolStore; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Stepper.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Stepper.cs index 7de8f9567e..c0c51c606f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Stepper.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Stepper.cs @@ -7,7 +7,7 @@ using System; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs index 165c02b8e4..d06021be2f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs @@ -10,7 +10,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; namespace Debugger @@ -141,8 +141,8 @@ namespace Debugger public void InterceptCurrentException() { - if (corThread is ICorDebugThread2) { // Is the debuggee .NET 2.0? - ((ICorDebugThread2)corThread).InterceptCurrentException(LastFunction.CorILFrame); + if (corThread.Is()) { // Is the debuggee .NET 2.0? + corThread.CastTo().InterceptCurrentException(LastFunction.CorILFrame.CastTo()); } process.Continue(); } @@ -297,8 +297,8 @@ namespace Debugger Function function = null; try { - if (corFrames[0] is ICorDebugILFrame) { - function = new Function(this, chainIndex, frameIndex, (ICorDebugILFrame)corFrames[0]); + if (corFrames[0].Is()) { + function = new Function(this, chainIndex, frameIndex, corFrames[0].CastTo()); } } catch (COMException) { // TODO diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs index 3777676a5b..34c6aa6853 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs @@ -10,7 +10,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; //TODO: Support for lower bound @@ -57,7 +57,7 @@ namespace Debugger internal unsafe ArrayValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) { - corArrayValue = (ICorDebugArrayValue)this.corValue; + corArrayValue = this.corValue.CastTo(); uint corElementTypeRaw; corArrayValue.GetElementType(out corElementTypeRaw); corElementType = (CorElementType)corElementTypeRaw; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs index 038147fe32..e8f2eaed70 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs @@ -10,7 +10,7 @@ using System.Collections; using System.Runtime.InteropServices; using Debugger; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; namespace Debugger diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs index 46e723df80..b09bbff6b5 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs @@ -8,7 +8,7 @@ using System; using System.Collections.Generic; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs index c3b77974b4..ee7b084b93 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs @@ -8,7 +8,7 @@ using System; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs index 565d7bef51..48fa740e64 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; using Debugger.Interop.MetaData; namespace Debugger @@ -69,7 +69,7 @@ namespace Debugger internal ICorDebugHandleValue SoftReference { get { - ICorDebugHeapValue2 heapValue = this.CorValue as ICorDebugHeapValue2; + ICorDebugHeapValue2 heapValue = this.CorValue.As(); if (heapValue == null) { // TODO: Investigate return null; } @@ -99,7 +99,7 @@ namespace Debugger internal unsafe ObjectValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) { - ((ICorDebugObjectValue)this.corValue).GetClass(out corClass); + this.corValue.CastTo().GetClass(out corClass); InitObjectVariable(); } @@ -195,7 +195,7 @@ namespace Debugger if (method.IsStatic) { return new ICorDebugValue[] {}; } else { - return new ICorDebugValue[] {((ObjectValue)getter()).SoftReference}; + return new ICorDebugValue[] {((ObjectValue)getter()).SoftReference.CastTo()}; } }); } @@ -212,7 +212,7 @@ namespace Debugger // Current frame is used to resolve context specific static values (eg. ThreadStatic) ICorDebugFrame curFrame = null; if (debugger.CurrentThread != null && debugger.CurrentThread.LastFunction != null && debugger.CurrentThread.LastFunction.CorILFrame != null) { - curFrame = debugger.CurrentThread.LastFunction.CorILFrame; + curFrame = debugger.CurrentThread.LastFunction.CorILFrame.CastTo(); } try { @@ -220,7 +220,7 @@ namespace Debugger if (field.IsStatic) { corClass.GetStaticFieldValue(field.Token, curFrame, out fieldValue); } else { - ((ICorDebugObjectValue)val.CorValue).GetFieldValue(corClass, field.Token, out fieldValue); + (val.CorValue.CastTo()).GetFieldValue(corClass, field.Token, out fieldValue); } return Value.CreateValue(debugger, fieldValue); } catch { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs index c4989fd526..ab33908dd9 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs @@ -9,7 +9,7 @@ using System; using System.ComponentModel; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { @@ -32,7 +32,7 @@ namespace Debugger IntPtr pString = Marshal.AllocHGlobal(2); // For some reason this function does not accept IntPtr.Zero - ((ICorDebugStringValue)corValue).GetString(pStringLenght, + (corValue.CastTo()).GetString(pStringLenght, out pStringLenght, pString); // Re-allocate string buffer @@ -41,7 +41,7 @@ namespace Debugger pStringLenght++; pString = Marshal.AllocHGlobal((int)pStringLenght * 2); - ((ICorDebugStringValue)corValue).GetString(pStringLenght, + (corValue.CastTo()).GetString(pStringLenght, out pStringLenght, pString); @@ -53,7 +53,7 @@ namespace Debugger object retValue; IntPtr pValue = Marshal.AllocHGlobal(8); - ((ICorDebugGenericValue)corValue).GetValue(pValue); + (corValue.CastTo()).GetValue(pValue); switch(CorType) { case CorElementType.BOOLEAN: retValue = *((System.Boolean*)pValue); break; @@ -107,7 +107,7 @@ namespace Debugger case CorElementType.U: *((uint*)pValue) = (uint)newValue; break; default: throw new NotSupportedException(); } - ((ICorDebugGenericValue)corValue).SetValue(pValue); + (corValue.CastTo()).SetValue(pValue); Marshal.FreeHGlobal(pValue); } OnValueChanged(); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs index 7bfbe84427..109239235d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs @@ -7,7 +7,7 @@ using System; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs index 6d91d95130..45ca0202f8 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs @@ -8,7 +8,7 @@ using System; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs index e666028f46..1bf29d4255 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs @@ -9,7 +9,7 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { @@ -160,13 +160,13 @@ namespace Debugger internal static ICorDebugValue DereferenceUnbox(ICorDebugValue corValue) { - if (corValue is ICorDebugReferenceValue) { + if (corValue.Is()) { int isNull; - ((ICorDebugReferenceValue)corValue).IsNull(out isNull); + (corValue.CastTo()).IsNull(out isNull); if (isNull == 0) { ICorDebugValue dereferencedValue; try { - ((ICorDebugReferenceValue)corValue).Dereference(out dereferencedValue); + (corValue.CastTo()).Dereference(out dereferencedValue); } catch { // Error during dereferencing return null; @@ -177,10 +177,10 @@ namespace Debugger } } - if (corValue is ICorDebugBoxValue) { + if (corValue.Is()) { ICorDebugObjectValue corUnboxedValue; - ((ICorDebugBoxValue)corValue).GetObject(out corUnboxedValue); - return DereferenceUnbox(corUnboxedValue); // Try again + (corValue.CastTo()).GetObject(out corUnboxedValue); + return DereferenceUnbox(corUnboxedValue.CastTo()); // Try again } return corValue; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs index 49bacb768e..76a1428912 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs @@ -7,7 +7,7 @@ using System; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs index ef7460acb1..c41fd9e1bb 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs @@ -9,7 +9,7 @@ using System; using System.Collections; using System.Collections.Generic; -using Debugger.Interop.CorDebug; +using Debugger.Wrappers.CorDebug; namespace Debugger {