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 90c2838501..be34163e33 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -355,6 +355,14 @@ + + + + + + + + @@ -367,4 +375,4 @@ - \ No newline at end of file + 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 52240c03c1..52464e618f 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 @@ -6,7 +6,6 @@ // using System; -using System.Diagnostics.SymbolStore; using System.Collections; using System.Runtime.InteropServices; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedMethod.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedMethod.cs index 5539bc3156..edfdf3e728 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedMethod.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedMethod.cs @@ -35,7 +35,7 @@ namespace Debugger.Interop.CorSym [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] void GetSourceStartEnd([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0, SizeConst=2)] ISymUnmanagedDocument[] docs, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0, SizeConst=2)] uint[] lines, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0, SizeConst=2)] uint[] columns, out int pRetVal); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void GetSequencePoints([In] uint cPoints, out uint pcPoints, [In] ref uint offsets, [In, MarshalAs(UnmanagedType.Interface)] ref ISymUnmanagedDocument documents, [In] ref uint lines, [In] ref uint columns, [In] ref uint endLines, [In] ref uint endColumns); + void GetSequencePoints([In] uint cPoints, out uint pcPoints, [Out, MarshalAs(UnmanagedType.LPArray)] uint[] offsets, [Out, MarshalAs(UnmanagedType.LPArray)] ISymUnmanagedDocument[] documents, [Out, MarshalAs(UnmanagedType.LPArray)] uint[] lines, [Out, MarshalAs(UnmanagedType.LPArray)] uint[] columns, [Out, MarshalAs(UnmanagedType.LPArray)] uint[] endLines, [Out, MarshalAs(UnmanagedType.LPArray)] uint[] endColumns); } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedScope.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedScope.cs index cb32553be2..f563e25176 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedScope.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedScope.cs @@ -21,7 +21,7 @@ namespace Debugger.Interop.CorSym [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] ISymUnmanagedScope GetParent(); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void GetChildren([In] uint cChildren, out uint pcChildren, [Out] IntPtr children); + void GetChildren([In] uint cChildren, out uint pcChildren, [Out, MarshalAs(UnmanagedType.LPArray)] ISymUnmanagedScope[] children); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] uint GetStartOffset(); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] @@ -29,9 +29,9 @@ namespace Debugger.Interop.CorSym [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] uint GetLocalCount(); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void GetLocals([In] uint cLocals, out uint pcLocals, [Out] IntPtr locals); + void GetLocals([In] uint cLocals, out uint pcLocals, [Out, MarshalAs(UnmanagedType.LPArray)] ISymUnmanagedVariable[] locals); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] - void GetNamespaces([In] uint cNameSpaces, out uint pcNameSpaces, [Out] IntPtr namespaces); + void GetNamespaces([In] uint cNameSpaces, out uint pcNameSpaces, [Out, MarshalAs(UnmanagedType.LPArray)] ISymUnmanagedNamespace[] namespaces); } } 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 d9f8d800af..b2e6fdb635 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 @@ -7,10 +7,10 @@ using System; using System.IO; -using System.Diagnostics.SymbolStore; using System.Runtime.InteropServices; using Debugger.Wrappers.CorDebug; +using Debugger.Wrappers.CorSym; using Debugger.Wrappers.MetaData; namespace Debugger @@ -21,11 +21,10 @@ namespace Debugger bool unloaded = false; string fullPath; - string fullPathPDB; int orderOfLoading = 0; ICorDebugModule corModule; - SymReader symReader; + ISymUnmanagedReader symReader; MetaData metaData; public NDebugger Debugger { @@ -46,7 +45,7 @@ namespace Debugger } } - public SymReader SymReader { + public ISymUnmanagedReader SymReader { get { return symReader; } @@ -141,29 +140,7 @@ namespace Debugger fullPath = Marshal.PtrToStringUni(pString); Marshal.FreeHGlobal(pString); - string tempPath = String.Empty; - string pdbFilename = String.Empty; - string oldPdbPath = String.Empty; - string newPdbPath = String.Empty; - try { - tempPath = Path.Combine(Path.GetTempPath(), Path.Combine("DebeggerPdb", new Random().Next().ToString())); - pdbFilename = Path.GetFileNameWithoutExtension(FullPath) + ".pdb"; - oldPdbPath = Path.Combine(Path.GetDirectoryName(FullPath), pdbFilename); - newPdbPath = Path.Combine(tempPath, pdbFilename); - if (File.Exists(oldPdbPath)) { - Directory.CreateDirectory(tempPath); - File.Move(oldPdbPath, newPdbPath); - } - fullPathPDB = newPdbPath; - } catch {} - - symReader = metaData.GetSymReader(fullPath, tempPath); - - try { - if (File.Exists(newPdbPath) && !File.Exists(oldPdbPath)) { - File.Copy(newPdbPath, oldPdbPath); - } - } catch {} + symReader = metaData.GetSymReader(fullPath, null); JMCStatus = SymbolsLoaded; } @@ -177,22 +154,6 @@ namespace Debugger public void Dispose() { - if (symReader != null) { - try { - System.Reflection.MethodInfo m = symReader.GetType().GetMethod("{dtor}"); - m.Invoke(symReader, null); - } catch { - Console.WriteLine("symReader release failed. ({dtor})"); - } finally { - symReader = null; - } - try { - File.Delete(fullPathPDB); - } catch { - Console.WriteLine("Could not delete pdb temp file"); - } - } - metaData.Dispose(); unloaded = true; 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 419d54ef49..80c6a7ed58 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 @@ -6,14 +6,13 @@ // using System; -using System.Diagnostics.SymbolStore; +using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; using Debugger.Wrappers.CorDebug; +using Debugger.Wrappers.CorSym; using Debugger.Wrappers.MetaData; -using System.Collections.Generic; - namespace Debugger { @@ -146,7 +145,7 @@ namespace Debugger } } - internal ISymbolReader symReader { + internal ISymUnmanagedReader symReader { get { if (module.SymbolsLoaded == false) return null; if (module.SymReader == null) return null; @@ -154,13 +153,13 @@ namespace Debugger } } - internal ISymbolMethod symMethod { + internal ISymUnmanagedMethod symMethod { get { if (symReader == null) { return null; } else { try { - return symReader.GetMethod(new SymbolToken((int)methodProps.Token)); + return symReader.GetMethod(methodProps.Token); } catch { return null; } @@ -256,88 +255,72 @@ namespace Debugger /// SourcecodeSegment GetSegmentForOffet(uint offset) { - ISymbolMethod symMethod; + ISymUnmanagedMethod symMethod; symMethod = this.symMethod; if (symMethod == null) { return null; } - int sequencePointCount = symMethod.SequencePointCount; - - int[] offsets = new int[sequencePointCount]; - int[] startLine = new int[sequencePointCount]; - int[] startColumn = new int[sequencePointCount]; - int[] endLine = new int[sequencePointCount]; - int[] endColumn = new int[sequencePointCount]; - - ISymbolDocument[] Doc = new ISymbolDocument[sequencePointCount]; - - symMethod.GetSequencePoints( - offsets, - Doc, - startLine, - startColumn, - endLine, - endColumn - ); + uint sequencePointCount = symMethod.SequencePointCount; + SequencePoint[] sequencePoints = symMethod.SequencePoints; SourcecodeSegment retVal = new SourcecodeSegment(); // Get i for which: offsets[i] <= offset < offsets[i + 1] // or fallback to first element if offset < offsets[0] - for (int i = sequencePointCount - 1; i >= 0; i--) // backwards - if (offsets[i] <= offset || i == 0) { + for (int i = (int)sequencePointCount - 1; i >= 0; i--) // backwards + if (sequencePoints[i].Offset <= offset || i == 0) { // Set inforamtion about current IL range int codeSize = (int)corFunction.ILCode.Size; retVal.ILOffset = (int)offset; - retVal.ILStart = offsets[i]; - retVal.ILEnd = (i + 1 < sequencePointCount) ? offsets[i + 1] : codeSize; + retVal.ILStart = (int)sequencePoints[i].Offset; + retVal.ILEnd = (i + 1 < sequencePointCount) ? (int)sequencePoints[i+1].Offset : codeSize; // 0xFeeFee means "code generated by compiler" // If we are in generated sequence use to closest real one instead, // extend the ILStart and ILEnd to include the 'real' sequence // Look ahead for 'real' sequence - while (i + 1 < sequencePointCount && startLine[i] == 0xFeeFee) { + while (i + 1 < sequencePointCount && sequencePoints[i].Line == 0xFeeFee) { i++; - retVal.ILEnd = (i + 1 < sequencePointCount) ? offsets[i + 1] : codeSize; + retVal.ILEnd = (i + 1 < sequencePointCount) ? (int)sequencePoints[i+1].Offset : codeSize; } // Look back for 'real' sequence - while (i - 1 >= 0 && startLine[i] == 0xFeeFee) { + while (i - 1 >= 0 && sequencePoints[i].Line == 0xFeeFee) { i--; - retVal.ILStart = offsets[i]; + retVal.ILStart = (int)sequencePoints[i].Offset; } // Wow, there are no 'real' sequences - if (startLine[i] == 0xFeeFee) { + if (sequencePoints[i].Line == 0xFeeFee) { return null; } retVal.ModuleFilename = module.FullPath; - retVal.SourceFullFilename = Doc[i].URL; + retVal.SourceFullFilename = sequencePoints[i].Document.URL; - retVal.StartLine = startLine[i]; - retVal.StartColumn = startColumn[i]; - retVal.EndLine = endLine[i]; - retVal.EndColumn = endColumn[i]; + retVal.StartLine = (int)sequencePoints[i].Line; + retVal.StartColumn = (int)sequencePoints[i].Column; + retVal.EndLine = (int)sequencePoints[i].EndLine; + retVal.EndColumn = (int)sequencePoints[i].EndColumn; List stepRanges = new List(); for (int j = 0; j < sequencePointCount; j++) { // Step over compiler generated sequences and current statement // 0xFeeFee means "code generated by compiler" - if (startLine[j] == 0xFeeFee || j == i) { + if (sequencePoints[j].Line == 0xFeeFee || j == i) { // Add start offset or remove last end (to connect two ranges into one) - if (stepRanges.Count > 0 && stepRanges[stepRanges.Count - 1] == offsets[j]) { + if (stepRanges.Count > 0 && stepRanges[stepRanges.Count - 1] == sequencePoints[j].Offset) { stepRanges.RemoveAt(stepRanges.Count - 1); } else { - stepRanges.Add(offsets[j]); + stepRanges.Add((int)sequencePoints[j].Offset); } // Add end offset | handle last sequence point if (j + 1 < sequencePointCount) { - stepRanges.Add(offsets[j + 1]); + stepRanges.Add((int)sequencePoints[j+1].Offset); } else { stepRanges.Add(codeSize); } @@ -470,7 +453,7 @@ namespace Debugger public IEnumerable LocalVariables { get { if (symMethod != null) { // TODO: Is this needed? - ISymbolScope symRootScope = symMethod.RootScope; + ISymUnmanagedScope symRootScope = symMethod.RootScope; foreach(Variable var in GetLocalVariablesInScope(symRootScope)) { if (!var.Name.StartsWith("CS$")) { // TODO: Generalize yield return var; @@ -480,19 +463,19 @@ namespace Debugger } } - IEnumerable GetLocalVariablesInScope(ISymbolScope symScope) + IEnumerable GetLocalVariablesInScope(ISymUnmanagedScope symScope) { - foreach (ISymbolVariable symVar in symScope.GetLocals()) { + foreach (ISymUnmanagedVariable symVar in symScope.Locals) { yield return GetLocalVariable(symVar); } - foreach(ISymbolScope childScope in symScope.GetChildren()) { + foreach(ISymUnmanagedScope childScope in symScope.Children) { foreach(Variable var in GetLocalVariablesInScope(childScope)) { yield return var; } } } - Variable GetLocalVariable(ISymbolVariable symVar) + Variable GetLocalVariable(ISymUnmanagedVariable symVar) { return new Variable(debugger, symVar.Name, 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 86828493ad..1d6aaf26cc 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 @@ -6,9 +6,9 @@ // using System; -using System.Diagnostics.SymbolStore; using Debugger.Wrappers.CorDebug; +using Debugger.Wrappers.CorSym; namespace Debugger { @@ -159,9 +159,9 @@ namespace Debugger ilOffset = 0; Module module = null; - ISymbolReader symReader = null; - ISymbolDocument symDoc = null; - + ISymUnmanagedReader symReader = null; + ISymUnmanagedDocument symDoc = null; + // Try to get doc from moduleFilename if (moduleFilename != null) { try { @@ -192,25 +192,25 @@ namespace Debugger return false; //Not found } - int validLine; + uint validLine; try { - validLine = symDoc.FindClosestLine(StartLine); + validLine = symDoc.FindClosestLine((uint)StartLine); } catch { return false; //Not found } if (validLine != StartLine && normailize) { - StartLine = validLine; - EndLine = validLine; + StartLine = (int)validLine; + EndLine = (int)validLine; StartColumn = 0; EndColumn = 0; } - ISymbolMethod symMethod; - symMethod = symReader.GetMethodFromDocumentPosition(symDoc, validLine, StartColumn); + ISymUnmanagedMethod symMethod; + symMethod = symReader.GetMethodFromDocumentPosition(symDoc, validLine, (uint)StartColumn); - function = module.CorModule.GetFunctionFromToken((uint)symMethod.Token.GetToken()); + function = module.CorModule.GetFunctionFromToken(symMethod.Token); - ilOffset = symMethod.GetOffset(symDoc, validLine, StartColumn); + ilOffset = (int)symMethod.GetOffset(symDoc, validLine, (uint)StartColumn); return true; } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedMethod.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedMethod.cs index 8ca794f95b..cbf88eac3d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedMethod.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedMethod.cs @@ -171,11 +171,27 @@ namespace Debugger.Wrappers.CorSym return pRetVal; } - public void GetSequencePoints(uint cPoints, out uint pcPoints, ref uint offsets, ref ISymUnmanagedDocument documents, ref uint lines, ref uint columns, ref uint endLines, ref uint endColumns) + public void GetSequencePoints(uint cPoints, out uint pcPoints, uint[] offsets, ISymUnmanagedDocument[] documents, uint[] lines, uint[] columns, uint[] endLines, uint[] endColumns) { - Debugger.Interop.CorSym.ISymUnmanagedDocument ref_documents = documents.WrappedObject; - this.WrappedObject.GetSequencePoints(cPoints, out pcPoints, ref offsets, ref ref_documents, ref lines, ref columns, ref endLines, ref endColumns); - documents = ISymUnmanagedDocument.Wrap(ref_documents); + Debugger.Interop.CorSym.ISymUnmanagedDocument[] array_documents = new Debugger.Interop.CorSym.ISymUnmanagedDocument[documents.Length]; + for (int i = 0; (i < documents.Length); i = (i + 1)) + { + if ((documents[i] != null)) + { + array_documents[i] = documents[i].WrappedObject; + } + } + this.WrappedObject.GetSequencePoints(cPoints, out pcPoints, offsets, array_documents, lines, columns, endLines, endColumns); + for (int i = 0; (i < documents.Length); i = (i + 1)) + { + if ((array_documents[i] != null)) + { + documents[i] = ISymUnmanagedDocument.Wrap(array_documents[i]); + } else + { + documents[i] = null; + } + } } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedScope.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedScope.cs index 54f8015e64..6279ce9f34 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedScope.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedScope.cs @@ -106,9 +106,27 @@ namespace Debugger.Wrappers.CorSym } } - public void GetChildren(uint cChildren, out uint pcChildren, System.IntPtr children) + public void GetChildren(uint cChildren, out uint pcChildren, ISymUnmanagedScope[] children) { - this.WrappedObject.GetChildren(cChildren, out pcChildren, children); + Debugger.Interop.CorSym.ISymUnmanagedScope[] array_children = new Debugger.Interop.CorSym.ISymUnmanagedScope[children.Length]; + for (int i = 0; (i < children.Length); i = (i + 1)) + { + if ((children[i] != null)) + { + array_children[i] = children[i].WrappedObject; + } + } + this.WrappedObject.GetChildren(cChildren, out pcChildren, array_children); + for (int i = 0; (i < children.Length); i = (i + 1)) + { + if ((array_children[i] != null)) + { + children[i] = ISymUnmanagedScope.Wrap(array_children[i]); + } else + { + children[i] = null; + } + } } public uint StartOffset @@ -135,14 +153,50 @@ namespace Debugger.Wrappers.CorSym } } - public void GetLocals(uint cLocals, out uint pcLocals, System.IntPtr locals) + public void GetLocals(uint cLocals, out uint pcLocals, ISymUnmanagedVariable[] locals) { - this.WrappedObject.GetLocals(cLocals, out pcLocals, locals); + Debugger.Interop.CorSym.ISymUnmanagedVariable[] array_locals = new Debugger.Interop.CorSym.ISymUnmanagedVariable[locals.Length]; + for (int i = 0; (i < locals.Length); i = (i + 1)) + { + if ((locals[i] != null)) + { + array_locals[i] = locals[i].WrappedObject; + } + } + this.WrappedObject.GetLocals(cLocals, out pcLocals, array_locals); + for (int i = 0; (i < locals.Length); i = (i + 1)) + { + if ((array_locals[i] != null)) + { + locals[i] = ISymUnmanagedVariable.Wrap(array_locals[i]); + } else + { + locals[i] = null; + } + } } - public void GetNamespaces(uint cNameSpaces, out uint pcNameSpaces, System.IntPtr namespaces) + public void GetNamespaces(uint cNameSpaces, out uint pcNameSpaces, ISymUnmanagedNamespace[] namespaces) { - this.WrappedObject.GetNamespaces(cNameSpaces, out pcNameSpaces, namespaces); + Debugger.Interop.CorSym.ISymUnmanagedNamespace[] array_namespaces = new Debugger.Interop.CorSym.ISymUnmanagedNamespace[namespaces.Length]; + for (int i = 0; (i < namespaces.Length); i = (i + 1)) + { + if ((namespaces[i] != null)) + { + array_namespaces[i] = namespaces[i].WrappedObject; + } + } + this.WrappedObject.GetNamespaces(cNameSpaces, out pcNameSpaces, array_namespaces); + for (int i = 0; (i < namespaces.Length); i = (i + 1)) + { + if ((array_namespaces[i] != null)) + { + namespaces[i] = ISymUnmanagedNamespace.Wrap(array_namespaces[i]); + } else + { + namespaces[i] = null; + } + } } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedBinder.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedBinder.cs new file mode 100644 index 0000000000..8be78a8049 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedBinder.cs @@ -0,0 +1,25 @@ +// +// +// +// +// $Revision$ +// + +namespace Debugger.Wrappers.CorSym +{ + using System; + using System.Runtime.InteropServices; + + public partial class ISymUnmanagedBinder + { + public ISymUnmanagedReader GetReaderForFile(object importer, string filename, string searchPath) + { + IntPtr pfilename = Marshal.StringToCoTaskMemUni(filename); + IntPtr psearchPath = Marshal.StringToCoTaskMemUni(searchPath); + ISymUnmanagedReader res = GetReaderForFile(importer, pfilename, psearchPath); + Marshal.FreeCoTaskMem(pfilename); + Marshal.FreeCoTaskMem(psearchPath); + return res; + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedDocument.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedDocument.cs new file mode 100644 index 0000000000..73c1ce6dae --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedDocument.cs @@ -0,0 +1,21 @@ +// +// +// +// +// $Revision$ +// + +namespace Debugger.Wrappers.CorSym +{ + using System; + + + public partial class ISymUnmanagedDocument + { + public string URL { + get { + return Util.GetString(GetURL); + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedMethod.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedMethod.cs new file mode 100644 index 0000000000..150995c00f --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedMethod.cs @@ -0,0 +1,50 @@ +// +// +// +// +// $Revision$ +// + +namespace Debugger.Wrappers.CorSym +{ + using System; + + + public partial class ISymUnmanagedMethod + { + public SequencePoint[] SequencePoints { + get { + uint count = this.SequencePointCount; + + ISymUnmanagedDocument[] documents = new ISymUnmanagedDocument[count]; + uint[] offsets = new uint[count]; + uint[] lines = new uint[count]; + uint[] columns = new uint[count]; + uint[] endLines = new uint[count]; + uint[] endColumns = new uint[count]; + + GetSequencePoints(count, + out count, + offsets, + documents, + lines, + columns, + endLines, + endColumns); + + SequencePoint[] sequencePoints = new SequencePoint[count]; + + for(int i = 0; i < count; i++) { + sequencePoints[i] = new SequencePoint(documents[i], + offsets[i], + lines[i], + columns[i], + endLines[i], + endColumns[i]); + } + + return sequencePoints; + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedReader.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedReader.cs new file mode 100644 index 0000000000..76e5b0ad9f --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedReader.cs @@ -0,0 +1,23 @@ +// +// +// +// +// $Revision$ +// + +namespace Debugger.Wrappers.CorSym +{ + using System; + using System.Runtime.InteropServices; + + public partial class ISymUnmanagedReader + { + public ISymUnmanagedDocument GetDocument(string url, System.Guid language, System.Guid languageVendor, System.Guid documentType) + { + IntPtr p = Marshal.StringToCoTaskMemUni(url); + ISymUnmanagedDocument res = GetDocument(p, language, languageVendor, documentType); + Marshal.FreeCoTaskMem(p); + return res; + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedScope.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedScope.cs new file mode 100644 index 0000000000..0bd24fa2d5 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedScope.cs @@ -0,0 +1,45 @@ +// +// +// +// +// $Revision$ +// + +namespace Debugger.Wrappers.CorSym +{ + using System; + + + public partial class ISymUnmanagedScope + { + public ISymUnmanagedScope[] Children { + get { + uint count; + GetChildren(0, out count, new ISymUnmanagedScope[0]); + ISymUnmanagedScope[] children = new ISymUnmanagedScope[count]; + GetChildren(count, out count, children); + return children; + } + } + + public ISymUnmanagedVariable[] Locals { + get { + uint count; + GetLocals(0, out count, new ISymUnmanagedVariable[0]); + ISymUnmanagedVariable[] locals = new ISymUnmanagedVariable[count]; + GetLocals(count, out count, locals); + return locals; + } + } + + public ISymUnmanagedNamespace[] Namespaces { + get { + uint count; + GetNamespaces(0, out count, new ISymUnmanagedNamespace[0]); + ISymUnmanagedNamespace[] namespaces = new ISymUnmanagedNamespace[count]; + GetNamespaces(0, out count, namespaces); + return namespaces; + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedVariable.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedVariable.cs new file mode 100644 index 0000000000..05e2bf4af8 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedVariable.cs @@ -0,0 +1,21 @@ +// +// +// +// +// $Revision$ +// + +namespace Debugger.Wrappers.CorSym +{ + using System; + using System.Runtime.InteropServices; + + public partial class ISymUnmanagedVariable + { + public string Name { + get { + return Util.GetString(GetName); + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/SequencePoint.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/SequencePoint.cs new file mode 100644 index 0000000000..699d16ca4f --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/SequencePoint.cs @@ -0,0 +1,68 @@ +// +// +// +// +// $Revision$ +// + +namespace Debugger.Wrappers.CorSym +{ + using System; + + + public class SequencePoint + { + ISymUnmanagedDocument document; + uint offset; + uint line; + uint column; + uint endLine; + uint endColumn; + + public ISymUnmanagedDocument Document { + get { + return document; + } + } + + public uint Offset { + get { + return offset; + } + } + + public uint Line { + get { + return line; + } + } + + public uint Column { + get { + return column; + } + } + + public uint EndLine { + get { + return endLine; + } + } + + public uint EndColumn { + get { + return endColumn; + } + } + + public SequencePoint(ISymUnmanagedDocument document, uint offset, uint line, uint column, uint endLine, uint endColumn) + { + this.document = document; + this.offset = offset; + this.line = line; + this.column = column; + this.endLine = endLine; + this.endColumn = endColumn; + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaData.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaData.cs index 8213da12be..488073d463 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaData.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaData.cs @@ -7,11 +7,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics.SymbolStore; using System.Text; using System.Runtime.InteropServices; using Debugger.Wrappers.CorDebug; +using Debugger.Wrappers.CorSym; using Debugger.Interop.MetaData; namespace Debugger.Wrappers.MetaData @@ -26,22 +26,14 @@ namespace Debugger.Wrappers.MetaData metaData = (IMetaDataImport)pModule.GetMetaDataInterface(ref guid); } - public SymReader GetSymReader(string fullname, string searchPath) + public ISymUnmanagedReader GetSymReader(string fullname, string searchPath) { - SymReader symReader; - SymBinder symBinder = new SymBinder(); - IntPtr ptr = IntPtr.Zero; try { - ptr = Marshal.GetIUnknownForObject(metaData); - symReader = (SymReader)symBinder.GetReader(ptr, fullname, searchPath); - } catch (System.Exception) { - symReader = null; - } finally { - if (ptr != IntPtr.Zero) { - Marshal.Release(ptr); - } + ISymUnmanagedBinder symBinder = new ISymUnmanagedBinder(new Debugger.Interop.CorSym.CorSymBinder_SxSClass()); + return symBinder.GetReaderForFile(metaData, fullname, searchPath); + } catch { + return null; } - return symReader; } public void Dispose() diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs index 58907711fe..aadbb98232 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs @@ -39,7 +39,7 @@ namespace Debugger.Wrappers public static void TrackCOMObject(object comObject, Type type) { - if (!Marshal.IsComObject(comObject)) { + if (comObject == null || !Marshal.IsComObject(comObject)) { if (trace) Trace("Will not be tracked: {0}", type.Name); } else { TrackedObjectMetaData metaData; @@ -56,7 +56,7 @@ namespace Debugger.Wrappers public static void ReleaseCOMObject(object comObject, Type type) { TrackedObjectMetaData metaData; - if (trackedCOMObjects.TryGetValue(comObject, out metaData)) { + if (comObject != null && trackedCOMObjects.TryGetValue(comObject, out metaData)) { metaData.RefCount -= 1; if (metaData.RefCount == 0) { Marshal.FinalReleaseComObject(comObject); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/Util.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/Util.cs new file mode 100644 index 0000000000..49a50c1715 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/Util.cs @@ -0,0 +1,32 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Debugger.Wrappers +{ + public delegate void UnmanagedStringGetter(uint bufferSize, out uint returnedSize, System.IntPtr pString); + + public static class Util + { + public static string GetString(UnmanagedStringGetter getter) + { + uint pStringLenght = 0; + IntPtr pString = IntPtr.Zero; + getter(pStringLenght, out pStringLenght, pString); + // Allocate string buffer + pString = Marshal.AllocHGlobal((int)pStringLenght * 2); + getter(pStringLenght, out pStringLenght, pString); + string str = Marshal.PtrToStringUni(pString); + // Release buffer + Marshal.FreeHGlobal(pString); + return str; + } + } +}