diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj index 3db8f23045..727d9bed6c 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -74,6 +74,7 @@ + @@ -86,7 +87,7 @@ - + diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Eval.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Eval.cs index 28acc76e12..4d1d94e8f4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Eval.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Eval.cs @@ -11,7 +11,6 @@ using System.Runtime.InteropServices; using Debugger.MetaData; using Debugger.Interop.CorDebug; -using CorElementType = Debugger.Interop.CorDebug.CorElementType; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/MTA2STA.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/MTA2STA.cs index a685130b9d..b925bea63e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/MTA2STA.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/MTA2STA.cs @@ -212,7 +212,8 @@ namespace Debugger.Internal } // Marshal a COM object object comObject = Marshal.GetObjectForIUnknown(param); - return Activator.CreateInstance(outputType, comObject); + Debugger.Interop.TrackedComObjects.Track(comObject); + return comObject; } /// diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs index 7505154cca..2ea7ee88d8 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs @@ -12,12 +12,10 @@ // Replace with: // \1\2\n\1{\n\1\tEnterCallback(PausedReason.Other, "\3");\n\1\t\n\1\tExitCallback_Continue();\n\1} +using Debugger.Interop; using System; using System.Runtime.InteropServices; using Debugger.Interop.CorDebug; -using CorDebugStepReason = Debugger.Interop.CorDebug.CorDebugStepReason; -using CorDebugExceptionCallbackType = Debugger.Interop.CorDebug.CorDebugExceptionCallbackType; -using CorDebugExceptionUnwindCallbackType = Debugger.Interop.CorDebug.CorDebugExceptionUnwindCallbackType; namespace Debugger.Internal { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackProxy.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackProxy.cs index afc37c4514..e281290584 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackProxy.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackProxy.cs @@ -7,10 +7,8 @@ using System; using System.Windows.Forms; +using Debugger.Interop; using Debugger.Interop.CorDebug; -using CorDebugStepReason = Debugger.Interop.CorDebug.CorDebugStepReason; -using CorDebugExceptionCallbackType = Debugger.Interop.CorDebug.CorDebugExceptionCallbackType; -using CorDebugExceptionUnwindCallbackType = Debugger.Interop.CorDebug.CorDebugExceptionUnwindCallbackType; // Regular expresion: // ^{\t*}{(:Ll| )*{:i} *\(((.# {:i}, |\))|())^6\)*}\n\t*\{(.|\n)@\t\} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs index 0d2ebe05a9..3964a0f0ba 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs @@ -12,12 +12,10 @@ // Replace with: // \1\2\n\1{\n\1\tGetProcessCallbackInterface(\4).\3(\4, \5, \6, \7, \8, \9);\n\1} +using Debugger.Interop; using System; using System.Runtime.InteropServices; using Debugger.Interop.CorDebug; -using CorDebugStepReason = Debugger.Interop.CorDebug.CorDebugStepReason; -using CorDebugExceptionCallbackType = Debugger.Interop.CorDebug.CorDebugExceptionCallbackType; -using CorDebugExceptionUnwindCallbackType = Debugger.Interop.CorDebug.CorDebugExceptionUnwindCallbackType; namespace Debugger.Internal { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/Common.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/Common.cs new file mode 100644 index 0000000000..48534ee697 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/Common.cs @@ -0,0 +1,89 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Debugger.Interop +{ + // These are used in both CorDebug and CorSym + + [StructLayout(LayoutKind.Sequential, Pack=4)] + public struct _FILETIME + { + public uint dwLowDateTime; + public uint dwHighDateTime; + } + + [StructLayout(LayoutKind.Sequential, Pack=8)] + public struct _LARGE_INTEGER + { + public long QuadPart; + } + + [StructLayout(LayoutKind.Sequential, Pack=8)] + public struct _ULARGE_INTEGER + { + public ulong QuadPart; + } + + [ComImport, Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType((short) 1)] + public interface ISequentialStream + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); + } + + [ComImport, InterfaceType((short) 1), Guid("0000000C-0000-0000-C000-000000000046")] + public interface IStream : ISequentialStream + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __SetSize([In] _ULARGE_INTEGER libNewSize); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __RemoteCopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __Commit([In] uint grfCommitFlags); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __Revert(); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void __Clone([MarshalAs(UnmanagedType.Interface)] out IStream ppstm); + } + + [StructLayout(LayoutKind.Sequential, Pack=8)] + public struct tagSTATSTG + { + [MarshalAs(UnmanagedType.LPWStr)] + public string pwcsName; + public uint type; + public _ULARGE_INTEGER cbSize; + public _FILETIME mtime; + public _FILETIME ctime; + public _FILETIME atime; + public uint grfMode; + public uint grfLocksSupported; + public Guid clsid; + public uint grfStateBits; + public uint reserved; + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug.cs index 740053cb2c..b5474be9ed 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug.cs @@ -30,19 +30,6 @@ namespace Debugger.Interop.CorDebug public uint dwSubBuild; } - [StructLayout(LayoutKind.Sequential, Pack=4)] - public struct _FILETIME - { - public uint dwLowDateTime; - public uint dwHighDateTime; - } - - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct _LARGE_INTEGER - { - public long QuadPart; - } - [StructLayout(LayoutKind.Sequential, Pack=4)] public struct _SECURITY_ATTRIBUTES { @@ -51,12 +38,6 @@ namespace Debugger.Interop.CorDebug public int bInheritHandle; } - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct _ULARGE_INTEGER - { - public ulong QuadPart; - } - [StructLayout(LayoutKind.Sequential, Pack=4)] public struct COR_DEBUG_STEP_RANGE { @@ -1635,59 +1616,6 @@ namespace Debugger.Interop.CorDebug [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] void __Next([In] uint celt, [Out] IntPtr values, out uint pceltFetched); } - - [ComImport, Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType((short) 1)] - public interface ISequentialStream - { - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); - } - - [ComImport, Guid("0000000C-0000-0000-C000-000000000046"), InterfaceType((short) 1)] - public interface IStream : ISequentialStream - { - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __SetSize([In] _ULARGE_INTEGER libNewSize); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteCopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Commit([In] uint grfCommitFlags); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Revert(); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Clone([MarshalAs(UnmanagedType.Interface)] out IStream ppstm); - } - - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct tagSTATSTG - { - [MarshalAs(UnmanagedType.LPWStr)] - public string pwcsName; - public uint type; - public _ULARGE_INTEGER cbSize; - public _FILETIME mtime; - public _FILETIME ctime; - public _FILETIME atime; - public uint grfMode; - public uint grfLocksSupported; - public Guid clsid; - public uint grfStateBits; - public uint reserved; - } } #pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.cs index 25cc6bcf07..e131a51438 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.cs @@ -31,6 +31,11 @@ namespace Debugger.Interop.CorDebug return obj as T; } + static void ProcessOutParameter(object parameter) + { + TrackedComObjects.ProcessOutParameter(parameter); + } + // ICorDebugArrayValue public static unsafe uint[] GetDimensions(this ICorDebugArrayValue corArray) @@ -215,9 +220,7 @@ namespace Debugger.Interop.CorDebug public static bool HasQueuedCallbacks(this ICorDebugProcess corProcess) { - int pbQueued; - corProcess.HasQueuedCallbacks(null, out pbQueued); - return pbQueued != 0; + return corProcess.HasQueuedCallbacks(null) != 0; } // ICorDebugStepper diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.generated.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.generated.cs index e68fdbab79..1fb45dc59d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.generated.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebugExtensionMethods.generated.cs @@ -13,10 +13,6 @@ namespace Debugger.Interop.CorDebug { public static partial class CorDebugExtensionMethods { - static void ProcessOutParameter(object parameter) - { - } - public static void CanLaunchOrAttach(this CorDebugClass instance, uint dwProcessId, int win32DebuggingEnabled) { instance.__CanLaunchOrAttach(dwProcessId, win32DebuggingEnabled); @@ -386,7 +382,7 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static uint GetType(this ICorDebugArrayValue instance) + public static uint GetTheType(this ICorDebugArrayValue instance) { uint pType; instance.__GetType(out pType); @@ -557,7 +553,7 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static uint GetType(this ICorDebugBoxValue instance) + public static uint GetTheType(this ICorDebugBoxValue instance) { uint pType; instance.__GetType(out pType); @@ -908,7 +904,7 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static uint GetType(this ICorDebugContext instance) + public static uint GetTheType(this ICorDebugContext instance) { uint pType; instance.__GetType(out pType); @@ -1469,7 +1465,7 @@ namespace Debugger.Interop.CorDebug return pnOffset; } - public static uint GetType(this ICorDebugGenericValue instance) + public static uint GetTheType(this ICorDebugGenericValue instance) { uint pType; instance.__GetType(out pType); @@ -1508,7 +1504,7 @@ namespace Debugger.Interop.CorDebug instance.__SetValue(pFrom); } - public static uint GetType(this ICorDebugHandleValue instance) + public static uint GetTheType(this ICorDebugHandleValue instance) { uint pType; instance.__GetType(out pType); @@ -1585,7 +1581,7 @@ namespace Debugger.Interop.CorDebug instance.__Dispose(); } - public static uint GetType(this ICorDebugHeapValue instance) + public static uint GetTheType(this ICorDebugHeapValue instance) { uint pType; instance.__GetType(out pType); @@ -2400,7 +2396,7 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static uint GetType(this ICorDebugObjectValue instance) + public static uint GetTheType(this ICorDebugObjectValue instance) { uint pType; instance.__GetType(out pType); @@ -2747,7 +2743,7 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static uint GetType(this ICorDebugReferenceValue instance) + public static uint GetTheType(this ICorDebugReferenceValue instance) { uint pType; instance.__GetType(out pType); @@ -2917,7 +2913,7 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static uint GetType(this ICorDebugStringValue instance) + public static uint GetTheType(this ICorDebugStringValue instance) { uint pType; instance.__GetType(out pType); @@ -3156,7 +3152,7 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static uint GetType(this ICorDebugType instance) + public static uint GetTheType(this ICorDebugType instance) { uint ty; instance.__GetType(out ty); @@ -3248,7 +3244,7 @@ namespace Debugger.Interop.CorDebug instance.__DebugEvent(pDebugEvent, fOutOfBand); } - public static uint GetType(this ICorDebugValue instance) + public static uint GetTheType(this ICorDebugValue instance) { uint pType; instance.__GetType(out pType); @@ -3337,87 +3333,5 @@ namespace Debugger.Interop.CorDebug return pceltFetched; } - public static void RemoteRead(this ISequentialStream instance, out byte pv, uint cb, out uint pcbRead) - { - instance.__RemoteRead(out pv, cb, out pcbRead); - ProcessOutParameter(pv); - } - - public static uint RemoteWrite(this ISequentialStream instance, ref byte pv, uint cb) - { - uint pcbWritten; - instance.__RemoteWrite(ref pv, cb, out pcbWritten); - ProcessOutParameter(pv); - return pcbWritten; - } - - public static void RemoteRead(this IStream instance, out byte pv, uint cb, out uint pcbRead) - { - instance.__RemoteRead(out pv, cb, out pcbRead); - ProcessOutParameter(pv); - } - - public static uint RemoteWrite(this IStream instance, ref byte pv, uint cb) - { - uint pcbWritten; - instance.__RemoteWrite(ref pv, cb, out pcbWritten); - ProcessOutParameter(pv); - return pcbWritten; - } - - public static _ULARGE_INTEGER RemoteSeek(this IStream instance, _LARGE_INTEGER dlibMove, uint dwOrigin) - { - _ULARGE_INTEGER plibNewPosition; - instance.__RemoteSeek(dlibMove, dwOrigin, out plibNewPosition); - ProcessOutParameter(plibNewPosition); - return plibNewPosition; - } - - public static void SetSize(this IStream instance, _ULARGE_INTEGER libNewSize) - { - instance.__SetSize(libNewSize); - } - - public static void RemoteCopyTo(this IStream instance, IStream pstm, _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten) - { - instance.__RemoteCopyTo(pstm, cb, out pcbRead, out pcbWritten); - ProcessOutParameter(pcbRead); - ProcessOutParameter(pcbWritten); - } - - public static void Commit(this IStream instance, uint grfCommitFlags) - { - instance.__Commit(grfCommitFlags); - } - - public static void Revert(this IStream instance) - { - instance.__Revert(); - } - - public static void LockRegion(this IStream instance, _ULARGE_INTEGER libOffset, _ULARGE_INTEGER cb, uint dwLockType) - { - instance.__LockRegion(libOffset, cb, dwLockType); - } - - public static void UnlockRegion(this IStream instance, _ULARGE_INTEGER libOffset, _ULARGE_INTEGER cb, uint dwLockType) - { - instance.__UnlockRegion(libOffset, cb, dwLockType); - } - - public static void Stat(this IStream instance, out tagSTATSTG pstatstg, uint grfStatFlag) - { - instance.__Stat(out pstatstg, grfStatFlag); - ProcessOutParameter(pstatstg); - } - - public static IStream Clone(this IStream instance) - { - IStream ppstm; - instance.__Clone(out ppstm); - ProcessOutParameter(ppstm); - return ppstm; - } - } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.cs index b77a7b8121..934ef3e3f0 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.cs @@ -11,5 +11,9 @@ namespace Debugger.Interop.CorPublish { public static partial class CorPublishExtensionMethods { + static void ProcessOutParameter(object parameter) + { + TrackedComObjects.ProcessOutParameter(parameter); + } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.generated.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.generated.cs index 349ac72b7b..34687e3ace 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.generated.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorPublishExtensionMethods.generated.cs @@ -14,10 +14,6 @@ namespace Debugger.Interop.CorPublish { public static partial class CorPublishExtensionMethods { - static void ProcessOutParameter(object parameter) - { - } - public static ICorPublishEnum Clone(this CorpubPublishClass instance) { ICorPublishEnum ppEnum; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym.cs index 26c23e8947..9665abe4ec 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym.cs @@ -381,42 +381,6 @@ namespace Debugger.Interop.CorSym } - [ComImport, Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType((short) 1)] - public interface ISequentialStream - { - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); - } - - [ComImport, InterfaceType((short) 1), Guid("0000000C-0000-0000-C000-000000000046")] - public interface IStream : ISequentialStream - { - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __SetSize([In] _ULARGE_INTEGER libNewSize); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __RemoteCopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Commit([In] uint grfCommitFlags); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Revert(); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag); - [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void __Clone([MarshalAs(UnmanagedType.Interface)] out IStream ppstm); - } - [ComImport, InterfaceType((short) 1), Guid("AA544D42-28CB-11D3-BD22-0000F80849BD")] public interface ISymUnmanagedBinder { @@ -729,42 +693,6 @@ namespace Debugger.Interop.CorSym [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] void __DefineConstant2([In] IntPtr name, [In, MarshalAs(UnmanagedType.Struct)] object value, [In] uint sigToken); } - - [StructLayout(LayoutKind.Sequential, Pack=4)] - public struct _FILETIME - { - public uint dwLowDateTime; - public uint dwHighDateTime; - } - - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct _LARGE_INTEGER - { - public long QuadPart; - } - - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct _ULARGE_INTEGER - { - public ulong QuadPart; - } - - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct tagSTATSTG - { - [MarshalAs(UnmanagedType.LPWStr)] - public string pwcsName; - public uint type; - public _ULARGE_INTEGER cbSize; - public _FILETIME mtime; - public _FILETIME ctime; - public _FILETIME atime; - public uint grfMode; - public uint grfLocksSupported; - public Guid clsid; - public uint grfStateBits; - public uint reserved; - } } #pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.cs index 6fd06d1f17..a770db622c 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.cs @@ -12,6 +12,11 @@ namespace Debugger.Interop.CorSym { public static partial class CorSymExtensionMethods { + static void ProcessOutParameter(object parameter) + { + TrackedComObjects.ProcessOutParameter(parameter); + } + // ISymUnmanagedBinder public static ISymUnmanagedReader GetReaderForFile(this ISymUnmanagedBinder symBinder, object importer, string filename, string searchPath) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.generated.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.generated.cs index 1ef693789c..eb0f70912e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.generated.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSymExtensionMethods.generated.cs @@ -13,10 +13,6 @@ namespace Debugger.Interop.CorSym { public static partial class CorSymExtensionMethods { - static void ProcessOutParameter(object parameter) - { - } - public static ISymUnmanagedReader GetReaderForFile(this CorSymBinder_SxSClass instance, object importer, IntPtr filename, IntPtr searchPath) { ISymUnmanagedReader returnValue = instance.__GetReaderForFile(importer, filename, searchPath); @@ -493,88 +489,6 @@ namespace Debugger.Interop.CorSym instance.__UsingNamespace(fullName); } - public static void RemoteRead(this ISequentialStream instance, out byte pv, uint cb, out uint pcbRead) - { - instance.__RemoteRead(out pv, cb, out pcbRead); - ProcessOutParameter(pv); - } - - public static uint RemoteWrite(this ISequentialStream instance, ref byte pv, uint cb) - { - uint pcbWritten; - instance.__RemoteWrite(ref pv, cb, out pcbWritten); - ProcessOutParameter(pv); - return pcbWritten; - } - - public static void RemoteRead(this IStream instance, out byte pv, uint cb, out uint pcbRead) - { - instance.__RemoteRead(out pv, cb, out pcbRead); - ProcessOutParameter(pv); - } - - public static uint RemoteWrite(this IStream instance, ref byte pv, uint cb) - { - uint pcbWritten; - instance.__RemoteWrite(ref pv, cb, out pcbWritten); - ProcessOutParameter(pv); - return pcbWritten; - } - - public static _ULARGE_INTEGER RemoteSeek(this IStream instance, _LARGE_INTEGER dlibMove, uint dwOrigin) - { - _ULARGE_INTEGER plibNewPosition; - instance.__RemoteSeek(dlibMove, dwOrigin, out plibNewPosition); - ProcessOutParameter(plibNewPosition); - return plibNewPosition; - } - - public static void SetSize(this IStream instance, _ULARGE_INTEGER libNewSize) - { - instance.__SetSize(libNewSize); - } - - public static void RemoteCopyTo(this IStream instance, IStream pstm, _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten) - { - instance.__RemoteCopyTo(pstm, cb, out pcbRead, out pcbWritten); - ProcessOutParameter(pcbRead); - ProcessOutParameter(pcbWritten); - } - - public static void Commit(this IStream instance, uint grfCommitFlags) - { - instance.__Commit(grfCommitFlags); - } - - public static void Revert(this IStream instance) - { - instance.__Revert(); - } - - public static void LockRegion(this IStream instance, _ULARGE_INTEGER libOffset, _ULARGE_INTEGER cb, uint dwLockType) - { - instance.__LockRegion(libOffset, cb, dwLockType); - } - - public static void UnlockRegion(this IStream instance, _ULARGE_INTEGER libOffset, _ULARGE_INTEGER cb, uint dwLockType) - { - instance.__UnlockRegion(libOffset, cb, dwLockType); - } - - public static void Stat(this IStream instance, out tagSTATSTG pstatstg, uint grfStatFlag) - { - instance.__Stat(out pstatstg, grfStatFlag); - ProcessOutParameter(pstatstg); - } - - public static IStream Clone(this IStream instance) - { - IStream ppstm; - instance.__Clone(out ppstm); - ProcessOutParameter(ppstm); - return ppstm; - } - public static ISymUnmanagedReader GetReaderForFile(this ISymUnmanagedBinder instance, object importer, IntPtr filename, IntPtr searchPath) { ISymUnmanagedReader returnValue = instance.__GetReaderForFile(importer, filename, searchPath); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/MetaDataWrapper.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/MetaDataWrapper.cs index be8f1971c3..093c335b26 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/MetaDataWrapper.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/MetaDataWrapper.cs @@ -28,25 +28,25 @@ namespace Debugger.Interop.MetaData { Guid guid = new Guid("{ 0x7dac8207, 0xd3ae, 0x4c75, { 0x9b, 0x67, 0x92, 0x80, 0x1a, 0x49, 0x7d, 0x44 } }"); metaData = (IMetaDataImport)pModule.GetMetaDataInterface(ref guid); - ResourceManager.TrackCOMObject(metaData, typeof(IMetaDataImport)); + TrackedComObjects.Track(metaData); } public ISymUnmanagedReader GetSymReader(string fullname, string searchPath) { try { - // TODO: Track ISymUnmanagedBinder symBinder = new Debugger.Interop.CorSym.CorSymBinder_SxSClass(); + TrackedComObjects.Track(symBinder); return symBinder.GetReaderForFile(metaData, fullname, searchPath); } catch { return null; } } - public ISymUnmanagedReader GetSymReader(Debugger.Interop.CorSym.IStream stream) + public ISymUnmanagedReader GetSymReader(IStream stream) { try { - // TODO: Track ISymUnmanagedBinder symBinder = new Debugger.Interop.CorSym.CorSymBinder_SxSClass(); + TrackedComObjects.Track(symBinder); return symBinder.GetReaderFromStream(metaData, stream); } catch { return null; @@ -60,16 +60,15 @@ namespace Debugger.Interop.MetaData public void Dispose() { - if (metaData != null) { - ResourceManager.ReleaseCOMObject(metaData, typeof(IMetaDataImport)); + IMetaDataImport m = this.metaData; + if (m != null) { + Marshal.ReleaseComObject(m); metaData = null; } } - // CloseEnum, CountEnum and ResetEnum are not wrapped - public uint[] EnumCustomAttributes(uint token_Scope, uint token_TypeOfAttributes) { return EnumerateTokens(metaData.EnumCustomAttributes, token_Scope, token_TypeOfAttributes); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/ResourceManager.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/ResourceManager.cs deleted file mode 100644 index 7ea5b4fc57..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/ResourceManager.cs +++ /dev/null @@ -1,114 +0,0 @@ -// -// -// -// -// $Revision$ -// - -#pragma warning disable 1591 - -using Debugger.Internal; -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Debugger.Interop; - -namespace Debugger.Interop -{ - class TrackedObjectMetaData - { - public Type ObjectType; - public int RefCount; - - public TrackedObjectMetaData(Type objectType, int refCount) - { - this.ObjectType = objectType; - this.RefCount = refCount; - } - } - - public static class ResourceManager - { - static MTA2STA mta2sta = new MTA2STA(); - static bool trace = false; - static Dictionary trackedCOMObjects = new Dictionary(); - - public static bool TraceMessagesEnabled { - get { - return trace; - } - set { - trace = value; - } - } - - public static void TrackCOMObject(object comObject, Type type) - { - if (comObject == null || !Marshal.IsComObject(comObject)) { - if (trace) Trace("Will not be tracked: {0}", type.Name); - } else { - TrackedObjectMetaData metaData; - if (trackedCOMObjects.TryGetValue(comObject, out metaData)) { - metaData.RefCount += 1; - } else { - metaData = new TrackedObjectMetaData(type,1); - trackedCOMObjects.Add(comObject, metaData); - } - if (trace) Trace("AddRef {0,2}: {1}", metaData.RefCount, type.Name); - } - } - - public static void ReleaseCOMObject(object comObject, Type type) - { - // Ensure that the release is done synchronosly - try { - mta2sta.AsyncCall(delegate { - ReleaseCOMObjectInternal(comObject, type); - }); - } catch (InvalidOperationException) { - // This might happen when the application is shuting down - } - } - - static void ReleaseCOMObjectInternal(object comObject, Type type) - { - TrackedObjectMetaData metaData; - if (comObject != null && trackedCOMObjects.TryGetValue(comObject, out metaData)) { - metaData.RefCount -= 1; - if (metaData.RefCount == 0) { - Marshal.FinalReleaseComObject(comObject); - trackedCOMObjects.Remove(comObject); - } - if (trace) Trace("Release {0,2}: {1}", metaData.RefCount, type.Name); - } else { - if (trace) Trace("Was not tracked: {0}", type.Name); - } - } - - public static void ReleaseAllTrackedCOMObjects() - { - if (trace) Trace("Releasing {0} tracked COM objects... ", trackedCOMObjects.Count); - while(trackedCOMObjects.Count > 0) { - foreach (KeyValuePair pair in trackedCOMObjects) { - Marshal.FinalReleaseComObject(pair.Key); - if (trace) Trace(" * Releasing {0} ({1} references)", pair.Value.ObjectType.Name, pair.Value.RefCount); - trackedCOMObjects.Remove(pair.Key); - break; - } - } - if (trace) Trace(" * Done"); - } - - public static event EventHandler TraceMessage; - - static void Trace(string msg, params object[] pars) - { - if (TraceMessage != null && trace) { - string message = String.Format("COM({0,-3}): {1}", trackedCOMObjects.Count, String.Format(msg, pars)); - TraceMessage(null, new MessageEventArgs(null, message)); - } - } - } -} - -#pragma warning restore 1591 diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/TrackedComObjects.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/TrackedComObjects.cs new file mode 100644 index 0000000000..9dbe65dd4c --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/TrackedComObjects.cs @@ -0,0 +1,61 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 1591 + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Debugger.Interop +{ + public static class TrackedComObjects + { + static List objects = new List(); + + public static void ProcessOutParameter(object parameter) + { + if (parameter != null) { + if (Marshal.IsComObject(parameter)) { + Track(parameter); + } else if (parameter is Array) { + foreach(object elem in (Array)parameter) { + ProcessOutParameter(elem); + } + } + } + } + + public static void Track(object obj) + { + if (Marshal.IsComObject(obj)) { + lock(objects) { + objects.Add(new WeakReference(obj)); + } + } + } + + public static int ReleaseAll() + { + lock(objects) { + int count = 0; + foreach(WeakReference weakRef in objects) { + object obj = weakRef.Target; + if (obj != null) { + Marshal.FinalReleaseComObject(obj); + count++; + } + } + objects.Clear(); + objects.TrimExcess(); + return count; + } + } + } +} + +#pragma warning restore 1591 diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/MetaData/DebugType.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/MetaData/DebugType.cs index ee49bc0beb..2d0e599145 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/MetaData/DebugType.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/MetaData/DebugType.cs @@ -15,8 +15,6 @@ using Debugger.Interop.CorDebug; using Debugger.Interop.MetaData; using ICSharpCode.NRefactory.Ast; using Mono.Cecil.Signatures; -using CorElementType = Debugger.Interop.CorDebug.CorElementType; -using CorTokenType = Debugger.Interop.MetaData.CorTokenType; namespace Debugger.MetaData { @@ -951,7 +949,7 @@ namespace Debugger.MetaData public static DebugType CreateFromCorType(AppDomain appDomain, ICorDebugType corType) { // Convert primitive type to class - CorElementType corElemType = (CorElementType)(corType.GetType()); + CorElementType corElemType = (CorElementType)(corType.GetTheType()); Type primitiveType = CorElementTypeToManagedType(corElemType); if (primitiveType != null) { corType = CreateFromType(appDomain.Mscorlib, primitiveType).CorType; @@ -971,7 +969,7 @@ namespace Debugger.MetaData DateTime startTime = Util.HighPrecisionTimer.Now; this.corType = corType; - this.corElementType = (CorElementType)corType.GetType(); + this.corElementType = (CorElementType)corType.GetTheType(); // Loading might access the type again loadedTypes[corType] = this; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Module.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Module.cs index 00133970d0..1a31f95c05 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Module.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Module.cs @@ -5,12 +5,13 @@ // $Revision$ // +using Debugger.Interop; using System; using System.Collections.Generic; -using Debugger.MetaData; using Debugger.Interop.CorDebug; using Debugger.Interop.CorSym; using Debugger.Interop.MetaData; +using Debugger.MetaData; namespace Debugger { @@ -198,7 +199,7 @@ namespace Debugger } } - public void UpdateSymbolsFromStream(Debugger.Interop.CorDebug.IStream pSymbolStream) + public void UpdateSymbolsFromStream(IStream pSymbolStream) { if (symReader != null) { symReader.As().Destroy(); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/NDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/NDebugger.cs index 39762425af..ab724dceb4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/NDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/NDebugger.cs @@ -72,11 +72,6 @@ namespace Debugger } else { mta2sta.CallMethod = CallMethod.DirectCall; } - - Wrappers.ResourceManager.TraceMessagesEnabled = false; - Wrappers.ResourceManager.TraceMessage += delegate (object s, MessageEventArgs e) { - TraceMessage(e.Message); - }; } /// @@ -119,7 +114,8 @@ namespace Debugger } this.debuggeeVersion = debuggeeVersion; - corDebug = new ICorDebug(NativeMethods.CreateDebuggingInterfaceFromVersion(3, debuggeeVersion)); + corDebug = NativeMethods.CreateDebuggingInterfaceFromVersion(3, debuggeeVersion); + TrackedComObjects.Track(corDebug); managedCallbackSwitch = new ManagedCallbackSwitch(this); managedCallbackProxy = new ManagedCallbackProxy(this, managedCallbackSwitch); @@ -143,9 +139,9 @@ namespace Debugger TraceMessage("ICorDebug terminated"); - Wrappers.ResourceManager.ReleaseAllTrackedCOMObjects(); + int released = TrackedComObjects.ReleaseAll(); - TraceMessage("Tracked COM objects released"); + TraceMessage("Released " + released + " tracked COM objects"); } /// diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/StackFrame.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/StackFrame.cs index f1eb186749..3e26f0301d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/StackFrame.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/StackFrame.cs @@ -12,7 +12,6 @@ using System.Runtime.InteropServices; using Debugger.MetaData; using Debugger.Interop.CorDebug; using Debugger.Interop.MetaData; -using CorElementType = Debugger.Interop.CorDebug.CorElementType; namespace Debugger { @@ -293,7 +292,7 @@ namespace Debugger throw; } // This can be 'by ref' for value types - if (corValue.GetType() == (uint)CorElementType.BYREF) { + if (corValue.GetTheType() == (uint)CorElementType.BYREF) { corValue = corValue.CastTo().Dereference(); } return corValue; @@ -341,7 +340,7 @@ namespace Debugger throw; } // Method arguments can be passed 'by ref' - if (corValue.GetType() == (uint)CorElementType.BYREF) { + if (corValue.GetTheType() == (uint)CorElementType.BYREF) { try { corValue = corValue.CastTo().Dereference(); } catch (COMException e) { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Stepper.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Stepper.cs index 225348e607..41a33d4b16 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Stepper.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Stepper.cs @@ -7,7 +7,6 @@ using System; using Debugger.Interop.CorDebug; -using CorDebugStepReason = Debugger.Interop.CorDebug.CorDebugStepReason; namespace Debugger { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Thread.cs index 7f87c1e15e..e13496cf51 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Thread.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Thread.cs @@ -292,13 +292,17 @@ namespace Debugger yield break; } + uint corChainIndex = CorThread.EnumerateChains().GetCount(); foreach(ICorDebugChain corChain in CorThread.EnumerateChains().GetEnumerator()) { + corChainIndex--; if (corChain.IsManaged() == 0) continue; // Only managed ones + uint corFrameIndex = corChain.EnumerateFrames().GetCount(); foreach(ICorDebugFrame corFrame in corChain.EnumerateFrames().GetEnumerator()) { + corFrameIndex--; if (!corFrame.Is()) continue; // Only IL frames StackFrame stackFrame; try { - stackFrame = new StackFrame(this, corFrame.CastTo(), corChain.Index, corFrame.Index); + stackFrame = new StackFrame(this, corFrame.CastTo(), corChainIndex, corFrameIndex); } catch (COMException) { // TODO continue; }; diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ControlFlow_Stepping.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ControlFlow_Stepping.cs index 6c4ce9c7e9..dcbf1fbcf7 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ControlFlow_Stepping.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ControlFlow_Stepping.cs @@ -115,8 +115,6 @@ namespace Debugger.Tests.TestPrograms #if TEST_CODE namespace Debugger.Tests { using NUnit.Framework; - using Debugger.Wrappers.CorDebug; - using Debugger.Wrappers.MetaData; public partial class DebuggerTests { diff --git a/src/Tools/ComExtensionMethodGenerator/ComExtensionMethodGenerator.cs b/src/Tools/ComExtensionMethodGenerator/ComExtensionMethodGenerator.cs index bc83b1fccb..068cf70d85 100644 --- a/src/Tools/ComExtensionMethodGenerator/ComExtensionMethodGenerator.cs +++ b/src/Tools/ComExtensionMethodGenerator/ComExtensionMethodGenerator.cs @@ -84,23 +84,23 @@ namespace ComExtensionMethodGenerator new NamespaceDeclaration(Namespace) { Children = extensionMethodsType.ToList() } ); - // Add the ProcessOutParameter method - if (ProcessOutParameter) { - extensionMethodsType.AddChild( - new MethodDeclaration() { - Modifier = Modifiers.Static, - TypeReference = new TypeReference("void", true), - Name = ProcessOutParameterMethodName, - Parameters = - new ParameterDeclarationExpression( - new TypeReference("object", true), - "parameter" - ).ToList(), - Body = new BlockStatement() - } - ); - extensionMethodsType.AddChild(new IdentifierExpression("\t\t\r\n")); - } +// // Add the ProcessOutParameter method +// if (ProcessOutParameter) { +// extensionMethodsType.AddChild( +// new MethodDeclaration() { +// Modifier = Modifiers.Static, +// TypeReference = new TypeReference("void", true), +// Name = ProcessOutParameterMethodName, +// Parameters = +// new ParameterDeclarationExpression( +// new TypeReference("object", true), +// "parameter" +// ).ToList(), +// Body = new BlockStatement() +// } +// ); +// extensionMethodsType.AddChild(new IdentifierExpression("\t\t\r\n")); +// } // Add the extesion methods foreach(NamespaceDeclaration ns in parser.CompilationUnit.Children.OfType()) { @@ -120,6 +120,9 @@ namespace ComExtensionMethodGenerator Console.WriteLine("Warning: {0}.{1} is missing prefix {2}.", type.Name, method.Name, MethodPrefix); hasWarnings = true; } + // HACK: GetType is used by System.Object + if (extensionMethod.Name == "GetType") + extensionMethod.Name = "GetTheType"; // Parameters extensionMethod.Parameters.Add(new ParameterDeclarationExpression(new TypeReference(type.Name), ThisParameterName)); foreach(ParameterDeclarationExpression param in method.Parameters) {