Browse files

Add debugger core.

Add new NRefactory.
Add editor margin & bookmarks.
  • Loading branch information...
1 parent 95ed5d8 commit c3ef036fd6fa7b6a2d41e36040c8272b1df5db7b @eusebiu eusebiu committed Feb 11, 2011
Showing with 24,791 additions and 0 deletions.
  1. +63 −0 Debugger/Debugger.Core/AppDomain.cs
  2. +24 −0 Debugger/Debugger.Core/AppDomainCollection.cs
  3. +70 −0 Debugger/Debugger.Core/ArrayDimension.cs
  4. +109 −0 Debugger/Debugger.Core/ArrayDimensions.cs
  5. +184 −0 Debugger/Debugger.Core/Breakpoint.cs
  6. +88 −0 Debugger/Debugger.Core/BreakpointCollection.cs
  7. +109 −0 Debugger/Debugger.Core/CollectionWithEvents.cs
  8. +28 −0 Debugger/Debugger.Core/DebuggeeState.cs
  9. +212 −0 Debugger/Debugger.Core/Debugger.Core.csproj
  10. +21 −0 Debugger/Debugger.Core/Debugger.Core.csproj.user
  11. +58 −0 Debugger/Debugger.Core/Debugger.Core.shfb
  12. +45 −0 Debugger/Debugger.Core/DebuggerException.cs
  13. +15 −0 Debugger/Debugger.Core/DebuggerObject.cs
  14. +416 −0 Debugger/Debugger.Core/Eval.cs
  15. +23 −0 Debugger/Debugger.Core/EvalCollection.cs
  16. +121 −0 Debugger/Debugger.Core/Exception.cs
  17. +13 −0 Debugger/Debugger.Core/ExceptionType.cs
  18. +56 −0 Debugger/Debugger.Core/GetValueException.cs
  19. +85 −0 Debugger/Debugger.Core/Interop/Common.cs
  20. +1,632 −0 Debugger/Debugger.Core/Interop/CorDebug.cs
  21. +242 −0 Debugger/Debugger.Core/Interop/CorDebugExtensionMethods.cs
  22. +3,342 −0 Debugger/Debugger.Core/Interop/CorDebugExtensionMethods.generated.cs
  23. +138 −0 Debugger/Debugger.Core/Interop/CorPublish.cs
  24. +15 −0 Debugger/Debugger.Core/Interop/CorPublishExtensionMethods.cs
  25. +273 −0 Debugger/Debugger.Core/Interop/CorPublishExtensionMethods.generated.cs
  26. +523 −0 Debugger/Debugger.Core/Interop/CorSym.cs
  27. +194 −0 Debugger/Debugger.Core/Interop/CorSymExtensionMethods.cs
  28. +901 −0 Debugger/Debugger.Core/Interop/CorSymExtensionMethods.generated.cs
  29. +252 −0 Debugger/Debugger.Core/Interop/MTA2STA.cs
  30. +278 −0 Debugger/Debugger.Core/Interop/MetaData.cs
  31. +1,122 −0 Debugger/Debugger.Core/Interop/MetaDataWrapper.cs
  32. +28 −0 Debugger/Debugger.Core/Interop/NativeMethods.cs
  33. +57 −0 Debugger/Debugger.Core/Interop/TrackedComObjects.cs
  34. +68 −0 Debugger/Debugger.Core/Interop/Util.cs
  35. +552 −0 Debugger/Debugger.Core/ManagedCallback.cs
  36. +420 −0 Debugger/Debugger.Core/ManagedCallbackProxy.cs
  37. +400 −0 Debugger/Debugger.Core/ManagedCallbackSwitch.cs
  38. +133 −0 Debugger/Debugger.Core/MetaData/DebugConstructorInfo.cs
  39. +131 −0 Debugger/Debugger.Core/MetaData/DebugFieldInfo.cs
  40. +61 −0 Debugger/Debugger.Core/MetaData/DebugLocalVariableInfo.cs
  41. +664 −0 Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs
  42. +67 −0 Debugger/Debugger.Core/MetaData/DebugParameterInfo.cs
  43. +244 −0 Debugger/Debugger.Core/MetaData/DebugPropertyInfo.cs
  44. +1,377 −0 Debugger/Debugger.Core/MetaData/DebugType.cs
  45. +21 −0 Debugger/Debugger.Core/MetaData/IDebugMemberInfo.cs
  46. +14 −0 Debugger/Debugger.Core/MetaData/IOverloadable.cs
  47. +408 −0 Debugger/Debugger.Core/Module.cs
  48. +50 −0 Debugger/Debugger.Core/ModuleCollection.cs
  49. +53 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs
  50. +49 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs
  51. +73 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs
  52. +55 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs
  53. +99 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs
  54. +58 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs
  55. +649 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs
  56. +43 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/Array.cs
  57. +43 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs
  58. +53 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs
  59. +41 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/Class.cs
  60. +37 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs
  61. +80 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs
  62. +48 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs
  63. +50 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs
  64. +41 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs
  65. +41 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs
  66. +46 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs
  67. +40 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs
  68. +35 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs
  69. +39 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs
  70. +38 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs
  71. +58 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs
  72. +42 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs
  73. +93 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs
  74. +48 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs
  75. +49 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs
  76. +50 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs
  77. +40 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs
  78. +33 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/Param.cs
  79. +52 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs
  80. +43 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs
  81. +39 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs
  82. +42 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs
  83. +50 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs
  84. +991 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs
  85. +520 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs
  86. +42 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs
  87. +36 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs
  88. +41 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs
  89. +42 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil.Signatures/Var.cs
  90. +43 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs
  91. +55 −0 Debugger/Debugger.Core/Mono.Cecil/Mono.Cecil/ReflectionException.cs
  92. +320 −0 Debugger/Debugger.Core/NDebugger.cs
  93. +334 −0 Debugger/Debugger.Core/NRefactory/Ast/ExpressionExtensionMethods.cs
  94. +1,015 −0 Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs
  95. +19 −0 Debugger/Debugger.Core/Options.cs
  96. +29 −0 Debugger/Debugger.Core/PauseSession.cs
  97. +22 −0 Debugger/Debugger.Core/PausedReason.cs
  98. +694 −0 Debugger/Debugger.Core/Process.cs
  99. +34 −0 Debugger/Debugger.Core/ProcessCollection.cs
  100. +22 −0 Debugger/Debugger.Core/ProcessEventArgs.cs
  101. +17 −0 Debugger/Debugger.Core/Properties/AssemblyInfo.cs
  102. +342 −0 Debugger/Debugger.Core/SourcecodeSegment.cs
  103. +408 −0 Debugger/Debugger.Core/StackFrame.cs
  104. +140 −0 Debugger/Debugger.Core/Stepper.cs
  105. +7 −0 Debugger/Debugger.Core/Stepping.txt
  106. +13 −0 Debugger/Debugger.Core/Tests/ExpandAttribute.cs
  107. +13 −0 Debugger/Debugger.Core/Tests/IgnoreAttribute.cs
  108. +13 −0 Debugger/Debugger.Core/Tests/IgnoreOnExceptionAttribute.cs
  109. +388 −0 Debugger/Debugger.Core/Thread.cs
  110. +53 −0 Debugger/Debugger.Core/ThreadCollection.cs
  111. +653 −0 Debugger/Debugger.Core/Value.cs
  112. +442 −0 Debugger/ILSpy.Debugger/AvalonEdit/Editor/AvalonEditDocumentAdapter.cs
  113. +98 −0 Debugger/ILSpy.Debugger/AvalonEdit/Editor/AvalonEditTextSourceAdapter.cs
  114. +85 −0 Debugger/ILSpy.Debugger/AvalonEdit/Editor/IDocument.cs
  115. +65 −0 Debugger/ILSpy.Debugger/AvalonEdit/Editor/IDocumentLine.cs
  116. +98 −0 Debugger/ILSpy.Debugger/AvalonEdit/Editor/ITextAnchor.cs
Sorry, we could not display the entire diff because it was too big.
View
63 Debugger/Debugger.Core/AppDomain.cs
@@ -0,0 +1,63 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using Debugger.Interop.CorDebug;
+using Debugger.MetaData;
+using System.Collections.Generic;
+
+namespace Debugger
+{
+ public class AppDomain: DebuggerObject
+ {
+ Process process;
+
+ ICorDebugAppDomain corAppDomain;
+
+ internal Dictionary<ICorDebugType, DebugType> DebugTypeCache = new Dictionary<ICorDebugType, DebugType>();
+
+ public Process Process {
+ get { return process; }
+ }
+
+ public uint ID {
+ get {
+ return corAppDomain.GetID();
+ }
+ }
+
+ Module mscorlib;
+
+ public Module Mscorlib {
+ get {
+ if (mscorlib != null) return mscorlib;
+ foreach(Module m in Process.Modules) {
+ if (m.Name == "mscorlib.dll" &&
+ m.AppDomain == this) {
+ mscorlib = m;
+ return mscorlib;
+ }
+ }
+ throw new DebuggerException("Mscorlib not loaded");
+ }
+ }
+
+ internal DebugType ObjectType {
+ get { return DebugType.CreateFromType(this.Mscorlib, typeof(object)); }
+ }
+
+ internal ICorDebugAppDomain CorAppDomain {
+ get { return corAppDomain; }
+ }
+
+ internal ICorDebugAppDomain2 CorAppDomain2 {
+ get { return (ICorDebugAppDomain2)corAppDomain; }
+ }
+
+ public AppDomain(Process process, ICorDebugAppDomain corAppDomain)
+ {
+ this.process = process;
+ this.corAppDomain = corAppDomain;
+ }
+ }
+}
View
24 Debugger/Debugger.Core/AppDomainCollection.cs
@@ -0,0 +1,24 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using Debugger.Interop.CorDebug;
+
+namespace Debugger
+{
+ public class AppDomainCollection: CollectionWithEvents<AppDomain>
+ {
+ public AppDomainCollection(NDebugger dbgr): base(dbgr) {}
+
+ public AppDomain this[ICorDebugAppDomain corAppDomain] {
+ get {
+ foreach(AppDomain a in this) {
+ if (a.CorAppDomain.Equals(corAppDomain)) {
+ return a;
+ }
+ }
+ throw new DebuggerException("AppDomain not found");
+ }
+ }
+ }
+}
View
70 Debugger/Debugger.Core/ArrayDimension.cs
@@ -0,0 +1,70 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace Debugger
+{
+ /// <summary>
+ /// Specifies the range of valid indicies for an array dimension
+ /// </summary>
+ public class ArrayDimension
+ {
+ int lowerBound;
+ int upperBound;
+
+ /// <summary> The smallest valid index in this dimension </summary>
+ public int LowerBound {
+ get { return lowerBound; }
+ }
+
+ /// <summary> The largest valid index in this dimension.
+ /// Returns LowerBound - 1 if the array is empty. </summary>
+ public int UpperBound {
+ get { return upperBound; }
+ }
+
+ /// <summary> The number of valid indicies of this dimension </summary>
+ public int Count {
+ get { return upperBound - lowerBound + 1; }
+ }
+
+ /// <summary> Determines whether the given index is a valid index for this dimension </summary>
+ public bool IsIndexValid(int index)
+ {
+ return (this.LowerBound <= index && index <= this.UpperBound);
+ }
+
+ public ArrayDimension(int lowerBound, int upperBound)
+ {
+ this.lowerBound = lowerBound;
+ this.upperBound = upperBound;
+ }
+
+ public override string ToString()
+ {
+ if (this.LowerBound == 0) {
+ return this.Count.ToString();
+ } else {
+ return this.LowerBound + ".." + this.UpperBound;
+ }
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = 0;
+ unchecked {
+ hashCode += 1000000007 * lowerBound.GetHashCode();
+ hashCode += 1000000009 * upperBound.GetHashCode();
+ }
+ return hashCode;
+ }
+
+ public override bool Equals(object obj)
+ {
+ ArrayDimension other = obj as ArrayDimension;
+ if (other == null) return false;
+ return this.lowerBound == other.lowerBound && this.upperBound == other.upperBound;
+ }
+ }
+}
View
109 Debugger/Debugger.Core/ArrayDimensions.cs
@@ -0,0 +1,109 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Debugger
+{
+ /// <summary>
+ /// Specifies the range of valid indicies for all array dimensions
+ /// </summary>
+ public class ArrayDimensions: IEnumerable<ArrayDimension>
+ {
+ List<ArrayDimension> dimensions = new List<ArrayDimension>();
+
+ public IEnumerator<ArrayDimension> GetEnumerator()
+ {
+ return dimensions.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)dimensions).GetEnumerator();
+ }
+
+ /// <summary> Gets a given dimension </summary>
+ public ArrayDimension this[int index] {
+ get {
+ return dimensions[index];
+ }
+ }
+
+ /// <summary> Get the number of dimensions of the array </summary>
+ public int Count {
+ get {
+ return dimensions.Count;
+ }
+ }
+
+ /// <summary> Get the total number of elements within the bounds
+ /// of an array specified by these dimensions. </summary>
+ public int TotalElementCount {
+ get {
+ int totalCount = 1;
+ foreach(ArrayDimension dim in this) {
+ totalCount *= dim.Count;
+ }
+ return totalCount;
+ }
+ }
+
+ /// <summary> Enumerate all vaild indicies in the array </summary>
+ public IEnumerable<int[]> Indices {
+ get {
+ foreach(ArrayDimension dim in this) {
+ if (dim.Count == 0) yield break;
+ }
+
+ int rank = this.Count;
+ int[] indices = new int[rank];
+ for(int i = 0; i < rank; i++) {
+ indices[i] = this[i].LowerBound;
+ }
+
+ while(true) { // Go thought all combinations
+ for (int i = rank - 1; i >= 1; i--) {
+ if (indices[i] > this[i].UpperBound) {
+ indices[i] = this[i].LowerBound;
+ indices[i - 1]++;
+ }
+ }
+ if (indices[0] > this[0].UpperBound) yield break; // We are done
+
+ yield return (int[])indices.Clone();
+
+ indices[rank - 1]++;
+ }
+ }
+ }
+
+ /// <summary> Determines whether the given index is a valid index for the array </summary>
+ public bool IsIndexValid(int[] indices)
+ {
+ for (int i = 0; i < this.Count; i++) {
+ if (!this[i].IsIndexValid(indices[i])) return false;
+ }
+ return true;
+ }
+
+ public ArrayDimensions(List<ArrayDimension> dimensions)
+ {
+ this.dimensions = dimensions;
+ }
+
+ public override string ToString()
+ {
+ string result = "[";
+ bool isFirst = true;
+ foreach(ArrayDimension dim in this) {
+ if (!isFirst) result += ", ";
+ result += dim.ToString();
+ isFirst = false;
+ }
+ result += "]";
+ return result;
+ }
+ }
+}
View
184 Debugger/Debugger.Core/Breakpoint.cs
@@ -0,0 +1,184 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+using Debugger.Interop.CorDebug;
+
+namespace Debugger
+{
+ public class Breakpoint: DebuggerObject
+ {
+ NDebugger debugger;
+
+ string fileName;
+ byte[] checkSum;
+ int line;
+ int column;
+ bool enabled;
+
+ SourcecodeSegment originalLocation;
+
+ List<ICorDebugFunctionBreakpoint> corBreakpoints = new List<ICorDebugFunctionBreakpoint>();
+
+ public event EventHandler<BreakpointEventArgs> Hit;
+ public event EventHandler<BreakpointEventArgs> Set;
+
+ [Debugger.Tests.Ignore]
+ public NDebugger Debugger {
+ get { return debugger; }
+ }
+
+ public string FileName {
+ get { return fileName; }
+ }
+
+ public byte[] CheckSum {
+ get { return checkSum; }
+ }
+
+ public int Line {
+ get { return line; }
+ set { line = value; }
+ }
+
+ public int Column {
+ get { return column; }
+ }
+
+ public bool Enabled {
+ get { return enabled; }
+ set {
+ enabled = value;
+ foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) {
+ corBreakpoint.Activate(enabled ? 1 : 0);
+ }
+ }
+ }
+
+ public SourcecodeSegment OriginalLocation {
+ get { return originalLocation; }
+ }
+
+ public bool IsSet {
+ get {
+ return corBreakpoints.Count > 0;
+ }
+ }
+
+ protected virtual void OnHit(BreakpointEventArgs e)
+ {
+ if (Hit != null) {
+ Hit(this, e);
+ }
+ }
+
+ internal void NotifyHit()
+ {
+ OnHit(new BreakpointEventArgs(this));
+ debugger.Breakpoints.OnHit(this);
+ }
+
+ protected virtual void OnSet(BreakpointEventArgs e)
+ {
+ if (Set != null) {
+ Set(this, e);
+ }
+ }
+
+ public Breakpoint(NDebugger debugger, ICorDebugFunctionBreakpoint corBreakpoint)
+ {
+ this.debugger = debugger;
+ this.corBreakpoints.Add(corBreakpoint);
+ }
+
+ public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled)
+ {
+ this.debugger = debugger;
+ this.fileName = fileName;
+ this.checkSum = checkSum;
+ this.line = line;
+ this.column = column;
+ this.enabled = enabled;
+ }
+
+ internal bool IsOwnerOf(ICorDebugBreakpoint breakpoint)
+ {
+ foreach(ICorDebugFunctionBreakpoint corFunBreakpoint in corBreakpoints) {
+ if (((ICorDebugBreakpoint)corFunBreakpoint).Equals(breakpoint)) return true;
+ }
+ return false;
+ }
+
+ internal void Deactivate()
+ {
+ foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) {
+ #if DEBUG
+ // Get repro
+ corBreakpoint.Activate(0);
+ #else
+ try {
+ corBreakpoint.Activate(0);
+ } catch(COMException e) {
+ // Sometimes happens, but we had not repro yet.
+ // 0x80131301: Process was terminated.
+ if ((uint)e.ErrorCode == 0x80131301)
+ continue;
+ throw;
+ }
+ #endif
+ }
+ corBreakpoints.Clear();
+ }
+
+ internal void MarkAsDeactivated()
+ {
+ corBreakpoints.Clear();
+ }
+
+ internal bool SetBreakpoint(Module module)
+ {
+ if (this.fileName == null)
+ return false;
+
+ SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column);
+ if (segment == null) return false;
+
+ originalLocation = segment;
+
+ ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart);
+ corBreakpoint.Activate(enabled ? 1 : 0);
+
+ corBreakpoints.Add(corBreakpoint);
+
+ OnSet(new BreakpointEventArgs(this));
+
+ return true;
+ }
+
+ /// <summary> Remove this breakpoint </summary>
+ public void Remove()
+ {
+ debugger.Breakpoints.Remove(this);
+ }
+ }
+
+ [Serializable]
+ public class BreakpointEventArgs : DebuggerEventArgs
+ {
+ Breakpoint breakpoint;
+
+ public Breakpoint Breakpoint {
+ get {
+ return breakpoint;
+ }
+ }
+
+ public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger)
+ {
+ this.breakpoint = breakpoint;
+ }
+ }
+}
View
88 Debugger/Debugger.Core/BreakpointCollection.cs
@@ -0,0 +1,88 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using Debugger.Interop.CorDebug;
+
+namespace Debugger
+{
+ public class BreakpointCollection: CollectionWithEvents<Breakpoint>
+ {
+ public event EventHandler<CollectionItemEventArgs<Breakpoint>> Hit;
+
+ protected internal void OnHit(Breakpoint item)
+ {
+ if (Hit != null) {
+ Hit(this, new CollectionItemEventArgs<Breakpoint>(item));
+ }
+ }
+
+ public BreakpointCollection(NDebugger debugger):base(debugger) { }
+
+ internal Breakpoint this[ICorDebugBreakpoint corBreakpoint] {
+ get {
+ foreach (Breakpoint breakpoint in this) {
+ if (breakpoint.IsOwnerOf(corBreakpoint)) {
+ return breakpoint;
+ }
+ }
+ return null;
+ }
+ }
+
+ public new void Add(Breakpoint breakpoint)
+ {
+ base.Add(breakpoint);
+ }
+
+ public Breakpoint Add(string filename, int line)
+ {
+ Breakpoint breakpoint = new Breakpoint(this.Debugger, filename, null, line, 0, true);
+ Add(breakpoint);
+ return breakpoint;
+ }
+
+ public Breakpoint Add(string fileName, byte[] checkSum, int line, int column, bool enabled)
+ {
+ Breakpoint breakpoint = new Breakpoint(this.Debugger, fileName, checkSum, line, column, enabled);
+ Add(breakpoint);
+ return breakpoint;
+ }
+
+ protected override void OnAdded(Breakpoint breakpoint)
+ {
+ foreach(Process process in this.Debugger.Processes) {
+ foreach(Module module in process.Modules) {
+ breakpoint.SetBreakpoint(module);
+ }
+ }
+
+ base.OnAdded(breakpoint);
+ }
+
+ public new void Remove(Breakpoint breakpoint)
+ {
+ base.Remove(breakpoint);
+ }
+
+ protected override void OnRemoved(Breakpoint breakpoint)
+ {
+ breakpoint.Deactivate();
+
+ base.OnRemoved(breakpoint);
+ }
+
+ internal void SetInModule(Module module)
+ {
+ // This is in case that the client modifies the collection as a response to set breakpoint
+ // NB: If client adds new breakpoint, it will be set directly as a result of his call, not here (because module is already loaded)
+ List<Breakpoint> collection = new List<Breakpoint>();
+ collection.AddRange(this);
+
+ foreach (Breakpoint b in collection) {
+ b.SetBreakpoint(module);
+ }
+ }
+ }
+}
View
109 Debugger/Debugger.Core/CollectionWithEvents.cs
@@ -0,0 +1,109 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Debugger
+{
+ public class CollectionItemEventArgs<T> : EventArgs
+ {
+ T item;
+
+ public T Item {
+ get {
+ return item;
+ }
+ }
+
+ public CollectionItemEventArgs(T item)
+ {
+ this.item = item;
+ }
+ }
+
+ /// <summary>
+ /// A collection that fires events when items are added or removed.
+ /// </summary>
+ public class CollectionWithEvents<T> : IEnumerable<T>
+ {
+ NDebugger debugger;
+
+ List<T> list = new List<T>();
+
+ public event EventHandler<CollectionItemEventArgs<T>> Added;
+ public event EventHandler<CollectionItemEventArgs<T>> Removed;
+
+ protected virtual void OnAdded(T item)
+ {
+ if (Added != null) {
+ Added(this, new CollectionItemEventArgs<T>(item));
+ }
+ }
+
+ protected virtual void OnRemoved(T item)
+ {
+ if (Removed != null) {
+ Removed(this, new CollectionItemEventArgs<T>(item));
+ }
+ }
+
+ public CollectionWithEvents(NDebugger debugger)
+ {
+ this.debugger = debugger;
+ }
+
+ protected NDebugger Debugger {
+ get {
+ return debugger;
+ }
+ }
+
+ public int Count {
+ get {
+ return list.Count;
+ }
+ }
+
+ public T this[int index] {
+ get {
+ return list[index];
+ }
+ }
+
+ internal void Add(T item)
+ {
+ list.Add(item);
+ OnAdded(item);
+ }
+
+ internal void Remove(T item)
+ {
+ if (list.Remove(item)) {
+ OnRemoved(item);
+ } else {
+ throw new DebuggerException("Item is not in the collection");
+ }
+ }
+
+ internal void Clear()
+ {
+ List<T> oldList = list;
+ list = new List<T>();
+ foreach (T item in oldList) {
+ OnRemoved(item);
+ }
+ }
+
+ IEnumerator<T> IEnumerable<T>.GetEnumerator()
+ {
+ return list.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return list.GetEnumerator();
+ }
+ }
+}
View
28 Debugger/Debugger.Core/DebuggeeState.cs
@@ -0,0 +1,28 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+namespace Debugger
+{
+ /// <summary>
+ /// Represents span of time in which the debugger state is assumed to
+ /// be unchanged.
+ /// </summary>
+ /// <remarks>
+ /// For example, although property evaluation can in theory change
+ /// any memory, it is assumed that they behave 'correctly' and thus
+ /// property evaluation does not change debugger state.
+ /// </remarks>
+ public class DebuggeeState: DebuggerObject
+ {
+ Process process;
+
+ public Process Process {
+ get { return process; }
+ }
+
+ public DebuggeeState(Process process)
+ {
+ this.process = process;
+ }
+ }
+}
View
212 Debugger/Debugger.Core/Debugger.Core.csproj
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Debugger</RootNamespace>
+ <AssemblyName>Debugger.Core</AssemblyName>
+ <AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
+ <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+ <NoStdLib>False</NoStdLib>
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+ <BaseAddress>114294784</BaseAddress>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <FileAlignment>4096</FileAlignment>
+ <WarningLevel>4</WarningLevel>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <OutputPath>..\..\..\..\AddIns\Debugger\</OutputPath>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ <PublishUrl>http://localhost/Debugger.Core/</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Web</InstallFrom>
+ <UpdateEnabled>true</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>true</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>Full</DebugType>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <Optimize>False</Optimize>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>PdbOnly</DebugType>
+ <Optimize>true</Optimize>
+ <DefineConstants>TRACE</DefineConstants>
+ <DebugSymbols>false</DebugSymbols>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Windows.Forms" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\MTA2STA.cs" />
+ <Compile Include="ManagedCallback.cs" />
+ <Compile Include="ManagedCallbackProxy.cs" />
+ <Compile Include="ManagedCallbackSwitch.cs" />
+ <Compile Include="MetaData\DebugConstructorInfo.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="AppDomain.cs" />
+ <Compile Include="AppDomainCollection.cs" />
+ <Compile Include="ArrayDimension.cs" />
+ <Compile Include="ArrayDimensions.cs" />
+ <Compile Include="Breakpoint.cs" />
+ <Compile Include="BreakpointCollection.cs" />
+ <Compile Include="CollectionWithEvents.cs" />
+ <Compile Include="DebuggeeState.cs" />
+ <Compile Include="DebuggerException.cs" />
+ <Compile Include="DebuggerObject.cs" />
+ <Compile Include="Eval.cs" />
+ <Compile Include="EvalCollection.cs" />
+ <Compile Include="Exception.cs" />
+ <Compile Include="ExceptionType.cs" />
+ <Compile Include="GetValueException.cs" />
+ <Compile Include="Interop\Common.cs" />
+ <Compile Include="Interop\CorDebug.cs" />
+ <Compile Include="Interop\CorDebugExtensionMethods.cs" />
+ <Compile Include="Interop\CorDebugExtensionMethods.generated.cs" />
+ <Compile Include="Interop\CorPublish.cs" />
+ <Compile Include="Interop\CorPublishExtensionMethods.cs" />
+ <Compile Include="Interop\CorPublishExtensionMethods.generated.cs" />
+ <Compile Include="Interop\CorSym.cs" />
+ <Compile Include="Interop\CorSymExtensionMethods.cs" />
+ <Compile Include="Interop\CorSymExtensionMethods.generated.cs" />
+ <Compile Include="Interop\MetaData.cs" />
+ <Compile Include="Interop\MetaDataWrapper.cs" />
+ <Compile Include="Interop\NativeMethods.cs" />
+ <Compile Include="Interop\TrackedComObjects.cs" />
+ <Compile Include="Interop\Util.cs" />
+ <Compile Include="MetaData\DebugFieldInfo.cs" />
+ <Compile Include="MetaData\DebugLocalVariableInfo.cs" />
+ <Compile Include="MetaData\DebugMethodInfo.cs" />
+ <Compile Include="MetaData\DebugParameterInfo.cs" />
+ <Compile Include="MetaData\DebugPropertyInfo.cs" />
+ <Compile Include="MetaData\DebugType.cs" />
+ <Compile Include="MetaData\IDebugMemberInfo.cs" />
+ <Compile Include="MetaData\IOverloadable.cs" />
+ <Compile Include="Module.cs" />
+ <Compile Include="ModuleCollection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ImageFormatException.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\CodedIndex.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ElementType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataFormatException.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataToken.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TokenType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Utilities.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Array.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ArrayShape.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\BaseSignatureVisitor.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Class.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Constraint.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\CustomMod.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\FieldSig.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\FnPtr.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\GenericArg.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\GenericInst.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\GenericInstSignature.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\InputOutputItem.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ISignatureVisitable.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ISignatureVisitor.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\LocalVarSig.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodDefSig.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodRefSig.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodSig.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodSpec.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MVar.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Param.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\PropertySig.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Ptr.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\RetType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Signature.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\SignatureReader.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\SigType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\SzArray.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\TypeSpec.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ValueType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Var.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\MethodCallingConvention.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\ReflectionException.cs" />
+ <Compile Include="NDebugger.cs" />
+ <Compile Include="NRefactory\Ast\ExpressionExtensionMethods.cs" />
+ <Compile Include="NRefactory\Visitors\ExpressionEvaluator.cs" />
+ <Compile Include="Options.cs" />
+ <Compile Include="PausedReason.cs" />
+ <Compile Include="PauseSession.cs" />
+ <Compile Include="Process.cs" />
+ <Compile Include="ProcessCollection.cs" />
+ <Compile Include="ProcessEventArgs.cs" />
+ <Compile Include="SourcecodeSegment.cs" />
+ <Compile Include="StackFrame.cs" />
+ <Compile Include="Stepper.cs" />
+ <Compile Include="Tests\ExpandAttribute.cs" />
+ <Compile Include="Tests\IgnoreAttribute.cs" />
+ <Compile Include="Tests\IgnoreOnExceptionAttribute.cs" />
+ <Compile Include="Thread.cs" />
+ <Compile Include="ThreadCollection.cs" />
+ <Compile Include="Value.cs" />
+ <None Include="Stepping.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Interop" />
+ <Folder Include="MetaData" />
+ <Folder Include="Mono.Cecil" />
+ <Folder Include="Mono.Cecil\Mono.Cecil" />
+ <Folder Include="Mono.Cecil\Mono.Cecil.Binary" />
+ <Folder Include="Mono.Cecil\Mono.Cecil.Metadata" />
+ <Folder Include="Mono.Cecil\Mono.Cecil.Signatures" />
+ <Folder Include="NRefactory" />
+ <Folder Include="NRefactory\Ast" />
+ <Folder Include="NRefactory\Visitors" />
+ <Folder Include="Tests" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Decompiler\lib\NRefactory\Project\NRefactory.csproj">
+ <Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
+ <Name>NRefactory</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
+</Project>
View
21 Debugger/Debugger.Core/Debugger.Core.csproj.user
@@ -0,0 +1,21 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <LastOpenVersion>8.0.50215</LastOpenVersion>
+ <ProjectView>ProjectFiles</ProjectView>
+ <ProjectTrust>0</ProjectTrust>
+ <PublishUrlHistory>
+ </PublishUrlHistory>
+ <InstallUrlHistory>
+ </InstallUrlHistory>
+ <SupportUrlHistory>
+ </SupportUrlHistory>
+ <UpdateUrlHistory>
+ </UpdateUrlHistory>
+ <BootstrapperUrlHistory>
+ </BootstrapperUrlHistory>
+ <ErrorReportUrlHistory>
+ </ErrorReportUrlHistory>
+ <FallbackCulture>en-US</FallbackCulture>
+ <VerifyUploadedFiles>true</VerifyUploadedFiles>
+ </PropertyGroup>
+</Project>
View
58 Debugger/Debugger.Core/Debugger.Core.shfb
@@ -0,0 +1,58 @@
+<project schemaVersion="1.6.0.2">
+ <assemblies>
+ <assembly assemblyPath="..\..\..\..\..\..\AddIns\AddIns\Misc\Debugger\Debugger.Core.dll" xmlCommentsPath="..\..\..\..\..\..\AddIns\AddIns\Misc\Debugger\Debugger.Core.xml" commentsOnly="False" />
+ </assemblies>
+ <namespaceSummaries>
+ <namespaceSummaryItem name="" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger" isDocumented="True" />
+ <namespaceSummaryItem name="Debugger.Expressions" isDocumented="True" />
+ <namespaceSummaryItem name="Debugger.Interop" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Interop.CorDebug" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Interop.CorSym" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Interop.MetaData" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.MetaData" isDocumented="True" />
+ <namespaceSummaryItem name="Debugger.Tests" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Util" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Wrappers" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Wrappers.CorDebug" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Wrappers.CorSym" isDocumented="False" />
+ <namespaceSummaryItem name="Debugger.Wrappers.MetaData" isDocumented="False" />
+ </namespaceSummaries>
+ <ProjectSummary>This library provides features for debugging managed applications.</ProjectSummary>
+ <MissingTags>Summary, Parameter, Returns, AutoDocumentCtors, Namespace</MissingTags>
+ <VisibleItems>InheritedMembers, Protected, SealedProtected</VisibleItems>
+ <HtmlHelp1xCompilerPath path="" />
+ <HtmlHelp2xCompilerPath path="" />
+ <OutputPath>.\docs\</OutputPath>
+ <SandcastlePath path="" />
+ <WorkingPath path="" />
+ <CleanIntermediates>True</CleanIntermediates>
+ <KeepLogFile>True</KeepLogFile>
+ <HelpFileFormat>HtmlHelp1x</HelpFileFormat>
+ <PurgeDuplicateTopics>True</PurgeDuplicateTopics>
+ <CppCommentsFixup>False</CppCommentsFixup>
+ <FrameworkVersion>2.0.50727</FrameworkVersion>
+ <BinaryTOC>True</BinaryTOC>
+ <IncludeFavorites>False</IncludeFavorites>
+ <Preliminary>False</Preliminary>
+ <RootNamespaceContainer>False</RootNamespaceContainer>
+ <RootNamespaceTitle />
+ <HelpTitle>Managed Debugger</HelpTitle>
+ <HtmlHelpName>Managed Debugger</HtmlHelpName>
+ <Language>en-US</Language>
+ <CopyrightHref />
+ <CopyrightText>2005-2008 David Srbecký</CopyrightText>
+ <FeedbackEMailAddress>dsrbecky@gmail.com</FeedbackEMailAddress>
+ <HeaderText />
+ <FooterText />
+ <ProjectLinkType>Local</ProjectLinkType>
+ <SdkLinkType>Msdn</SdkLinkType>
+ <SdkLinkTarget>Blank</SdkLinkTarget>
+ <PresentationStyle>Prototype</PresentationStyle>
+ <NamingMethod>Guid</NamingMethod>
+ <SyntaxFilters>Standard</SyntaxFilters>
+ <ShowFeedbackControl>False</ShowFeedbackControl>
+ <ContentPlacement>AboveNamespaces</ContentPlacement>
+ <ContentSiteMap path="" />
+ <TopicFileTransform path="" />
+</project>
View
45 Debugger/Debugger.Core/DebuggerException.cs
@@ -0,0 +1,45 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+namespace Debugger
+{
+ /// <summary>
+ /// Type of exception thrown by the Debugger.
+ /// </summary>
+ public class DebuggerException: System.Exception
+ {
+ public DebuggerException() {}
+ public DebuggerException(string message): base(message) {}
+ public DebuggerException(string message, params object[] args): base(string.Format(message, args)) {}
+ public DebuggerException(string message, System.Exception inner): base(message, inner) {}
+ }
+
+ /// <summary>
+ /// An exception that is thrown when the debugged process unexpectedly exits.
+ /// </summary>
+ public class ProcessExitedException: DebuggerException
+ {
+ string processName = null;
+
+ /// <summary>
+ /// The name of the process that has exited.
+ /// </summary>
+ public string ProcessName {
+ get { return processName; }
+ }
+
+ /// <summary>
+ /// Creates a ProcessExitedException for an unnamed process.
+ /// </summary>
+ public ProcessExitedException(): base("Process exited") {}
+
+ /// <summary>
+ /// Creates a ProcessExitedException for a process.
+ /// </summary>
+ /// <param name="processName">The name of the process</param>
+ public ProcessExitedException(string processName): base(string.Format("Process '{0}' exited.", processName)) {
+ this.processName = processName;
+ }
+
+ }
+}
View
15 Debugger/Debugger.Core/DebuggerObject.cs
@@ -0,0 +1,15 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace Debugger
+{
+ /// <summary>
+ /// A base class for all classes declared by the debugger
+ /// </summary>
+ public class DebuggerObject: MarshalByRefObject
+ {
+
+ }
+}
View
416 Debugger/Debugger.Core/Eval.cs
@@ -0,0 +1,416 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+using Debugger.MetaData;
+using Debugger.Interop.CorDebug;
+
+namespace Debugger
+{
+ public enum EvalState {
+ Evaluating,
+ EvaluatedSuccessfully,
+ EvaluatedException,
+ EvaluatedNoResult,
+ EvaluatedTimeOut,
+ };
+
+ /// <summary>
+ /// This class holds information about function evaluation.
+ /// </summary>
+ public class Eval: DebuggerObject
+ {
+ delegate void EvalStarter(Eval eval);
+
+ AppDomain appDomain;
+ Process process;
+
+ string description;
+ ICorDebugEval corEval;
+ Thread thread;
+ Value result;
+ EvalState state;
+
+ public AppDomain AppDomain {
+ get { return appDomain; }
+ }
+
+ public Process Process {
+ get { return process; }
+ }
+
+ public string Description {
+ get { return description; }
+ }
+
+ public ICorDebugEval CorEval {
+ get { return corEval; }
+ }
+
+ public ICorDebugEval2 CorEval2 {
+ get { return (ICorDebugEval2)corEval; }
+ }
+
+ /// <exception cref="GetValueException">Evaluating...</exception>
+ public Value Result {
+ get {
+ switch(this.State) {
+ case EvalState.Evaluating: throw new GetValueException("Evaluating...");
+ case EvalState.EvaluatedSuccessfully: return result;
+ case EvalState.EvaluatedException: return result;
+ case EvalState.EvaluatedNoResult: return null;
+ case EvalState.EvaluatedTimeOut: throw new GetValueException("Timeout");
+ default: throw new DebuggerException("Unknown state");
+ }
+ }
+ }
+
+ public EvalState State {
+ get { return state; }
+ }
+
+ public bool Evaluated {
+ get {
+ return state == EvalState.EvaluatedSuccessfully ||
+ state == EvalState.EvaluatedException ||
+ state == EvalState.EvaluatedNoResult ||
+ state == EvalState.EvaluatedTimeOut;
+ }
+ }
+
+ Eval(AppDomain appDomain, string description, EvalStarter evalStarter)
+ {
+ this.appDomain = appDomain;
+ this.process = appDomain.Process;
+ this.description = description;
+ this.state = EvalState.Evaluating;
+ this.thread = GetEvaluationThread(appDomain);
+ this.corEval = thread.CorThread.CreateEval();
+
+ try {
+ evalStarter(this);
+ } catch (COMException e) {
+ if ((uint)e.ErrorCode == 0x80131C26) {
+ throw new GetValueException("Can not evaluate in optimized code");
+ } else if ((uint)e.ErrorCode == 0x80131C28) {
+ throw new GetValueException("Object is in wrong AppDomain");
+ } else if ((uint)e.ErrorCode == 0x8013130A) {
+ // Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
+ throw new GetValueException("Function does not have IL code");
+ } else if ((uint)e.ErrorCode == 0x80131C23) {
+ // The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
+ // This can probably happen when we break and the thread is in native code
+ throw new GetValueException("Thread is in GC unsafe point");
+ } else if ((uint)e.ErrorCode == 0x80131C22) {
+ // The operation is illegal because of a stack overflow.
+ throw new GetValueException("Can not evaluate after stack overflow");
+ } else if ((uint)e.ErrorCode == 0x80131313) {
+ // Func eval cannot work. Bad starting point.
+ // Reproduction circumstancess are unknown
+ throw new GetValueException("Func eval cannot work. Bad starting point.");
+ } else {
+ #if DEBUG
+ throw; // Expose for more diagnostics
+ #else
+ throw new GetValueException(e.Message);
+ #endif
+ }
+ }
+
+ appDomain.Process.ActiveEvals.Add(this);
+
+ if (appDomain.Process.Options.SuspendOtherThreads) {
+ appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { thread }, CorDebugThreadState.THREAD_SUSPEND);
+ } else {
+ appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, this.Process.UnsuspendedThreads, CorDebugThreadState.THREAD_RUN);
+ }
+ }
+
+ static Thread GetEvaluationThread(AppDomain appDomain)
+ {
+ appDomain.Process.AssertPaused();
+
+ Thread st = appDomain.Process.SelectedThread;
+ if (st != null && !st.Suspended && !st.IsInNativeCode && st.IsAtSafePoint && st.CorThread.GetAppDomain().GetID() == appDomain.ID) {
+ return st;
+ }
+
+ foreach(Thread t in appDomain.Process.Threads) {
+ if (!t.Suspended && !t.IsInNativeCode && t.IsAtSafePoint && t.CorThread.GetAppDomain().GetID() == appDomain.ID) {
+ return t;
+ }
+ }
+
+ throw new GetValueException("No suitable thread for evaluation");
+ }
+
+ internal bool IsCorEval(ICorDebugEval corEval)
+ {
+ return this.corEval == corEval;
+ }
+
+ /// <exception cref="DebuggerException">Evaluation can not be stopped</exception>
+ /// <exception cref="GetValueException">Process exited</exception>
+ Value WaitForResult()
+ {
+ // Note that aborting is not supported for suspended threads
+ try {
+ process.WaitForPause(TimeSpan.FromMilliseconds(500));
+ if (!Evaluated) {
+ process.TraceMessage("Aborting eval: " + Description);
+ this.CorEval.Abort();
+ process.WaitForPause(TimeSpan.FromMilliseconds(2500));
+ if (!Evaluated) {
+ process.TraceMessage("Rude aborting eval: " + Description);
+ this.CorEval2.RudeAbort();
+ process.WaitForPause(TimeSpan.FromMilliseconds(5000));
+ if (!Evaluated) {
+ throw new DebuggerException("Evaluation can not be stopped");
+ }
+ }
+ // Note that this sets Evaluated to true
+ state = EvalState.EvaluatedTimeOut;
+ }
+ process.AssertPaused();
+ return this.Result;
+ } catch (ProcessExitedException) {
+ throw new GetValueException("Process exited");
+ }
+ }
+
+ internal void NotifyEvaluationComplete(bool successful)
+ {
+ // Eval result should be ICorDebugHandleValue so it should survive Continue()
+ if (state == EvalState.EvaluatedTimeOut) {
+ return;
+ }
+ if (corEval.GetResult() == null) {
+ state = EvalState.EvaluatedNoResult;
+ } else {
+ if (successful) {
+ state = EvalState.EvaluatedSuccessfully;
+ } else {
+ state = EvalState.EvaluatedException;
+ }
+ result = new Value(AppDomain, corEval.GetResult());
+ }
+ }
+
+ /// <summary> Synchronously calls a function and returns its return value </summary>
+ public static Value InvokeMethod(DebugMethodInfo method, Value thisValue, Value[] args)
+ {
+ if (method.BackingField != null) {
+ method.Process.TraceMessage("Using backing field for " + method.FullName);
+ return Value.GetMemberValue(thisValue, method.BackingField, args);
+ }
+ return AsyncInvokeMethod(method, thisValue, args).WaitForResult();
+ }
+
+ public static Eval AsyncInvokeMethod(DebugMethodInfo method, Value thisValue, Value[] args)
+ {
+ return new Eval(
+ method.AppDomain,
+ "Function call: " + method.FullName,
+ delegate(Eval eval) {
+ MethodInvokeStarter(eval, method, thisValue, args);
+ }
+ );
+ }
+
+ /// <exception cref="GetValueException"><c>GetValueException</c>.</exception>
+ static void MethodInvokeStarter(Eval eval, DebugMethodInfo method, Value thisValue, Value[] args)
+ {
+ List<ICorDebugValue> corArgs = new List<ICorDebugValue>();
+ args = args ?? new Value[0];
+ if (args.Length != method.ParameterCount) {
+ throw new GetValueException("Invalid parameter count");
+ }
+ if (!method.IsStatic) {
+ if (thisValue == null)
+ throw new GetValueException("'this' is null");
+ if (thisValue.IsNull)
+ throw new GetValueException("Null reference");
+ // if (!(thisValue.IsObject)) // eg Can evaluate on array
+ if (!method.DeclaringType.IsInstanceOfType(thisValue)) {
+ throw new GetValueException(
+ "Can not evaluate because the object is not of proper type. " +
+ "Expected: " + method.DeclaringType.FullName + " Seen: " + thisValue.Type.FullName
+ );
+ }
+ corArgs.Add(thisValue.CorValue);
+ }
+ for(int i = 0; i < args.Length; i++) {
+ Value arg = args[i];
+ DebugType paramType = (DebugType)method.GetParameters()[i].ParameterType;
+ if (!arg.Type.CanImplicitelyConvertTo(paramType))
+ throw new GetValueException("Inncorrect parameter type");
+ // Implicitely convert to correct primitve type
+ if (paramType.IsPrimitive && args[i].Type != paramType) {
+ object oldPrimVal = arg.PrimitiveValue;
+ object newPrimVal = Convert.ChangeType(oldPrimVal, paramType.PrimitiveType);
+ arg = CreateValue(method.AppDomain, newPrimVal);
+ }
+ // It is importatnt to pass the parameted in the correct form (boxed/unboxed)
+ if (paramType.IsValueType) {
+ corArgs.Add(arg.CorGenericValue);
+ } else {
+ if (args[i].Type.IsValueType) {
+ corArgs.Add(arg.Box().CorValue);
+ } else {
+ corArgs.Add(arg.CorValue);
+ }
+ }
+ }
+
+ ICorDebugType[] genericArgs = ((DebugType)method.DeclaringType).GenericArgumentsAsCorDebugType;
+ eval.CorEval2.CallParameterizedFunction(
+ method.CorFunction,
+ (uint)genericArgs.Length, genericArgs,
+ (uint)corArgs.Count, corArgs.ToArray()
+ );
+ }
+
+ public static Value CreateValue(AppDomain appDomain, object value)
+ {
+ if (value == null) {
+ ICorDebugClass corClass = appDomain.ObjectType.CorType.GetClass();
+ Thread thread = GetEvaluationThread(appDomain);
+ ICorDebugEval corEval = thread.CorThread.CreateEval();
+ ICorDebugValue corValue = corEval.CreateValue((uint)CorElementType.CLASS, corClass);
+ return new Value(appDomain, corValue);
+ } else if (value is string) {
+ return Eval.NewString(appDomain, (string)value);
+ } else {
+ if (!value.GetType().IsPrimitive)
+ throw new DebuggerException("Value must be primitve type. Seen " + value.GetType());
+ Value val = Eval.NewObjectNoConstructor(DebugType.CreateFromType(appDomain.Mscorlib, value.GetType()));
+ val.PrimitiveValue = value;
+ return val;
+ }
+ }
+
+ /*
+ // The following function create values only for the purpuse of evalutaion
+ // They actually do not allocate memory on the managed heap
+ // The advantage is that it does not continue the process
+ /// <exception cref="DebuggerException">Can not create string this way</exception>
+ public static Value CreateValue(Process process, object value)
+ {
+ if (value is string) throw new DebuggerException("Can not create string this way");
+ CorElementType corElemType;
+ ICorDebugClass corClass = null;
+ if (value != null) {
+ corElemType = DebugType.TypeNameToCorElementType(value.GetType().FullName);
+ } else {
+ corElemType = CorElementType.CLASS;
+ corClass = DebugType.Create(process, null, typeof(object).FullName).CorType.Class;
+ }
+ ICorDebugEval corEval = CreateCorEval(process);
+ ICorDebugValue corValue = corEval.CreateValue((uint)corElemType, corClass);
+ Value v = new Value(process, new Expressions.PrimitiveExpression(value), corValue);
+ if (value != null) {
+ v.PrimitiveValue = value;
+ }
+ return v;
+ }
+ */
+
+ #region Convenience methods
+
+ public static Value NewString(AppDomain appDomain, string textToCreate)
+ {
+ return AsyncNewString(appDomain, textToCreate).WaitForResult();
+ }
+
+ #endregion
+
+ public static Eval AsyncNewString(AppDomain appDomain, string textToCreate)
+ {
+ return new Eval(
+ appDomain,
+ "New string: " + textToCreate,
+ delegate(Eval eval) {
+ eval.CorEval2.NewStringWithLength(textToCreate, (uint)textToCreate.Length);
+ }
+ );
+ }
+
+ #region Convenience methods
+
+ public static Value NewArray(DebugType type, uint length, uint? lowerBound)
+ {
+ return AsyncNewArray(type, length, lowerBound).WaitForResult();
+ }
+
+ #endregion
+
+ public static Eval AsyncNewArray(DebugType type, uint length, uint? lowerBound)
+ {
+ lowerBound = lowerBound ?? 0;
+ return new Eval(
+ type.AppDomain,
+ "New array: " + type + "[" + length + "]",
+ delegate(Eval eval) {
+ // Multi-dimensional arrays not supported in .NET 2.0
+ eval.CorEval2.NewParameterizedArray(type.CorType, 1, new uint[] { length }, new uint[] { lowerBound.Value });
+ }
+ );
+ }
+
+ #region Convenience methods
+
+ public static Value NewObject(DebugMethodInfo constructor, Value[] constructorArguments)
+ {
+ return AsyncNewObject(constructor, constructorArguments).WaitForResult();
+ }
+
+ #endregion
+
+ public static Eval AsyncNewObject(DebugMethodInfo constructor, Value[] constructorArguments)
+ {
+ ICorDebugValue[] constructorArgsCorDebug = ValuesAsCorDebug(constructorArguments);
+ return new Eval(
+ constructor.AppDomain,
+ "New object: " + constructor.FullName,
+ delegate(Eval eval) {
+ eval.CorEval2.NewParameterizedObject(
+ constructor.CorFunction,
+ (uint)constructor.DeclaringType.GetGenericArguments().Length, ((DebugType)constructor.DeclaringType).GenericArgumentsAsCorDebugType,
+ (uint)constructorArgsCorDebug.Length, constructorArgsCorDebug);
+ }
+ );
+ }
+
+ #region Convenience methods
+
+ public static Value NewObjectNoConstructor(DebugType debugType)
+ {
+ return AsyncNewObjectNoConstructor(debugType).WaitForResult();
+ }
+
+ #endregion
+
+ public static Eval AsyncNewObjectNoConstructor(DebugType debugType)
+ {
+ return new Eval(
+ debugType.AppDomain,
+ "New object: " + debugType.FullName,
+ delegate(Eval eval) {
+ eval.CorEval2.NewParameterizedObjectNoConstructor(debugType.CorType.GetClass(), (uint)debugType.GetGenericArguments().Length, debugType.GenericArgumentsAsCorDebugType);
+ }
+ );
+ }
+
+ static ICorDebugValue[] ValuesAsCorDebug(Value[] values)
+ {
+ ICorDebugValue[] valuesAsCorDebug = new ICorDebugValue[values.Length];
+ for(int i = 0; i < values.Length; i++) {
+ valuesAsCorDebug[i] = values[i].CorValue;
+ }
+ return valuesAsCorDebug;
+ }
+ }
+}
View
23 Debugger/Debugger.Core/EvalCollection.cs
@@ -0,0 +1,23 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using Debugger.Interop.CorDebug;
+
+namespace Debugger
+{
+ public class EvalCollection: CollectionWithEvents<Eval>
+ {
+ public EvalCollection(NDebugger debugger): base(debugger) {}
+
+ internal Eval this[ICorDebugEval corEval] {
+ get {
+ foreach(Eval eval in this) {
+ if (eval.IsCorEval(corEval)) {
+ return eval;
+ }
+ }
+ throw new DebuggerException("Eval not found for given ICorDebugEval");
+ }
+ }
+ }
+}
View
121 Debugger/Debugger.Core/Exception.cs
@@ -0,0 +1,121 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System.Text;
+
+namespace Debugger
+{
+ /// <summary> This convenience class provides access to an exception within the debugee. </summary>
+ /// <seealso cref="System.Exception" />
+ public class Exception: DebuggerObject
+ {
+ Value exception;
+
+ public Value Value {
+ get { return exception; }
+ }
+
+ public Exception(Value exception)
+ {
+ this.exception = exception;
+ }
+
+ /// <summary> The <c>GetType().FullName</c> of the exception. </summary>
+ /// <seealso cref="System.Exception" />
+ public string Type {
+ get {
+ return exception.Type.FullName;
+ }
+ }
+
+ /// <summary> The <c>Message</c> property of the exception. </summary>
+ /// <seealso cref="System.Exception" />
+ public string Message {
+ get {
+ Value message = exception.GetMemberValue("_message");
+ return message.IsNull ? string.Empty : message.AsString();
+ }
+ }
+
+ /// <summary> The <c>InnerException</c> property of the exception. </summary>
+ /// <seealso cref="System.Exception" />
+ public Exception InnerException {
+ get {
+ Value innerException = exception.GetMemberValue("_innerException");
+ return innerException.IsNull ? null : new Exception(innerException);
+ }
+ }
+
+ public void MakeValuePermanent()
+ {
+ exception = exception.GetPermanentReference();
+ }
+
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(this.Type);
+ if (!string.IsNullOrEmpty(this.Message)) {
+ sb.Append(": ");
+ sb.Append(this.Message);
+ }
+ if (this.InnerException != null) {
+ sb.Append(" ---> ");
+ sb.Append(this.InnerException.ToString());
+ }
+ return sb.ToString();
+ }
+
+ public string GetStackTrace()
+ {
+ return GetStackTrace("--- End of inner exception stack trace ---");
+ }
+
+ /// <summary> Returs formated stacktrace for the exception </summary>
+ /// <exception cref="GetValueException"> Getting the stacktrace involves property
+ /// evaluation so GetValueException can be thrown in some cicumstances. </exception>
+ public string GetStackTrace(string endOfInnerExceptionFormat)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (this.InnerException != null) {
+ sb.Append(this.InnerException.GetStackTrace(endOfInnerExceptionFormat));
+ sb.Append(" ");
+ sb.Append(endOfInnerExceptionFormat);
+ sb.AppendLine();
+ }
+ // Note that evaluation is not possible after a stackoverflow exception
+ Value stackTrace = exception.GetMemberValue("StackTrace");
+ if (!stackTrace.IsNull) {
+ sb.Append(stackTrace.AsString());
+ sb.AppendLine();
+ }
+ return sb.ToString();
+ }
+ }
+
+ public class ExceptionEventArgs: ProcessEventArgs
+ {
+ readonly Exception exception;
+ readonly ExceptionType exceptionType;
+ readonly bool isUnhandled;
+
+ public Exception Exception {
+ get { return exception; }
+ }
+
+ public ExceptionType ExceptionType {
+ get { return exceptionType; }
+ }
+
+ public bool IsUnhandled {
+ get { return isUnhandled; }
+ }
+
+ public ExceptionEventArgs(Process process, Exception exception, ExceptionType exceptionType, bool isUnhandled):base(process)
+ {
+ this.exception = exception;
+ this.exceptionType = exceptionType;
+ this.isUnhandled = isUnhandled;
+ }
+ }
+}
View
13 Debugger/Debugger.Core/ExceptionType.cs
@@ -0,0 +1,13 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+namespace Debugger
+{
+ public enum ExceptionType
+ {
+ FirstChance = 1,
+ UserFirstChance = 2,
+ CatchHandlerFound = 3,
+ Unhandled = 4,
+ }
+}
View
56 Debugger/Debugger.Core/GetValueException.cs
@@ -0,0 +1,56 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.NRefactory.Ast;
+
+namespace Debugger
+{
+ public class GetValueException: DebuggerException
+ {
+ INode expression;
+ string error;
+
+ /// <summary> Expression that has caused this exception to occur </summary>
+ public INode Expression {
+ get { return expression; }
+ set { expression = value; }
+ }
+
+ public string Error {
+ get { return error; }
+ }
+
+ public override string Message {
+ get {
+ if (expression == null) {
+ return error;
+ } else {
+ return error;
+ // return String.Format("Error evaluating \"{0}\": {1}", expression.PrettyPrint(), error);
+ }
+ }
+ }
+
+ public GetValueException(INode expression, string error):base(error)
+ {
+ this.expression = expression;
+ this.error = error;
+ }
+
+ public GetValueException(string error, System.Exception inner):base(error, inner)
+ {
+ this.error = error;
+ }
+
+ public GetValueException(string errorFmt, params object[] args):base(string.Format(errorFmt, args))
+ {
+ this.error = string.Format(errorFmt, args);
+ }
+
+ public GetValueException(string error):base(error)
+ {
+ this.error = error;
+ }
+ }
+}
View
85 Debugger/Debugger.Core/Interop/Common.cs
@@ -0,0 +1,85 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+#pragma warning disable 108, 1591
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace Debugger.Interop
+{
+ // These are used in both CorDebug and CorSym
+
+ [StructLayout(LayoutKind.Sequential, Pack=4)]
+ public struct _FILETIME
+ {
+ public uint dwLowDateTime;
+ public uint dwHighDateTime;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack=8)]
+ public struct _LARGE_INTEGER
+ {
+ public long QuadPart;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack=8)]
+ public struct _ULARGE_INTEGER
+ {
+ public ulong QuadPart;
+ }
+
+ [ComImport, Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType((short) 1)]
+ public interface ISequentialStream
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten);
+ }
+
+ [ComImport, InterfaceType((short) 1), Guid("0000000C-0000-0000-C000-000000000046")]
+ public interface IStream : ISequentialStream
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __RemoteRead(out byte pv, [In] uint cb, out uint pcbRead);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __SetSize([In] _ULARGE_INTEGER libNewSize);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __RemoteCopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Commit([In] uint grfCommitFlags);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Revert();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Clone([MarshalAs(UnmanagedType.Interface)] out IStream ppstm);
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack=8)]
+ public struct tagSTATSTG
+ {
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwcsName;
+ public uint type;
+ public _ULARGE_INTEGER cbSize;
+ public _FILETIME mtime;
+ public _FILETIME ctime;
+ public _FILETIME atime;
+ public uint grfMode;
+ public uint grfLocksSupported;
+ public Guid clsid;
+ public uint grfStateBits;
+ public uint reserved;
+ }
+}
View
1,632 Debugger/Debugger.Core/Interop/CorDebug.cs
1,632 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
242 Debugger/Debugger.Core/Interop/CorDebugExtensionMethods.cs
@@ -0,0 +1,242 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Debugger.Interop.CorDebug
+{
+ public static partial class CorDebugExtensionMethods
+ {
+ const int EnumerateBufferSize = 16;
+
+ static void ProcessOutParameter(object parameter)
+ {
+ TrackedComObjects.ProcessOutParameter(parameter);
+ }
+
+ // ICorDebugArrayValue
+
+ public static unsafe uint[] GetDimensions(this ICorDebugArrayValue corArray)
+ {
+ uint[] dimensions = new uint[corArray.GetRank()];
+ fixed(uint* 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(uint* pBaseIndicies = baseIndicies)
+ corArray.GetBaseIndicies((uint)baseIndicies.Length, new IntPtr(pBaseIndicies));
+ return baseIndicies;
+ }
+
+ public static unsafe ICorDebugValue GetElement(this ICorDebugArrayValue corArray, uint[] indices)
+ {
+ fixed(uint* pIndices = indices)
+ return corArray.GetElement((uint)indices.Length, new IntPtr(pIndices));
+ }
+
+ public static unsafe ICorDebugValue GetElement(this ICorDebugArrayValue corArray, int[] indices)
+ {
+ fixed(int* 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)
+ {
+ byte[] code = new byte[corCode.GetSize()];
+ fixed(byte* pCode = code)
+ corCode.GetCode(0, (uint)code.Length, (uint)code.Length, new IntPtr(pCode));
+ return code;
+ }
+
+ // ICorDebugEnum
+
+ public static IEnumerable<ICorDebugFrame> GetEnumerator(this ICorDebugFrameEnum corEnum)
+ {
+ corEnum.Reset();
+ while (true) {
+ ICorDebugFrame[] corFrames = new ICorDebugFrame[EnumerateBufferSize];
+ uint fetched = corEnum.Next(EnumerateBufferSize, corFrames);
+ if (fetched == 0)
+ yield break;
+ for(int i = 0; i < fetched; i++)
+ yield return corFrames[i];
+ }
+ }
+
+ public static ICorDebugFrame Next(this ICorDebugFrameEnum corEnum)
+ {
+ ICorDebugFrame[] corFrames = new ICorDebugFrame[] { null };
+ uint framesFetched = corEnum.Next(1, corFrames);
+ return corFrames[0];
+ }
+
+ public static IEnumerable<ICorDebugChain> GetEnumerator(this ICorDebugChainEnum corEnum)
+ {
+ corEnum.Reset();
+ while (true) {
+ ICorDebugChain[] corChains = new ICorDebugChain[EnumerateBufferSize];
+ uint fetched = corEnum.Next(EnumerateBufferSize, corChains);
+ if (fetched == 0)
+ yield break;
+ for(int i = 0; i < fetched; i++)
+ yield return corChains[i];
+ }
+ }
+
+ public static ICorDebugChain Next(this ICorDebugChainEnum corChainEnum)
+ {
+ ICorDebugChain[] corChains = new ICorDebugChain[] { null };
+ uint chainsFetched = corChainEnum.Next(1, corChains);
+ return corChains[0];
+ }
+
+ // ICorDebugGenericValue
+
+ public static unsafe Byte[] GetRawValue(this ICorDebugGenericValue corGenVal)
+ {
+ byte[] retValue = new byte[(int)corGenVal.GetSize()];
+ fixed(byte* pRetValue = retValue)
+ corGenVal.GetValue(new IntPtr(pRetValue));
+ return retValue;
+ }
+
+ public static unsafe void SetRawValue(this ICorDebugGenericValue corGenVal, byte[] value)
+ {
+ if (corGenVal.GetSize() != value.Length)
+ throw new ArgumentException("Incorrect length");
+ fixed(byte* pValue = value)
+ corGenVal.SetValue(new IntPtr(pValue));
+ }
+
+ public static unsafe object GetValue(this ICorDebugGenericValue corGenVal, Type type)
+ {
+ object retValue;
+ byte[] value = new byte[(int)corGenVal.GetSize()];
+ fixed(byte* pValue = value) {
+ corGenVal.GetValue(new IntPtr(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();
+ }
+ }
+ return retValue;
+ }
+
+ public static unsafe void SetValue(this ICorDebugGenericValue corGenVal, object value)
+ {
+ if (value == null)
+ throw new ArgumentNullException("value");
+ byte[] val = new byte[(int)corGenVal.GetSize()];
+ fixed(byte* pValue = val) {
+ switch(value.GetType().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(new IntPtr(pValue));
+ }
+ }
+
+ // ICorDebugModule
+
+ public static string GetName(this ICorDebugModule corModule)
+ {
+ // The 'out' parameter returns the size of the needed buffer as in other functions
+ return Util.GetString(corModule.GetName, 256, true);
+ }
+
+ // ICorDebugProcess
+
+ public static bool HasQueuedCallbacks(this ICorDebugProcess corProcess)
+ {
+ return corProcess.HasQueuedCallbacks(null) != 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)
+ {
+ uint length = corString.GetLength();
+ return Util.GetString(corString.GetString, length, 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());
+ }
+ }
+}
View
3,342 Debugger/Debugger.Core/Interop/CorDebugExtensionMethods.generated.cs
3,342 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
138 Debugger/Debugger.Core/Interop/CorPublish.cs
@@ -0,0 +1,138 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+#pragma warning disable 108, 1591
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Debugger.Interop.CorPublish
+{
+ [ComImport, TypeLibType((short) 2), ClassInterface((short) 0), Guid("047A9A40-657E-11D3-8D5B-00104B35E7EF")]
+ public class CorpubPublishClass : ICorPublish, CorpubPublish, ICorPublishProcess, ICorPublishAppDomain, ICorPublishProcessEnum, ICorPublishAppDomainEnum
+ {
+ // Methods
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __EnumAppDomains([MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomainEnum ppEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __EnumProcesses([In, ComAliasName("CorpubProcessLib.COR_PUB_ENUMPROCESS")] COR_PUB_ENUMPROCESS Type, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcessEnum ppIEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __GetCount(out uint pcelt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __GetDisplayName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __GetID(out uint puId);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __GetName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __GetProcess([In] uint pid, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess ppProcess);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __GetProcessID(out uint pid);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __ICorPublishAppDomainEnum_Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __ICorPublishAppDomainEnum_GetCount(out uint pcelt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __ICorPublishAppDomainEnum_Reset();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __ICorPublishAppDomainEnum_Skip([In] uint celt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __IsManaged(out int pbManaged);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomain objects, out uint pceltFetched);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess objects, out uint pceltFetched);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __Reset();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ public virtual extern void __Skip([In] uint celt);
+ }
+
+ [ComImport, CoClass(typeof(CorpubPublishClass)), Guid("9613A0E7-5A68-11D3-8F84-00A0C9B4D50C")]
+ public interface CorpubPublish : ICorPublish
+ {
+ }
+
+ public enum COR_PUB_ENUMPROCESS
+ {
+ COR_PUB_MANAGEDONLY = 1
+ }
+
+ [ComImport, Guid("9613A0E7-5A68-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)]
+ public interface ICorPublish
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __EnumProcesses([In, ComAliasName("CorpubProcessLib.COR_PUB_ENUMPROCESS")] COR_PUB_ENUMPROCESS Type, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcessEnum ppIEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetProcess([In] uint pid, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess ppProcess);
+ }
+
+ [ComImport, Guid("D6315C8F-5A6A-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)]
+ public interface ICorPublishAppDomain
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetID(out uint puId);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName);
+ }
+
+ [ComImport, Guid("9F0C98F5-5A6A-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1),]
+ public interface ICorPublishAppDomainEnum : ICorPublishEnum
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Skip([In] uint celt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Reset();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetCount(out uint pcelt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomain objects, out uint pceltFetched);
+ }
+
+ [ComImport, Guid("C0B22967-5A69-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)]
+ public interface ICorPublishEnum
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Skip([In] uint celt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Reset();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetCount(out uint pcelt);
+ }
+
+ [ComImport, Guid("18D87AF1-5A6A-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)]
+ public interface ICorPublishProcess
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __IsManaged(out int pbManaged);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __EnumAppDomains([MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomainEnum ppEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetProcessID(out uint pid);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetDisplayName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName);
+ }
+
+ [ComImport, Guid("A37FBD41-5A69-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)]
+ public interface ICorPublishProcessEnum : ICorPublishEnum
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Skip([In] uint celt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Reset();
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __GetCount(out uint pcelt);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
+ void __Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess objects, out uint pceltFetched);
+ }
+}
View
15 Debugger/Debugger.Core/Interop/CorPublishExtensionMethods.cs
@@ -0,0 +1,15 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace Debugger.Interop.CorPublish
+{
+ public static partial class CorPublishExtensionMethods
+ {
+ static void ProcessOutParameter(object parameter)