From 7a40b626606dc76da9e7bf68308cda74adcd77b7 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 27 May 2009 19:06:11 +0000 Subject: [PATCH] Debugger now supports debugging IronPython code. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4153 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Debugger.Core.csproj | 5 --- .../Project/Src/Control/Module.cs | 12 ++++++ .../Project/Src/Internal/ManagedCallback.cs | 11 ++++- .../ICorDebugEditAndContinueSnapshot.cs | 1 + .../Src/Interop/CorDebug/ISequentialStream.cs | 25 ----------- .../Project/Src/Interop/CorDebug/IStream.cs | 43 ------------------- .../Src/Interop/CorDebug/_LARGE_INTEGER.cs | 21 --------- .../Src/Interop/CorDebug/_ULARGE_INTEGER.cs | 21 --------- .../Src/Interop/CorDebug/tagSTATSTG.cs | 33 -------------- .../Autogenerated/ISequentialStream.cs | 11 +++-- .../CorDebug/Autogenerated/IStream.cs | 28 ++++++------ .../Autogenerated/ISymUnmanagedBinder.cs | 4 +- .../Src/Wrappers/MetaData/MetaDataImport.cs | 10 +++++ 13 files changed, 54 insertions(+), 171 deletions(-) delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ISequentialStream.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/IStream.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_LARGE_INTEGER.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_ULARGE_INTEGER.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/tagSTATSTG.cs 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 91faa3ded9..4f43971575 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -184,15 +184,10 @@ - - - - - diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Module.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Module.cs index e06e4aae13..ff67cff702 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Module.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Module.cs @@ -190,6 +190,18 @@ namespace Debugger } } + public void UpdateSymbolsFromStream(Debugger.Wrappers.CorDebug.IStream pSymbolStream) + { + if (symReader != null) { + symReader.As().Destroy(); + } + + symReader = metaData.GetSymReader(pSymbolStream); + if (symReader != null) { + OnSymbolsLoaded(new ModuleEventArgs(this)); + } + } + /// Sets all code as being 'my code'. The code will be gradually /// set to not-user-code as encountered acording to stepping options public void ResetJustMyCodeStatus() 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 4b2cab3866..68f690050b 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 @@ -290,7 +290,16 @@ namespace Debugger public void UpdateModuleSymbols(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule, IStream pSymbolStream) { EnterCallback(PausedReason.Other, "UpdateModuleSymbols", pAppDomain); - + + foreach (Module module in process.Modules) { + if (module.CorModule == pModule) { + process.TraceMessage("UpdateModuleSymbols: Found module: " + pModule.Name); + module.UpdateSymbolsFromStream(pSymbolStream); + process.Debugger.SetBreakpointsInModule(module); + break; + } + } + ExitCallback(); } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugEditAndContinueSnapshot.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugEditAndContinueSnapshot.cs index 491614310c..3d10367f87 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugEditAndContinueSnapshot.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugEditAndContinueSnapshot.cs @@ -12,6 +12,7 @@ namespace Debugger.Interop.CorDebug using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; + using Debugger.Interop.CorSym; [ComImport, Guid("6DC3FA01-D7CB-11D2-8A95-0080C792E5D8"), InterfaceType((short) 1)] public interface ICorDebugEditAndContinueSnapshot diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ISequentialStream.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ISequentialStream.cs deleted file mode 100644 index 78a61b10f4..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ISequentialStream.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -// -// -// -// $Revision$ -// - -#pragma warning disable 108, 1591 - -namespace Debugger.Interop.CorDebug -{ - using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; - - [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); - } -} - -#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/IStream.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/IStream.cs deleted file mode 100644 index 4f1f0372c3..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/IStream.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// -// -// -// $Revision$ -// - -#pragma warning disable 108, 1591 - -namespace Debugger.Interop.CorDebug -{ - using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; - - [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); - } -} - -#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_LARGE_INTEGER.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_LARGE_INTEGER.cs deleted file mode 100644 index ee3218f2eb..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_LARGE_INTEGER.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -// -// -// -// $Revision$ -// - -#pragma warning disable 108, 1591 - -namespace Debugger.Interop.CorDebug -{ - using System.Runtime.InteropServices; - - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct _LARGE_INTEGER - { - public long QuadPart; - } -} - -#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_ULARGE_INTEGER.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_ULARGE_INTEGER.cs deleted file mode 100644 index 1b5f3706a8..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/_ULARGE_INTEGER.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -// -// -// -// $Revision$ -// - -#pragma warning disable 108, 1591 - -namespace Debugger.Interop.CorDebug -{ - using System.Runtime.InteropServices; - - [StructLayout(LayoutKind.Sequential, Pack=8)] - public struct _ULARGE_INTEGER - { - public ulong QuadPart; - } -} - -#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/tagSTATSTG.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/tagSTATSTG.cs deleted file mode 100644 index 51fc307fbc..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/tagSTATSTG.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -// -// -// -// $Revision$ -// - -#pragma warning disable 108, 1591 - -namespace Debugger.Interop.CorDebug -{ - using System; - using System.Runtime.InteropServices; - - [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/Wrappers/CorDebug/Autogenerated/ISequentialStream.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/ISequentialStream.cs index 079549ddf5..42a0fb06ab 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/ISequentialStream.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/ISequentialStream.cs @@ -1,4 +1,4 @@ -// +// // // // @@ -16,10 +16,9 @@ namespace Debugger.Wrappers.CorDebug public partial class ISequentialStream { + private Debugger.Interop.CorSym.ISequentialStream wrappedObject; - private Debugger.Interop.CorDebug.ISequentialStream wrappedObject; - - internal Debugger.Interop.CorDebug.ISequentialStream WrappedObject + internal Debugger.Interop.CorSym.ISequentialStream WrappedObject { get { @@ -27,13 +26,13 @@ namespace Debugger.Wrappers.CorDebug } } - public ISequentialStream(Debugger.Interop.CorDebug.ISequentialStream wrappedObject) + public ISequentialStream(Debugger.Interop.CorSym.ISequentialStream wrappedObject) { this.wrappedObject = wrappedObject; ResourceManager.TrackCOMObject(wrappedObject, typeof(ISequentialStream)); } - public static ISequentialStream Wrap(Debugger.Interop.CorDebug.ISequentialStream objectToWrap) + public static ISequentialStream Wrap(Debugger.Interop.CorSym.ISequentialStream objectToWrap) { if ((objectToWrap != null)) { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/IStream.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/IStream.cs index 6fa71ac9d0..889166a8c0 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/IStream.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/Autogenerated/IStream.cs @@ -1,4 +1,4 @@ -// +// // // // @@ -17,9 +17,9 @@ namespace Debugger.Wrappers.CorDebug public partial class IStream { - private Debugger.Interop.CorDebug.IStream wrappedObject; + private Debugger.Interop.CorSym.IStream wrappedObject; - internal Debugger.Interop.CorDebug.IStream WrappedObject + internal Debugger.Interop.CorSym.IStream WrappedObject { get { @@ -27,13 +27,13 @@ namespace Debugger.Wrappers.CorDebug } } - public IStream(Debugger.Interop.CorDebug.IStream wrappedObject) + public IStream(Debugger.Interop.CorSym.IStream wrappedObject) { this.wrappedObject = wrappedObject; ResourceManager.TrackCOMObject(wrappedObject, typeof(IStream)); } - public static IStream Wrap(Debugger.Interop.CorDebug.IStream objectToWrap) + public static IStream Wrap(Debugger.Interop.CorSym.IStream objectToWrap) { if ((objectToWrap != null)) { @@ -109,21 +109,21 @@ namespace Debugger.Wrappers.CorDebug return pcbWritten; } - public Debugger.Interop.CorDebug._ULARGE_INTEGER RemoteSeek(Debugger.Interop.CorDebug._LARGE_INTEGER dlibMove, uint dwOrigin) + public Debugger.Interop.CorSym._ULARGE_INTEGER RemoteSeek(Debugger.Interop.CorSym._LARGE_INTEGER dlibMove, uint dwOrigin) { - Debugger.Interop.CorDebug._ULARGE_INTEGER plibNewPosition; + Debugger.Interop.CorSym._ULARGE_INTEGER plibNewPosition; this.WrappedObject.RemoteSeek(dlibMove, dwOrigin, out plibNewPosition); return plibNewPosition; } - public void SetSize(Debugger.Interop.CorDebug._ULARGE_INTEGER libNewSize) + public void SetSize(Debugger.Interop.CorSym._ULARGE_INTEGER libNewSize) { this.WrappedObject.SetSize(libNewSize); } - public Debugger.Interop.CorDebug._ULARGE_INTEGER RemoteCopyTo(IStream pstm, Debugger.Interop.CorDebug._ULARGE_INTEGER cb, out Debugger.Interop.CorDebug._ULARGE_INTEGER pcbRead) + public Debugger.Interop.CorSym._ULARGE_INTEGER RemoteCopyTo(IStream pstm, Debugger.Interop.CorSym._ULARGE_INTEGER cb, out Debugger.Interop.CorSym._ULARGE_INTEGER pcbRead) { - Debugger.Interop.CorDebug._ULARGE_INTEGER pcbWritten; + Debugger.Interop.CorSym._ULARGE_INTEGER pcbWritten; this.WrappedObject.RemoteCopyTo(pstm.WrappedObject, cb, out pcbRead, out pcbWritten); return pcbWritten; } @@ -138,17 +138,17 @@ namespace Debugger.Wrappers.CorDebug this.WrappedObject.Revert(); } - public void LockRegion(Debugger.Interop.CorDebug._ULARGE_INTEGER libOffset, Debugger.Interop.CorDebug._ULARGE_INTEGER cb, uint dwLockType) + public void LockRegion(Debugger.Interop.CorSym._ULARGE_INTEGER libOffset, Debugger.Interop.CorSym._ULARGE_INTEGER cb, uint dwLockType) { this.WrappedObject.LockRegion(libOffset, cb, dwLockType); } - public void UnlockRegion(Debugger.Interop.CorDebug._ULARGE_INTEGER libOffset, Debugger.Interop.CorDebug._ULARGE_INTEGER cb, uint dwLockType) + public void UnlockRegion(Debugger.Interop.CorSym._ULARGE_INTEGER libOffset, Debugger.Interop.CorSym._ULARGE_INTEGER cb, uint dwLockType) { this.WrappedObject.UnlockRegion(libOffset, cb, dwLockType); } - public void Stat(out Debugger.Interop.CorDebug.tagSTATSTG pstatstg, uint grfStatFlag) + public void Stat(out Debugger.Interop.CorSym.tagSTATSTG pstatstg, uint grfStatFlag) { this.WrappedObject.Stat(out pstatstg, grfStatFlag); } @@ -156,7 +156,7 @@ namespace Debugger.Wrappers.CorDebug public IStream Clone() { IStream ppstm; - Debugger.Interop.CorDebug.IStream out_ppstm; + Debugger.Interop.CorSym.IStream out_ppstm; this.WrappedObject.Clone(out out_ppstm); ppstm = IStream.Wrap(out_ppstm); return ppstm; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedBinder.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedBinder.cs index 174b70a585..61455a0b45 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedBinder.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedBinder.cs @@ -1,4 +1,4 @@ -// +// // // // @@ -100,7 +100,7 @@ namespace Debugger.Wrappers.CorSym return ISymUnmanagedReader.Wrap(this.WrappedObject.GetReaderForFile(importer, filename, searchPath)); } - public ISymUnmanagedReader GetReaderFromStream(object importer, IStream pstream) + public ISymUnmanagedReader GetReaderFromStream(object importer, Debugger.Wrappers.CorDebug.IStream pstream) { return ISymUnmanagedReader.Wrap(this.WrappedObject.GetReaderFromStream(importer, pstream.WrappedObject)); } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs index 1bad327b48..f0053e5dae 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs @@ -41,6 +41,16 @@ namespace Debugger.Wrappers.MetaData } } + public ISymUnmanagedReader GetSymReader(Debugger.Wrappers.CorDebug.IStream stream) + { + try { + ISymUnmanagedBinder symBinder = new ISymUnmanagedBinder(new Debugger.Interop.CorSym.CorSymBinder_SxSClass()); + return symBinder.GetReaderFromStream(metaData, stream); + } catch { + return null; + } + } + ~MetaDataImport() { Dispose();