Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5134 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
20 changed files with 414 additions and 729 deletions
@ -0,0 +1,249 @@
@@ -0,0 +1,249 @@
|
||||
// <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; |
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
// ICorDebugArrayValue
|
||||
|
||||
public static unsafe uint[] GetDimensions(this ICorDebugArrayValue corArray) |
||||
{ |
||||
uint[] dimensions = new uint[corArray.GetRank()]; |
||||
fixed (void* pDimensions = dimensions) |
||||
corArray.GetDimensions((uint)dimensions.Length, new IntPtr(pDimensions)); |
||||
return dimensions; |
||||
} |
||||
|
||||
public static unsafe uint[] GetBaseIndicies(this ICorDebugArrayValue corArray) |
||||
{ |
||||
uint[] baseIndicies = new uint[corArray.GetRank()]; |
||||
fixed (void* pBaseIndicies = baseIndicies) |
||||
corArray.GetBaseIndicies((uint)baseIndicies.Length, new IntPtr(pBaseIndicies)); |
||||
return baseIndicies; |
||||
} |
||||
|
||||
public static unsafe ICorDebugValue GetElement(this ICorDebugArrayValue corArray, uint[] indices) |
||||
{ |
||||
fixed (void* pIndices = indices) |
||||
return corArray.GetElement((uint)indices.Length, new IntPtr(pIndices)); |
||||
} |
||||
|
||||
public static unsafe ICorDebugValue GetElement(this ICorDebugArrayValue corArray, int[] indices) |
||||
{ |
||||
fixed (void* pIndices = indices) |
||||
return corArray.GetElement((uint)indices.Length, new IntPtr(pIndices)); |
||||
} |
||||
|
||||
// ICorDebugClass2
|
||||
|
||||
public static ICorDebugType GetParameterizedType(this ICorDebugClass2 corClass, uint elementType, ICorDebugType[] ppTypeArgs) |
||||
{ |
||||
return corClass.GetParameterizedType(elementType, (uint)ppTypeArgs.Length, ppTypeArgs); |
||||
} |
||||
|
||||
// ICorDebugCode
|
||||
|
||||
public static unsafe byte[] GetCode(this ICorDebugCode corCode) |
||||
{ |
||||
if (corCode.IsIL() == 0) return null; |
||||
byte[] code = new byte[corCode.GetSize()]; |
||||
fixed(void* pCode = code) |
||||
corCode.GetCode(0, (uint)code.Length, (uint)code.Length, new IntPtr(pCode)); |
||||
return code; |
||||
} |
||||
|
||||
// ICorDebugFrameEnum
|
||||
|
||||
public static IEnumerable<ICorDebugFrame> GetEnumerator(this ICorDebugFrameEnum corFrameEnum) |
||||
{ |
||||
// TODO: As list
|
||||
corFrameEnum.Reset(); |
||||
while (true) { |
||||
ICorDebugFrame corFrame = corFrameEnum.Next(); |
||||
if (corFrame != null) { |
||||
yield return corFrame; |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static ICorDebugFrame Next(this ICorDebugFrameEnum corFrameEnum) |
||||
{ |
||||
ICorDebugFrame[] corFrames = new ICorDebugFrame[1]; |
||||
uint framesFetched = corFrameEnum.Next(1, corFrames); |
||||
if (framesFetched == 0) { |
||||
return null; |
||||
} else { |
||||
return corFrames[0]; |
||||
} |
||||
} |
||||
|
||||
// ICorDebugGenericValue
|
||||
|
||||
public static unsafe Byte[] GetRawValue(this ICorDebugGenericValue corGenVal) |
||||
{ |
||||
// TODO: Unset fixing insead
|
||||
Byte[] retValue = new Byte[(int)corGenVal.GetSize()]; |
||||
IntPtr pValue = Marshal.AllocHGlobal(retValue.Length); |
||||
corGenVal.GetValue(pValue); |
||||
Marshal.Copy(pValue, retValue, 0, retValue.Length); |
||||
Marshal.FreeHGlobal(pValue); |
||||
return retValue; |
||||
} |
||||
|
||||
public static unsafe void SetRawValue(this ICorDebugGenericValue corGenVal, byte[] value) |
||||
{ |
||||
if (corGenVal.GetSize() != value.Length) throw new ArgumentException("Incorrect length"); |
||||
IntPtr pValue = Marshal.AllocHGlobal(value.Length); |
||||
Marshal.Copy(value, 0, pValue, value.Length); |
||||
corGenVal.SetValue(pValue); |
||||
Marshal.FreeHGlobal(pValue); |
||||
} |
||||
|
||||
public static unsafe object GetValue(this ICorDebugGenericValue corGenVal,Type type) |
||||
{ |
||||
object retValue; |
||||
IntPtr pValue = Marshal.AllocHGlobal((int)corGenVal.GetSize()); |
||||
corGenVal.GetValue(pValue); |
||||
switch(type.FullName) { |
||||
case "System.Boolean": retValue = *((System.Boolean*)pValue); break; |
||||
case "System.Char": retValue = *((System.Char*) pValue); break; |
||||
case "System.SByte": retValue = *((System.SByte*) pValue); break; |
||||
case "System.Byte": retValue = *((System.Byte*) pValue); break; |
||||
case "System.Int16": retValue = *((System.Int16*) pValue); break; |
||||
case "System.UInt16": retValue = *((System.UInt16*) pValue); break; |
||||
case "System.Int32": retValue = *((System.Int32*) pValue); break; |
||||
case "System.UInt32": retValue = *((System.UInt32*) pValue); break; |
||||
case "System.Int64": retValue = *((System.Int64*) pValue); break; |
||||
case "System.UInt64": retValue = *((System.UInt64*) pValue); break; |
||||
case "System.Single": retValue = *((System.Single*) pValue); break; |
||||
case "System.Double": retValue = *((System.Double*) pValue); break; |
||||
case "System.IntPtr": retValue = *((System.IntPtr*) pValue); break; |
||||
case "System.UIntPtr": retValue = *((System.UIntPtr*)pValue); break; |
||||
default: throw new NotSupportedException(); |
||||
} |
||||
Marshal.FreeHGlobal(pValue); |
||||
return retValue; |
||||
} |
||||
|
||||
public static unsafe void SetValue(this ICorDebugGenericValue corGenVal, Type type, object value) |
||||
{ |
||||
IntPtr pValue = Marshal.AllocHGlobal((int)corGenVal.GetSize()); |
||||
switch(type.FullName) { |
||||
case "System.Boolean": *((System.Boolean*)pValue) = (System.Boolean)value; break; |
||||
case "System.Char": *((System.Char*) pValue) = (System.Char) value; break; |
||||
case "System.SByte": *((System.SByte*) pValue) = (System.SByte) value; break; |
||||
case "System.Byte": *((System.Byte*) pValue) = (System.Byte) value; break; |
||||
case "System.Int16": *((System.Int16*) pValue) = (System.Int16) value; break; |
||||
case "System.UInt16": *((System.UInt16*) pValue) = (System.UInt16) value; break; |
||||
case "System.Int32": *((System.Int32*) pValue) = (System.Int32) value; break; |
||||
case "System.UInt32": *((System.UInt32*) pValue) = (System.UInt32) value; break; |
||||
case "System.Int64": *((System.Int64*) pValue) = (System.Int64) value; break; |
||||
case "System.UInt64": *((System.UInt64*) pValue) = (System.UInt64) value; break; |
||||
case "System.Single": *((System.Single*) pValue) = (System.Single) value; break; |
||||
case "System.Double": *((System.Double*) pValue) = (System.Double) value; break; |
||||
case "System.IntPtr": *((System.IntPtr*) pValue) = (System.IntPtr) value; break; |
||||
case "System.UIntPtr": *((System.UIntPtr*)pValue) = (System.UIntPtr)value; break; |
||||
default: throw new NotSupportedException(); |
||||
} |
||||
corGenVal.SetValue(pValue); |
||||
Marshal.FreeHGlobal(pValue); |
||||
} |
||||
|
||||
// ICorDebugChainEnum
|
||||
|
||||
public static IEnumerable<ICorDebugChain> GetEnumerator(this ICorDebugChainEnum corChainEnum) |
||||
{ |
||||
corChainEnum.Reset(); |
||||
while (true) { |
||||
ICorDebugChain corChain = corChainEnum.Next(); |
||||
if (corChain != null) { |
||||
yield return corChain; |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static ICorDebugChain Next(this ICorDebugChainEnum corChainEnum) |
||||
{ |
||||
ICorDebugChain[] corChains = new ICorDebugChain[1]; |
||||
uint chainsFetched = corChainEnum.Next(1, corChains); |
||||
if (chainsFetched == 0) { |
||||
return null; |
||||
} else { |
||||
return corChains[0]; |
||||
} |
||||
} |
||||
|
||||
// ICorDebugModule
|
||||
|
||||
public static string GetName(this ICorDebugModule corModule) |
||||
{ |
||||
return Util.GetString(corModule.GetName); |
||||
} |
||||
|
||||
// ICorDebugProcess
|
||||
|
||||
public static bool HasQueuedCallbacks(this ICorDebugProcess corProcess) |
||||
{ |
||||
int pbQueued; |
||||
corProcess.HasQueuedCallbacks(null, out pbQueued); |
||||
return pbQueued != 0; |
||||
} |
||||
|
||||
// ICorDebugStepper
|
||||
|
||||
public static unsafe void StepRange(this ICorDebugStepper corStepper, bool bStepIn, int[] ranges) |
||||
{ |
||||
fixed (int* pRanges = ranges) |
||||
corStepper.StepRange(bStepIn?1:0, (IntPtr)pRanges, (uint)ranges.Length / 2); |
||||
} |
||||
|
||||
// ICorDebugStringValue
|
||||
|
||||
public static string GetString(this ICorDebugStringValue corString) |
||||
{ |
||||
return Util.GetString(corString.GetString, 64, false); |
||||
} |
||||
|
||||
// ICorDebugTypeEnum
|
||||
|
||||
public static IEnumerable<ICorDebugType> GetEnumerator(this ICorDebugTypeEnum corTypeEnum) |
||||
{ |
||||
corTypeEnum.Reset(); |
||||
while (true) { |
||||
ICorDebugType corType = corTypeEnum.Next(); |
||||
if (corType != null) { |
||||
yield return corType; |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static ICorDebugType Next(this ICorDebugTypeEnum corTypeEnum) |
||||
{ |
||||
ICorDebugType[] corTypes = new ICorDebugType[1]; |
||||
uint typesFetched = corTypeEnum.Next(1, corTypes); |
||||
if (typesFetched == 0) { |
||||
return null; |
||||
} else { |
||||
return corTypes[0]; |
||||
} |
||||
} |
||||
|
||||
public static List<ICorDebugType> ToList(this ICorDebugTypeEnum corTypeEnum) |
||||
{ |
||||
return new List<ICorDebugType>(corTypeEnum.GetEnumerator()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,165 @@
@@ -0,0 +1,165 @@
|
||||
// <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; |
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
public static partial class CorSymExtensionMethods |
||||
{ |
||||
// ISymUnmanagedBinder
|
||||
|
||||
public static ISymUnmanagedReader GetReaderForFile(this ISymUnmanagedBinder symBinder, object importer, string filename, string searchPath) |
||||
{ |
||||
IntPtr pfilename = Marshal.StringToCoTaskMemUni(filename); |
||||
IntPtr psearchPath = Marshal.StringToCoTaskMemUni(searchPath); |
||||
ISymUnmanagedReader res = symBinder.GetReaderForFile(importer, pfilename, psearchPath); |
||||
Marshal.FreeCoTaskMem(pfilename); |
||||
Marshal.FreeCoTaskMem(psearchPath); |
||||
return res; |
||||
} |
||||
|
||||
// ISymUnmanagedDocument
|
||||
|
||||
public static string GetURL(this ISymUnmanagedDocument symDoc) |
||||
{ |
||||
return Util.GetString(symDoc.GetURL, 256, true); |
||||
} |
||||
|
||||
public static byte[] GetCheckSum(this ISymUnmanagedDocument symDoc) |
||||
{ |
||||
uint checkSumLength = 0; |
||||
symDoc.GetCheckSum(checkSumLength, out checkSumLength, IntPtr.Zero); |
||||
IntPtr checkSumPtr = Marshal.AllocHGlobal((int)checkSumLength); |
||||
symDoc.GetCheckSum(checkSumLength, out checkSumLength, checkSumPtr); |
||||
byte[] checkSumBytes = new byte[checkSumLength]; |
||||
Marshal.Copy(checkSumPtr, checkSumBytes, 0, (int)checkSumLength); |
||||
Marshal.FreeHGlobal(checkSumPtr); |
||||
return checkSumBytes; |
||||
} |
||||
|
||||
// ISymUnmanagedMethod
|
||||
|
||||
public static SequencePoint[] GetSequencePoints(this ISymUnmanagedMethod symMethod) |
||||
{ |
||||
uint count = symMethod.GetSequencePointCount(); |
||||
|
||||
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]; |
||||
|
||||
symMethod.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() { |
||||
Document = documents[i], |
||||
Offset = offsets[i], |
||||
Line = lines[i], |
||||
Column = columns[i], |
||||
EndLine = endLines[i], |
||||
EndColumn = endColumns[i] |
||||
}; |
||||
} |
||||
|
||||
return sequencePoints; |
||||
} |
||||
|
||||
// ISymUnmanagedReader
|
||||
|
||||
public static ISymUnmanagedDocument GetDocument(this ISymUnmanagedReader symReader, string url, System.Guid language, System.Guid languageVendor, System.Guid documentType) |
||||
{ |
||||
IntPtr p = Marshal.StringToCoTaskMemUni(url); |
||||
ISymUnmanagedDocument res = symReader.GetDocument(p, language, languageVendor, documentType); |
||||
Marshal.FreeCoTaskMem(p); |
||||
return res; |
||||
} |
||||
|
||||
// ISymUnmanagedScope
|
||||
|
||||
public static ISymUnmanagedScope[] GetChildren(this ISymUnmanagedScope symScope) |
||||
{ |
||||
uint count; |
||||
symScope.GetChildren(0, out count, new ISymUnmanagedScope[0]); |
||||
ISymUnmanagedScope[] children = new ISymUnmanagedScope[count]; |
||||
symScope.GetChildren(count, out count, children); |
||||
return children; |
||||
} |
||||
|
||||
public static ISymUnmanagedVariable[] GetLocals(this ISymUnmanagedScope symScope) |
||||
{ |
||||
uint count; |
||||
symScope.GetLocals(0, out count, new ISymUnmanagedVariable[0]); |
||||
ISymUnmanagedVariable[] locals = new ISymUnmanagedVariable[count]; |
||||
symScope.GetLocals(count, out count, locals); |
||||
return locals; |
||||
} |
||||
|
||||
public static ISymUnmanagedNamespace[] GetNamespaces(this ISymUnmanagedScope symScope) |
||||
{ |
||||
uint count; |
||||
symScope.GetNamespaces(0, out count, new ISymUnmanagedNamespace[0]); |
||||
ISymUnmanagedNamespace[] namespaces = new ISymUnmanagedNamespace[count]; |
||||
symScope.GetNamespaces(0, out count, namespaces); |
||||
return namespaces; |
||||
} |
||||
|
||||
// ISymUnmanagedVariable
|
||||
|
||||
public static string GetName(this ISymUnmanagedVariable symVar) |
||||
{ |
||||
return Util.GetString(symVar.GetName); |
||||
} |
||||
|
||||
const int defaultSigSize = 8; |
||||
|
||||
public static unsafe byte[] GetSignature(this ISymUnmanagedVariable symVar) |
||||
{ |
||||
byte[] sig = new byte[defaultSigSize]; |
||||
uint acualSize; |
||||
fixed(byte* pSig = sig) |
||||
symVar.GetSignature((uint)sig.Length, out acualSize, new IntPtr(pSig)); |
||||
Array.Resize(ref sig, (int)acualSize); |
||||
if (acualSize > defaultSigSize) |
||||
fixed(byte* pSig = sig) |
||||
symVar.GetSignature((uint)sig.Length, out acualSize, new IntPtr(pSig)); |
||||
return sig; |
||||
} |
||||
} |
||||
|
||||
public class SequencePoint: IComparable<SequencePoint> |
||||
{ |
||||
public ISymUnmanagedDocument Document { get; private set; } |
||||
public uint Offset { get; private set; } |
||||
public uint Line { get; private set; } |
||||
public uint Column { get; private set; } |
||||
public uint EndLine { get; private set; } |
||||
public uint EndColumn { get; private set; } |
||||
|
||||
public int CompareTo(SequencePoint other) |
||||
{ |
||||
if (this.Line == other.Line) { |
||||
return this.Column.CompareTo(other.Column); |
||||
} else { |
||||
return this.Line.CompareTo(other.Line); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,46 +0,0 @@
@@ -1,46 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static unsafe uint[] GetDimensions(this ICorDebugArrayValue corArray) |
||||
{ |
||||
uint[] dimensions = new uint[corArray.GetRank()]; |
||||
fixed (void* pDimensions = dimensions) |
||||
corArray.GetDimensions((uint)dimensions.Length, new IntPtr(pDimensions)); |
||||
return dimensions; |
||||
} |
||||
|
||||
public static unsafe uint[] GetBaseIndicies(this ICorDebugArrayValue corArray) |
||||
{ |
||||
uint[] baseIndicies = new uint[corArray.GetRank()]; |
||||
fixed (void* pBaseIndicies = baseIndicies) |
||||
corArray.GetBaseIndicies((uint)baseIndicies.Length, new IntPtr(pBaseIndicies)); |
||||
return baseIndicies; |
||||
} |
||||
|
||||
public static unsafe ICorDebugValue GetElement(this ICorDebugArrayValue corArray, uint[] indices) |
||||
{ |
||||
fixed (void* pIndices = indices) |
||||
return corArray.GetElement((uint)indices.Length, new IntPtr(pIndices)); |
||||
} |
||||
|
||||
public static unsafe ICorDebugValue GetElement(this ICorDebugArrayValue corArray, int[] indices) |
||||
{ |
||||
fixed (void* pIndices = indices) |
||||
return corArray.GetElement((uint)indices.Length, new IntPtr(pIndices)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,44 +0,0 @@
@@ -1,44 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static IEnumerable<ICorDebugChain> GetEnumerator(this ICorDebugChainEnum corChainEnum) |
||||
{ |
||||
corChainEnum.Reset(); |
||||
while (true) { |
||||
ICorDebugChain corChain = corChainEnum.Next(); |
||||
if (corChain != null) { |
||||
yield return corChain; |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static ICorDebugChain Next(this ICorDebugChainEnum corChainEnum) |
||||
{ |
||||
ICorDebugChain[] corChains = new ICorDebugChain[1]; |
||||
uint chainsFetched = corChainEnum.Next(1, corChains); |
||||
if (chainsFetched == 0) { |
||||
return null; |
||||
} else { |
||||
return corChains[0]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static ICorDebugType GetParameterizedType(this ICorDebugClass2 corClass, uint elementType, ICorDebugType[] ppTypeArgs) |
||||
{ |
||||
return corClass.GetParameterizedType(elementType, (uint)ppTypeArgs.Length, ppTypeArgs); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,25 +0,0 @@
@@ -1,25 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static unsafe byte[] GetCode(this ICorDebugCode corCode) |
||||
{ |
||||
if (corCode.IsIL() == 0) return null; |
||||
byte[] code = new byte[corCode.GetSize()]; |
||||
fixed(void* pCode = code) |
||||
corCode.GetCode(0, (uint)code.Length, (uint)code.Length, new IntPtr(pCode)); |
||||
return code; |
||||
} |
||||
} |
||||
} |
@ -1,45 +0,0 @@
@@ -1,45 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static IEnumerable<ICorDebugFrame> GetEnumerator(this ICorDebugFrameEnum corFrameEnum) |
||||
{ |
||||
// TODO: As list
|
||||
corFrameEnum.Reset(); |
||||
while (true) { |
||||
ICorDebugFrame corFrame = corFrameEnum.Next(); |
||||
if (corFrame != null) { |
||||
yield return corFrame; |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static ICorDebugFrame Next(this ICorDebugFrameEnum corFrameEnum) |
||||
{ |
||||
ICorDebugFrame[] corFrames = new ICorDebugFrame[1]; |
||||
uint framesFetched = corFrameEnum.Next(1, corFrames); |
||||
if (framesFetched == 0) { |
||||
return null; |
||||
} else { |
||||
return corFrames[0]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,89 +0,0 @@
@@ -1,89 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static unsafe Byte[] GetRawValue(this ICorDebugGenericValue corGenVal) |
||||
{ |
||||
// TODO: Unset fixing insead
|
||||
Byte[] retValue = new Byte[(int)corGenVal.GetSize()]; |
||||
IntPtr pValue = Marshal.AllocHGlobal(retValue.Length); |
||||
corGenVal.GetValue(pValue); |
||||
Marshal.Copy(pValue, retValue, 0, retValue.Length); |
||||
Marshal.FreeHGlobal(pValue); |
||||
return retValue; |
||||
} |
||||
|
||||
public static unsafe void SetRawValue(this ICorDebugGenericValue corGenVal, byte[] value) |
||||
{ |
||||
if (corGenVal.GetSize() != value.Length) throw new ArgumentException("Incorrect length"); |
||||
IntPtr pValue = Marshal.AllocHGlobal(value.Length); |
||||
Marshal.Copy(value, 0, pValue, value.Length); |
||||
corGenVal.SetValue(pValue); |
||||
Marshal.FreeHGlobal(pValue); |
||||
} |
||||
|
||||
public static unsafe object GetValue(this ICorDebugGenericValue corGenVal,Type type) |
||||
{ |
||||
object retValue; |
||||
IntPtr pValue = Marshal.AllocHGlobal((int)corGenVal.GetSize()); |
||||
corGenVal.GetValue(pValue); |
||||
switch(type.FullName) { |
||||
case "System.Boolean": retValue = *((System.Boolean*)pValue); break; |
||||
case "System.Char": retValue = *((System.Char*) pValue); break; |
||||
case "System.SByte": retValue = *((System.SByte*) pValue); break; |
||||
case "System.Byte": retValue = *((System.Byte*) pValue); break; |
||||
case "System.Int16": retValue = *((System.Int16*) pValue); break; |
||||
case "System.UInt16": retValue = *((System.UInt16*) pValue); break; |
||||
case "System.Int32": retValue = *((System.Int32*) pValue); break; |
||||
case "System.UInt32": retValue = *((System.UInt32*) pValue); break; |
||||
case "System.Int64": retValue = *((System.Int64*) pValue); break; |
||||
case "System.UInt64": retValue = *((System.UInt64*) pValue); break; |
||||
case "System.Single": retValue = *((System.Single*) pValue); break; |
||||
case "System.Double": retValue = *((System.Double*) pValue); break; |
||||
case "System.IntPtr": retValue = *((System.IntPtr*) pValue); break; |
||||
case "System.UIntPtr": retValue = *((System.UIntPtr*)pValue); break; |
||||
default: throw new NotSupportedException(); |
||||
} |
||||
Marshal.FreeHGlobal(pValue); |
||||
return retValue; |
||||
} |
||||
|
||||
public static unsafe void SetValue(this ICorDebugGenericValue corGenVal, Type type, object value) |
||||
{ |
||||
IntPtr pValue = Marshal.AllocHGlobal((int)corGenVal.GetSize()); |
||||
switch(type.FullName) { |
||||
case "System.Boolean": *((System.Boolean*)pValue) = (System.Boolean)value; break; |
||||
case "System.Char": *((System.Char*) pValue) = (System.Char) value; break; |
||||
case "System.SByte": *((System.SByte*) pValue) = (System.SByte) value; break; |
||||
case "System.Byte": *((System.Byte*) pValue) = (System.Byte) value; break; |
||||
case "System.Int16": *((System.Int16*) pValue) = (System.Int16) value; break; |
||||
case "System.UInt16": *((System.UInt16*) pValue) = (System.UInt16) value; break; |
||||
case "System.Int32": *((System.Int32*) pValue) = (System.Int32) value; break; |
||||
case "System.UInt32": *((System.UInt32*) pValue) = (System.UInt32) value; break; |
||||
case "System.Int64": *((System.Int64*) pValue) = (System.Int64) value; break; |
||||
case "System.UInt64": *((System.UInt64*) pValue) = (System.UInt64) value; break; |
||||
case "System.Single": *((System.Single*) pValue) = (System.Single) value; break; |
||||
case "System.Double": *((System.Double*) pValue) = (System.Double) value; break; |
||||
case "System.IntPtr": *((System.IntPtr*) pValue) = (System.IntPtr) value; break; |
||||
case "System.UIntPtr": *((System.UIntPtr*)pValue) = (System.UIntPtr)value; break; |
||||
default: throw new NotSupportedException(); |
||||
} |
||||
corGenVal.SetValue(pValue); |
||||
Marshal.FreeHGlobal(pValue); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
|
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static string GetName(this ICorDebugModule corModule) |
||||
{ |
||||
return Util.GetString(corModule.GetName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static bool HasQueuedCallbacks(this ICorDebugProcess corProcess) |
||||
{ |
||||
int pbQueued; |
||||
corProcess.HasQueuedCallbacks(null, out pbQueued); |
||||
return pbQueued != 0; |
||||
} |
||||
} |
||||
} |
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static unsafe void StepRange(this ICorDebugStepper corStepper, bool bStepIn, int[] ranges) |
||||
{ |
||||
fixed (int* pRanges = ranges) |
||||
corStepper.StepRange(bStepIn?1:0, (IntPtr)pRanges, (uint)ranges.Length / 2); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static string GetString(this ICorDebugStringValue corString) |
||||
{ |
||||
return Util.GetString(corString.GetString, 64, false); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorDebug |
||||
{ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
public static partial class CorDebugExtensionMethods |
||||
{ |
||||
public static IEnumerable<ICorDebugType> GetEnumerator(this ICorDebugTypeEnum corTypeEnum) |
||||
{ |
||||
corTypeEnum.Reset(); |
||||
while (true) { |
||||
ICorDebugType corType = corTypeEnum.Next(); |
||||
if (corType != null) { |
||||
yield return corType; |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static ICorDebugType Next(this ICorDebugTypeEnum corTypeEnum) |
||||
{ |
||||
ICorDebugType[] corTypes = new ICorDebugType[1]; |
||||
uint typesFetched = corTypeEnum.Next(1, corTypes); |
||||
if (typesFetched == 0) { |
||||
return null; |
||||
} else { |
||||
return corTypes[0]; |
||||
} |
||||
} |
||||
|
||||
public static List<ICorDebugType> ToList(this ICorDebugTypeEnum corTypeEnum) |
||||
{ |
||||
return new List<ICorDebugType>(corTypeEnum.GetEnumerator()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorSym |
||||
{ |
||||
using System; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
public static partial class CorSymExtensionMethods |
||||
{ |
||||
public static ISymUnmanagedReader GetReaderForFile(this ISymUnmanagedBinder symBinder, object importer, string filename, string searchPath) |
||||
{ |
||||
IntPtr pfilename = Marshal.StringToCoTaskMemUni(filename); |
||||
IntPtr psearchPath = Marshal.StringToCoTaskMemUni(searchPath); |
||||
ISymUnmanagedReader res = symBinder.GetReaderForFile(importer, pfilename, psearchPath); |
||||
Marshal.FreeCoTaskMem(pfilename); |
||||
Marshal.FreeCoTaskMem(psearchPath); |
||||
return res; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorSym |
||||
{ |
||||
using System; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
public static partial class CorSymExtensionMethods |
||||
{ |
||||
public static string GetURL(this ISymUnmanagedDocument symDoc) |
||||
{ |
||||
return Util.GetString(symDoc.GetURL, 256, true); |
||||
} |
||||
|
||||
public static byte[] GetCheckSum(this ISymUnmanagedDocument symDoc) |
||||
{ |
||||
uint checkSumLength = 0; |
||||
symDoc.GetCheckSum(checkSumLength, out checkSumLength, IntPtr.Zero); |
||||
IntPtr checkSumPtr = Marshal.AllocHGlobal((int)checkSumLength); |
||||
symDoc.GetCheckSum(checkSumLength, out checkSumLength, checkSumPtr); |
||||
byte[] checkSumBytes = new byte[checkSumLength]; |
||||
Marshal.Copy(checkSumPtr, checkSumBytes, 0, (int)checkSumLength); |
||||
Marshal.FreeHGlobal(checkSumPtr); |
||||
return checkSumBytes; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,57 +0,0 @@
@@ -1,57 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorSym |
||||
{ |
||||
using System; |
||||
|
||||
|
||||
public static partial class CorSymExtensionMethods |
||||
{ |
||||
public static SequencePoint[] GetSequencePoints(this ISymUnmanagedMethod symMethod) |
||||
{ |
||||
uint count = symMethod.GetSequencePointCount(); |
||||
|
||||
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]; |
||||
|
||||
symMethod.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; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorSym |
||||
{ |
||||
using System; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
public static partial class CorSymExtensionMethods |
||||
{ |
||||
public static ISymUnmanagedDocument GetDocument(this ISymUnmanagedReader symReader, string url, System.Guid language, System.Guid languageVendor, System.Guid documentType) |
||||
{ |
||||
IntPtr p = Marshal.StringToCoTaskMemUni(url); |
||||
ISymUnmanagedDocument res = symReader.GetDocument(p, language, languageVendor, documentType); |
||||
Marshal.FreeCoTaskMem(p); |
||||
return res; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,46 +0,0 @@
@@ -1,46 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorSym |
||||
{ |
||||
using System; |
||||
|
||||
|
||||
public static partial class CorSymExtensionMethods |
||||
{ |
||||
public static ISymUnmanagedScope[] GetChildren(this ISymUnmanagedScope symScope) |
||||
{ |
||||
uint count; |
||||
symScope.GetChildren(0, out count, new ISymUnmanagedScope[0]); |
||||
ISymUnmanagedScope[] children = new ISymUnmanagedScope[count]; |
||||
symScope.GetChildren(count, out count, children); |
||||
return children; |
||||
} |
||||
|
||||
public static ISymUnmanagedVariable[] GetLocals(this ISymUnmanagedScope symScope) |
||||
{ |
||||
uint count; |
||||
symScope.GetLocals(0, out count, new ISymUnmanagedVariable[0]); |
||||
ISymUnmanagedVariable[] locals = new ISymUnmanagedVariable[count]; |
||||
symScope.GetLocals(count, out count, locals); |
||||
return locals; |
||||
} |
||||
|
||||
public static ISymUnmanagedNamespace[] GetNamespaces(this ISymUnmanagedScope symScope) |
||||
{ |
||||
uint count; |
||||
symScope.GetNamespaces(0, out count, new ISymUnmanagedNamespace[0]); |
||||
ISymUnmanagedNamespace[] namespaces = new ISymUnmanagedNamespace[count]; |
||||
symScope.GetNamespaces(0, out count, namespaces); |
||||
return namespaces; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,38 +0,0 @@
@@ -1,38 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorSym |
||||
{ |
||||
using System; |
||||
|
||||
public static partial class CorSymExtensionMethods |
||||
{ |
||||
public static string GetName(this ISymUnmanagedVariable symVar) |
||||
{ |
||||
return Util.GetString(symVar.GetName); |
||||
} |
||||
|
||||
const int defaultSigSize = 8; |
||||
|
||||
public static unsafe byte[] GetSignature(this ISymUnmanagedVariable symVar) |
||||
{ |
||||
byte[] sig = new byte[defaultSigSize]; |
||||
uint acualSize; |
||||
fixed(byte* pSig = sig) |
||||
symVar.GetSignature((uint)sig.Length, out acualSize, new IntPtr(pSig)); |
||||
Array.Resize(ref sig, (int)acualSize); |
||||
if (acualSize > defaultSigSize) |
||||
fixed(byte* pSig = sig) |
||||
symVar.GetSignature((uint)sig.Length, out acualSize, new IntPtr(pSig)); |
||||
return sig; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
@ -1,82 +0,0 @@
@@ -1,82 +0,0 @@
|
||||
// <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>
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Debugger.Interop.CorSym |
||||
{ |
||||
using System; |
||||
using System.Collections; |
||||
|
||||
|
||||
public class SequencePoint: IComparable<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; |
||||
} |
||||
|
||||
public int CompareTo(SequencePoint other) |
||||
{ |
||||
if (this.Line == other.Line) { |
||||
return this.Column.CompareTo(other.Column); |
||||
} else { |
||||
return this.Line.CompareTo(other.Line); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#pragma warning restore 1591
|
Loading…
Reference in new issue