Browse Source

Using unmanaged CorSym instead of System.Diagnostics.SymbolStore

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1159 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
028cb778bd
  1. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs
  3. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedMethod.cs
  4. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedScope.cs
  5. 47
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs
  6. 79
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  7. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/SourcecodeSegment.cs
  8. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedMethod.cs
  9. 66
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedScope.cs
  10. 25
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedBinder.cs
  11. 21
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedDocument.cs
  12. 50
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedMethod.cs
  13. 23
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedReader.cs
  14. 45
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedScope.cs
  15. 21
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedVariable.cs
  16. 68
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/SequencePoint.cs
  17. 20
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaData.cs
  18. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs
  19. 32
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/Util.cs

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -355,6 +355,14 @@ @@ -355,6 +355,14 @@
<Compile Include="Src\Wrappers\NativeMethods.cs" />
<Compile Include="Src\Wrappers\ResourceManager.cs" />
<Compile Include="Src\Wrappers\_SECURITY_ATTRIBUTES.cs" />
<Compile Include="Src\Wrappers\Util.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedBinder.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedDocument.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedMethod.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedReader.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedScope.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedVariable.cs" />
<Compile Include="Src\Wrappers\CorSym\SequencePoint.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />
@ -367,4 +375,4 @@ @@ -367,4 +375,4 @@
<Folder Include="Src\Wrappers\MetaData" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>
</Project>

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
// </file>
using System;
using System.Diagnostics.SymbolStore;
using System.Collections;
using System.Runtime.InteropServices;

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedMethod.cs

@ -35,7 +35,7 @@ namespace Debugger.Interop.CorSym @@ -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);
}
}

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorSym/ISymUnmanagedScope.cs

@ -21,7 +21,7 @@ namespace Debugger.Interop.CorSym @@ -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 @@ -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);
}
}

47
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs

@ -7,10 +7,10 @@ @@ -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 @@ -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 @@ -46,7 +45,7 @@ namespace Debugger
}
}
public SymReader SymReader {
public ISymUnmanagedReader SymReader {
get {
return symReader;
}
@ -141,29 +140,7 @@ namespace Debugger @@ -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 @@ -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;

79
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -6,14 +6,13 @@ @@ -6,14 +6,13 @@
// </file>
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 @@ -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 @@ -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 @@ -256,88 +255,72 @@ namespace Debugger
/// </summary>
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<int> stepRanges = new List<int>();
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 @@ -470,7 +453,7 @@ namespace Debugger
public IEnumerable<Variable> 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 @@ -480,19 +463,19 @@ namespace Debugger
}
}
IEnumerable<Variable> GetLocalVariablesInScope(ISymbolScope symScope)
IEnumerable<Variable> 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,

24
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/SourcecodeSegment.cs

@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
// </file>
using System;
using System.Diagnostics.SymbolStore;
using Debugger.Wrappers.CorDebug;
using Debugger.Wrappers.CorSym;
namespace Debugger
{
@ -159,9 +159,9 @@ 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 @@ -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;
}

24
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedMethod.cs

@ -171,11 +171,27 @@ namespace Debugger.Wrappers.CorSym @@ -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;
}
}
}
}
}

66
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/Autogenerated/ISymUnmanagedScope.cs

@ -106,9 +106,27 @@ namespace Debugger.Wrappers.CorSym @@ -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 @@ -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;
}
}
}
}
}

25
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedBinder.cs

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}

21
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedDocument.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
namespace Debugger.Wrappers.CorSym
{
using System;
public partial class ISymUnmanagedDocument
{
public string URL {
get {
return Util.GetString(GetURL);
}
}
}
}

50
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedMethod.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}
}

23
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedReader.cs

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}

45
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedScope.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}
}

21
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedVariable.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
namespace Debugger.Wrappers.CorSym
{
using System;
using System.Runtime.InteropServices;
public partial class ISymUnmanagedVariable
{
public string Name {
get {
return Util.GetString(GetName);
}
}
}
}

68
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/SequencePoint.cs

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}

20
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaData.cs

@ -7,11 +7,11 @@ @@ -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 @@ -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()

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs

@ -39,7 +39,7 @@ namespace Debugger.Wrappers @@ -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 @@ -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);

32
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/Util.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}
Loading…
Cancel
Save