Browse Source

Removed references to Debugger.Interop from main debugger code

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1153 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
569106c6ff
  1. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/README.TXT
  3. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs
  4. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs
  5. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  6. 16
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs
  7. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
  8. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  9. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/CorDebugExceptionCallbackType.cs
  10. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/CorDebugExceptionUnwindCallbackType.cs
  11. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/CorDebugStepReason.cs
  12. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugManagedCallback.cs
  13. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugManagedCallback2.cs
  14. 35
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs
  15. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  16. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
  17. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  18. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  19. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/CorDebugExceptionCallbackType.cs
  20. 30
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/CorDebugStepReason.cs
  21. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/ICorDebugManagedCallback.cs
  22. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/ICorDebugManagedCallback2.cs
  23. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ICorDebugManagedCallbacks.cs
  24. 115
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaData.cs
  25. 0
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/NativeMethods.cs
  26. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/_SECURITY_ATTRIBUTES.cs

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

@ -57,7 +57,6 @@
<Compile Include="Src\Debugger\Internal\ManagedCallback.cs" /> <Compile Include="Src\Debugger\Internal\ManagedCallback.cs" />
<Compile Include="Src\Debugger\Internal\ManagedCallbackProxy.cs" /> <Compile Include="Src\Debugger\Internal\ManagedCallbackProxy.cs" />
<Compile Include="Src\Debugger\Internal\MTA2STA.cs" /> <Compile Include="Src\Debugger\Internal\MTA2STA.cs" />
<Compile Include="Src\Debugger\Internal\NativeMethods.cs" />
<Compile Include="Src\Debugger\NDebugger.cs" /> <Compile Include="Src\Debugger\NDebugger.cs" />
<Compile Include="Src\Interop enums\ClassFieldAttribute.cs" /> <Compile Include="Src\Interop enums\ClassFieldAttribute.cs" />
<Compile Include="Src\Interop enums\CorCallingConvention.cs" /> <Compile Include="Src\Interop enums\CorCallingConvention.cs" />
@ -205,8 +204,6 @@
<Compile Include="Src\Wrappers\CorDebug\CorDebug.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebug.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugClass.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugClass.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugCreateProcessFlags.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugCreateProcessFlags.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugExceptionCallbackType.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugExceptionUnwindCallbackType.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugHandleType.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugHandleType.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugChainReason.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugChainReason.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugIntercept.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugIntercept.cs" />
@ -214,7 +211,6 @@
<Compile Include="Src\Wrappers\CorDebug\CorDebugMappingResult.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugMappingResult.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugMDAFlags.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugMDAFlags.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugRegister.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugRegister.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugStepReason.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugThreadState.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugThreadState.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugUnmappedStop.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugUnmappedStop.cs" />
<Compile Include="Src\Wrappers\CorDebug\CorDebugUserState.cs" /> <Compile Include="Src\Wrappers\CorDebug\CorDebugUserState.cs" />
@ -356,6 +352,9 @@
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedVariable.cs" /> <Compile Include="Src\Wrappers\CorSym\ISymUnmanagedVariable.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedWriter.cs" /> <Compile Include="Src\Wrappers\CorSym\ISymUnmanagedWriter.cs" />
<Compile Include="Src\Wrappers\CorSym\ISymUnmanagedWriter2.cs" /> <Compile Include="Src\Wrappers\CorSym\ISymUnmanagedWriter2.cs" />
<Compile Include="Src\Wrappers\NativeMethods.cs" />
<Compile Include="Src\Wrappers\ICorDebugManagedCallbacks.cs" />
<Compile Include="Src\Wrappers\_SECURITY_ATTRIBUTES.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="README.TXT" /> <Content Include="README.TXT" />

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/README.TXT

@ -1,6 +1,6 @@
Debugger.Core and Debugger.Interop are the two libraries that hold most core debugging functionality. Debugger.Core is the library that hold most core debugging functionality.
The vast majority of the code of these libraries was written by me without any modifications made by other people. If you could preserve this ratio by not making any modifications, I would be extremely pleased and I would be indebted to you. The vast majority of the code of this library was written by me without any modifications made by other people. If you could preserve this ratio by not making any modifications, I would be extremely pleased and I would be indebted to you.
However, if you find a bug or if you have an idea or suggestion, please do send me an e-mail to dsrbecky@gmail.com However, if you find a bug or if you have an idea or suggestion, please do send me an e-mail to dsrbecky@gmail.com

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

@ -23,7 +23,6 @@ namespace Debugger
bool hadBeenSet = false; bool hadBeenSet = false;
bool enabled = true; bool enabled = true;
ICorDebugFunctionBreakpoint corBreakpoint; ICorDebugFunctionBreakpoint corBreakpoint;
IntPtr pBreakpoint;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -86,11 +85,6 @@ namespace Debugger
this.enabled = enabled; this.enabled = enabled;
} }
internal bool Equals(IntPtr ptr)
{
return pBreakpoint == ptr;
}
internal bool Equals(ICorDebugFunctionBreakpoint obj) internal bool Equals(ICorDebugFunctionBreakpoint obj)
{ {
return corBreakpoint == obj; return corBreakpoint == obj;
@ -98,7 +92,7 @@ namespace Debugger
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return base.Equals(obj) || corBreakpoint == (obj as ICorDebugFunctionBreakpoint); return base.Equals(obj) || corBreakpoint.Equals(obj);
} }
public override int GetHashCode() public override int GetHashCode()
@ -127,7 +121,6 @@ namespace Debugger
hadBeenSet = true; hadBeenSet = true;
corBreakpoint.Activate(enabled?1:0); corBreakpoint.Activate(enabled?1:0);
pBreakpoint = Marshal.GetComInterfaceForObject(corBreakpoint.WrappedObject, typeof(Debugger.Interop.CorDebug.ICorDebugFunctionBreakpoint));
OnChanged(); OnChanged();

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

@ -10,7 +10,6 @@ using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
namespace Debugger namespace Debugger
{ {

13
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs

@ -133,17 +133,18 @@ namespace Debugger
} }
} }
public void Breakpoint(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, IntPtr pBreakpoint) public void Breakpoint(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugBreakpoint pBreakpoint)
{ {
EnterCallback("Breakpoint", pThread); EnterCallback("Breakpoint", pThread);
ExitCallback_Paused(PausedReason.Breakpoint); ExitCallback_Paused(PausedReason.Breakpoint);
foreach (Breakpoint b in debugger.Breakpoints) { // foreach (Breakpoint b in debugger.Breakpoints) {
if (b.Equals(pBreakpoint)) { // if (b.Equals(pBreakpoint)) {
b.OnHit(); // // TODO: Check that this works
} // b.OnHit();
} // }
// }
} }
public void BreakpointSetError(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugBreakpoint pBreakpoint, uint dwError) public void BreakpointSetError(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugBreakpoint pBreakpoint, uint dwError)

16
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs

@ -23,7 +23,7 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger namespace Debugger
{ {
class ManagedCallbackProxy : Debugger.Interop.CorDebug.ICorDebugManagedCallback, Debugger.Interop.CorDebug.ICorDebugManagedCallback2 class ManagedCallbackProxy : ICorDebugManagedCallbacks
{ {
NDebugger debugger; NDebugger debugger;
ManagedCallback realCallback; ManagedCallback realCallback;
@ -45,14 +45,14 @@ namespace Debugger
debugger.MTA2STA.Call(callback); debugger.MTA2STA.Call(callback);
} }
public void StepComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pStepper, Debugger.Interop.CorDebug.CorDebugStepReason reason) public void StepComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pStepper, CorDebugStepReason reason)
{ {
Call(delegate { Call(delegate {
realCallback.StepComplete( realCallback.StepComplete(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain), MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread), MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugStepper>(pStepper), MTA2STA.MarshalIntPtrTo<ICorDebugStepper>(pStepper),
(CorDebugStepReason)reason reason
); );
}); });
} }
@ -93,7 +93,7 @@ namespace Debugger
realCallback.Breakpoint( realCallback.Breakpoint(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain), MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread), MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
pBreakpoint MTA2STA.MarshalIntPtrTo<ICorDebugBreakpoint>(pBreakpoint)
); );
}); });
} }
@ -357,7 +357,7 @@ namespace Debugger
}); });
} }
public void Exception(IntPtr pAppDomain, IntPtr pThread, IntPtr pFrame, uint nOffset, Debugger.Interop.CorDebug.CorDebugExceptionCallbackType dwEventType, uint dwFlags) public void Exception(IntPtr pAppDomain, IntPtr pThread, IntPtr pFrame, uint nOffset, CorDebugExceptionCallbackType dwEventType, uint dwFlags)
{ {
Call(delegate { Call(delegate {
realCallback.Exception2( realCallback.Exception2(
@ -365,19 +365,19 @@ namespace Debugger
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread), MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFrame>(pFrame), MTA2STA.MarshalIntPtrTo<ICorDebugFrame>(pFrame),
nOffset, nOffset,
(CorDebugExceptionCallbackType)dwEventType, dwEventType,
dwFlags dwFlags
); );
}); });
} }
public void ExceptionUnwind(IntPtr pAppDomain, IntPtr pThread, Debugger.Interop.CorDebug.CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags) public void ExceptionUnwind(IntPtr pAppDomain, IntPtr pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags)
{ {
Call(delegate { Call(delegate {
realCallback.ExceptionUnwind( realCallback.ExceptionUnwind(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain), MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread), MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
(CorDebugExceptionUnwindCallbackType)dwEventType, dwEventType,
dwFlags dwFlags
); );
}); });

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs

@ -7,13 +7,12 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
using System.Collections.Generic;
namespace Debugger namespace Debugger
{ {

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -7,13 +7,12 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
using System.Collections.Generic;
namespace Debugger namespace Debugger
{ {

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/CorDebugExceptionCallbackType.cs

@ -5,7 +5,7 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
namespace Debugger.Interop.CorDebug namespace Debugger.Wrappers.CorDebug
{ {
using System; using System;

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/CorDebugExceptionUnwindCallbackType.cs

@ -5,7 +5,7 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
namespace Debugger.Interop.CorDebug namespace Debugger.Wrappers.CorDebug
{ {
using System; using System;

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/CorDebugStepReason.cs

@ -5,7 +5,7 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
namespace Debugger.Interop.CorDebug namespace Debugger.Wrappers.CorDebug
{ {
using System; using System;

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugManagedCallback.cs

@ -17,7 +17,7 @@ namespace Debugger.Interop.CorDebug
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Breakpoint([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pBreakpoint); void Breakpoint([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pBreakpoint);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void StepComplete([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pStepper, [In] CorDebugStepReason reason); void StepComplete([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pStepper, [In] Debugger.Wrappers.CorDebug.CorDebugStepReason reason);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Break([In] IntPtr pAppDomain, [In] IntPtr thread); void Break([In] IntPtr pAppDomain, [In] IntPtr thread);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Interop/CorDebug/ICorDebugManagedCallback2.cs

@ -23,9 +23,9 @@ namespace Debugger.Interop.CorDebug
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void DestroyConnection([In] IntPtr pProcess, [In] uint dwConnectionId); void DestroyConnection([In] IntPtr pProcess, [In] uint dwConnectionId);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Exception([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFrame, [In] uint nOffset, [In] CorDebugExceptionCallbackType dwEventType, [In] uint dwFlags); void Exception([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFrame, [In] uint nOffset, [In] Debugger.Wrappers.CorDebug.CorDebugExceptionCallbackType dwEventType, [In] uint dwFlags);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void ExceptionUnwind([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] CorDebugExceptionUnwindCallbackType dwEventType, [In] uint dwFlags); void ExceptionUnwind([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] Debugger.Wrappers.CorDebug.CorDebugExceptionUnwindCallbackType dwEventType, [In] uint dwFlags);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void FunctionRemapComplete([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFunction); void FunctionRemapComplete([In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFunction);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]

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

@ -12,7 +12,6 @@ using System.Runtime.InteropServices;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Wrappers.MetaData; using Debugger.Wrappers.MetaData;
using Debugger.Interop.MetaData;
namespace Debugger namespace Debugger
{ {
@ -25,9 +24,9 @@ namespace Debugger
string fullPathPDB; string fullPathPDB;
int orderOfLoading = 0; int orderOfLoading = 0;
readonly ICorDebugModule corModule; ICorDebugModule corModule;
SymReader symReader; SymReader symReader;
IMetaDataImport metaDataInterface; MetaData metaData;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -37,7 +36,7 @@ namespace Debugger
internal MetaData MetaData { internal MetaData MetaData {
get { get {
return new MetaData(metaDataInterface); return metaData;
} }
} }
@ -127,10 +126,7 @@ namespace Debugger
corModule = pModule; corModule = pModule;
Guid metaDataInterfaceGuid = new Guid("{ 0x7dac8207, 0xd3ae, 0x4c75, { 0x9b, 0x67, 0x92, 0x80, 0x1a, 0x49, 0x7d, 0x44 } }"); metaData = new MetaData(pModule);
object pMetaDataInterface = pModule.GetMetaDataInterface(ref metaDataInterfaceGuid);
metaDataInterface = (IMetaDataImport) pMetaDataInterface;
uint pStringLenght = 0; // Terminating character included in pStringLenght uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero; IntPtr pString = IntPtr.Zero;
@ -161,19 +157,8 @@ namespace Debugger
fullPathPDB = newPdbPath; fullPathPDB = newPdbPath;
} catch {} } catch {}
SymBinder symBinder = new SymBinder(); symReader = metaData.GetSymReader(fullPath, tempPath);
IntPtr ptr = IntPtr.Zero;
try {
ptr = Marshal.GetIUnknownForObject(metaDataInterface);
symReader = (SymReader)symBinder.GetReader(ptr, fullPath, tempPath);
} catch (System.Exception) {
symReader = null;
} finally {
if (ptr != IntPtr.Zero) {
Marshal.Release(ptr);
}
}
try { try {
if (File.Exists(newPdbPath) && !File.Exists(oldPdbPath)) { if (File.Exists(newPdbPath) && !File.Exists(oldPdbPath)) {
File.Copy(newPdbPath, oldPdbPath); File.Copy(newPdbPath, oldPdbPath);
@ -208,13 +193,7 @@ namespace Debugger
} }
} }
try { metaData.Dispose();
Marshal.FinalReleaseComObject(metaDataInterface);
} catch {
Console.WriteLine("metaDataInterface release failed. (FinalReleaseComObject)");
} finally {
metaDataInterface = null;
}
unloaded = true; unloaded = true;
} }

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs

@ -11,7 +11,6 @@ using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
namespace Debugger namespace Debugger
{ {

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs

@ -11,7 +11,6 @@ using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
namespace Debugger namespace Debugger
{ {
@ -87,11 +86,6 @@ namespace Debugger
{ {
debugger.TraceMessage("Executing " + filename); debugger.TraceMessage("Executing " + filename);
Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES secAttr = new Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES();
secAttr.bInheritHandle = 0;
secAttr.lpSecurityDescriptor = IntPtr.Zero;
secAttr.nLength = (uint)sizeof(Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES); //=12?
uint[] processStartupInfo = new uint[17]; uint[] processStartupInfo = new uint[17];
processStartupInfo[0] = sizeof(uint) * 17; processStartupInfo[0] = sizeof(uint) * 17;
uint[] processInfo = new uint[4]; uint[] processInfo = new uint[4];
@ -109,8 +103,8 @@ namespace Debugger
filename, // lpApplicationName filename, // lpApplicationName
// If we do not prepend " ", the first argument migh just get lost // If we do not prepend " ", the first argument migh just get lost
" " + arguments, // lpCommandLine " " + arguments, // lpCommandLine
ref secAttr, // lpProcessAttributes ref _SECURITY_ATTRIBUTES.Default, // lpProcessAttributes
ref secAttr, // lpThreadAttributes ref _SECURITY_ATTRIBUTES.Default, // lpThreadAttributes
1,//TRUE // bInheritHandles 1,//TRUE // bInheritHandles
0x00000010 /*CREATE_NEW_CONSOLE*/, // dwCreationFlags 0x00000010 /*CREATE_NEW_CONSOLE*/, // dwCreationFlags
IntPtr.Zero, // lpEnvironment IntPtr.Zero, // lpEnvironment

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

@ -11,7 +11,6 @@ using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
namespace Debugger namespace Debugger
{ {

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -9,9 +9,7 @@ using System;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Debugger;
using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
namespace Debugger namespace Debugger
{ {

24
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/CorDebugExceptionCallbackType.cs

@ -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>
namespace Debugger.Wrappers.CorDebug
{
using System;
public enum CorDebugExceptionCallbackType : int
{
DEBUG_EXCEPTION_FIRST_CHANCE = 1,
DEBUG_EXCEPTION_USER_FIRST_CHANCE = 2,
DEBUG_EXCEPTION_CATCH_HANDLER_FOUND = 3,
DEBUG_EXCEPTION_UNHANDLED = 4,
}
}

30
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/CorDebugStepReason.cs

@ -1,30 +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>
namespace Debugger.Wrappers.CorDebug
{
using System;
public enum CorDebugStepReason : int
{
STEP_NORMAL = 0,
STEP_RETURN = 1,
STEP_CALL = 2,
STEP_EXCEPTION_FILTER = 3,
STEP_EXCEPTION_HANDLER = 4,
STEP_INTERCEPT = 5,
STEP_EXIT = 6,
}
}

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

@ -93,9 +93,9 @@ namespace Debugger.Wrappers.CorDebug
this.WrappedObject.Breakpoint(pAppDomain, pThread, pBreakpoint); this.WrappedObject.Breakpoint(pAppDomain, pThread, pBreakpoint);
} }
public void StepComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pStepper, CorDebugStepReason reason) public void StepComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pStepper, Debugger.Wrappers.CorDebug.CorDebugStepReason reason)
{ {
this.WrappedObject.StepComplete(pAppDomain, pThread, pStepper, ((Debugger.Interop.CorDebug.CorDebugStepReason)(reason))); this.WrappedObject.StepComplete(pAppDomain, pThread, pStepper, reason);
} }
public void Break(System.IntPtr pAppDomain, System.IntPtr thread) public void Break(System.IntPtr pAppDomain, System.IntPtr thread)

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/ICorDebugManagedCallback2.cs

@ -108,14 +108,14 @@ namespace Debugger.Wrappers.CorDebug
this.WrappedObject.DestroyConnection(pProcess, dwConnectionId); this.WrappedObject.DestroyConnection(pProcess, dwConnectionId);
} }
public void Exception(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pFrame, uint nOffset, CorDebugExceptionCallbackType dwEventType, uint dwFlags) public void Exception(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pFrame, uint nOffset, Debugger.Wrappers.CorDebug.CorDebugExceptionCallbackType dwEventType, uint dwFlags)
{ {
this.WrappedObject.Exception(pAppDomain, pThread, pFrame, nOffset, ((Debugger.Interop.CorDebug.CorDebugExceptionCallbackType)(dwEventType)), dwFlags); this.WrappedObject.Exception(pAppDomain, pThread, pFrame, nOffset, dwEventType, dwFlags);
} }
public void ExceptionUnwind(System.IntPtr pAppDomain, System.IntPtr pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags) public void ExceptionUnwind(System.IntPtr pAppDomain, System.IntPtr pThread, Debugger.Wrappers.CorDebug.CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags)
{ {
this.WrappedObject.ExceptionUnwind(pAppDomain, pThread, ((Debugger.Interop.CorDebug.CorDebugExceptionUnwindCallbackType)(dwEventType)), dwFlags); this.WrappedObject.ExceptionUnwind(pAppDomain, pThread, dwEventType, dwFlags);
} }
public void FunctionRemapComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pFunction) public void FunctionRemapComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pFunction)

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/CorDebugExceptionUnwindCallbackType.cs → src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ICorDebugManagedCallbacks.cs

@ -1,7 +1,7 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt"/> // <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/> // <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/> // <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
@ -9,12 +9,8 @@ namespace Debugger.Wrappers.CorDebug
{ {
using System; using System;
public interface ICorDebugManagedCallbacks: Debugger.Interop.CorDebug.ICorDebugManagedCallback, Debugger.Interop.CorDebug.ICorDebugManagedCallback2
public enum CorDebugExceptionUnwindCallbackType : int
{ {
DEBUG_EXCEPTION_UNWIND_BEGIN = 1,
DEBUG_EXCEPTION_INTERCEPTED = 2,
} }
} }

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

@ -7,30 +7,63 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.SymbolStore;
using System.Text; using System.Text;
using Debugger.Interop.MetaData;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Debugger.Wrappers.CorDebug;
using Debugger.Interop.MetaData;
namespace Debugger.Wrappers.MetaData namespace Debugger.Wrappers.MetaData
{ {
class MetaData class MetaData: IDisposable
{ {
IMetaDataImport metaData; IMetaDataImport metaData;
public MetaData(IMetaDataImport metaData) public MetaData(ICorDebugModule pModule)
{ {
this.metaData = metaData; Guid guid = new Guid("{ 0x7dac8207, 0xd3ae, 0x4c75, { 0x9b, 0x67, 0x92, 0x80, 0x1a, 0x49, 0x7d, 0x44 } }");
metaData = (IMetaDataImport)pModule.GetMetaDataInterface(ref guid);
} }
public SymReader GetSymReader(string fullname, string searchPath)
{
SymReader symReader;
SymBinder symBinder = new SymBinder();
IntPtr ptr = IntPtr.Zero;
try {
ptr = Marshal.GetIUnknownForObject(metaData);
symReader = (SymReader)symBinder.GetReader(ptr, fullname, searchPath);
} catch (System.Exception) {
symReader = null;
} finally {
if (ptr != IntPtr.Zero) {
Marshal.Release(ptr);
}
}
return symReader;
}
public void Dispose()
{
try {
Marshal.FinalReleaseComObject(metaData);
} catch {
Console.WriteLine("metaData release failed. (FinalReleaseComObject)");
} finally {
metaData = null;
}
}
public TypeDefProps GetTypeDefProps(uint typeToken) public TypeDefProps GetTypeDefProps(uint typeToken)
{ {
TypeDefProps typeDefProps; TypeDefProps typeDefProps;
typeDefProps.Token = typeToken; typeDefProps.Token = typeToken;
uint pStringLenght = 0; // Terminating character included in pStringLenght uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero; IntPtr pString = IntPtr.Zero;
// Get length of string // Get length of string
metaData.GetTypeDefProps(typeDefProps.Token, metaData.GetTypeDefProps(typeDefProps.Token,
pString, pString,
@ -38,10 +71,10 @@ namespace Debugger.Wrappers.MetaData
out pStringLenght, out pStringLenght,
out typeDefProps.Flags, out typeDefProps.Flags,
out typeDefProps.SuperClassToken); out typeDefProps.SuperClassToken);
// Allocate string buffer // Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2); pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
// Get properties // Get properties
metaData.GetTypeDefProps(typeDefProps.Token, metaData.GetTypeDefProps(typeDefProps.Token,
pString, pString,
@ -49,19 +82,19 @@ namespace Debugger.Wrappers.MetaData
out pStringLenght, out pStringLenght,
out typeDefProps.Flags, out typeDefProps.Flags,
out typeDefProps.SuperClassToken); out typeDefProps.SuperClassToken);
typeDefProps.Name = Marshal.PtrToStringUni(pString); typeDefProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString); Marshal.FreeHGlobal(pString);
return typeDefProps; return typeDefProps;
} }
public TypeRefProps GetTypeRefProps(uint typeToken) public TypeRefProps GetTypeRefProps(uint typeToken)
{ {
TypeRefProps typeRefProps; TypeRefProps typeRefProps;
typeRefProps.Token = typeToken; typeRefProps.Token = typeToken;
uint unused; uint unused;
uint pStringLenght = 0; // Terminating character included in pStringLenght uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero; IntPtr pString = IntPtr.Zero;
@ -73,16 +106,16 @@ namespace Debugger.Wrappers.MetaData
// Allocate string buffer // Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2); pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
metaData.GetTypeRefProps(typeRefProps.Token, metaData.GetTypeRefProps(typeRefProps.Token,
out unused, out unused,
pString, pString,
pStringLenght, pStringLenght,
out pStringLenght); // real string lenght out pStringLenght); // real string lenght
typeRefProps.Name = Marshal.PtrToStringUni(pString); typeRefProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString); Marshal.FreeHGlobal(pString);
return typeRefProps; return typeRefProps;
} }
@ -100,13 +133,13 @@ namespace Debugger.Wrappers.MetaData
yield return GetFieldProps(fieldToken); yield return GetFieldProps(fieldToken);
} }
} }
public FieldProps GetFieldProps(uint fieldToken) public FieldProps GetFieldProps(uint fieldToken)
{ {
FieldProps fieldProps; FieldProps fieldProps;
fieldProps.Token = fieldToken; fieldProps.Token = fieldToken;
uint unused; uint unused;
IntPtr unusedPtr = IntPtr.Zero; IntPtr unusedPtr = IntPtr.Zero;
uint pStringLenght = 0; // Terminating character included in pStringLenght uint pStringLenght = 0; // Terminating character included in pStringLenght
@ -122,10 +155,10 @@ namespace Debugger.Wrappers.MetaData
out unused, out unused,
out unusedPtr, out unusedPtr,
out unused); out unused);
// Allocate string buffer // Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2); pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
metaData.GetFieldProps(fieldProps.Token, metaData.GetFieldProps(fieldProps.Token,
out fieldProps.ClassToken, out fieldProps.ClassToken,
pString, pString,
@ -137,10 +170,10 @@ namespace Debugger.Wrappers.MetaData
out unused, out unused,
out unusedPtr, out unusedPtr,
out unused); out unused);
fieldProps.Name = Marshal.PtrToStringUni(pString); fieldProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString); Marshal.FreeHGlobal(pString);
return fieldProps; return fieldProps;
} }
@ -158,13 +191,13 @@ namespace Debugger.Wrappers.MetaData
yield return GetMethodProps(methodToken); yield return GetMethodProps(methodToken);
} }
} }
public unsafe MethodProps GetMethodProps(uint methodToken) public unsafe MethodProps GetMethodProps(uint methodToken)
{ {
MethodProps methodProps; MethodProps methodProps;
methodProps.Token = methodToken; methodProps.Token = methodToken;
uint pStringLenght = 0; // Terminating character included in pStringLenght uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero; IntPtr pString = IntPtr.Zero;
//IntPtr pSigBlob; //IntPtr pSigBlob;
@ -179,10 +212,10 @@ namespace Debugger.Wrappers.MetaData
out sigBlobSize, out sigBlobSize,
out methodProps.CodeRVA, out methodProps.CodeRVA,
out methodProps.ImplFlags); out methodProps.ImplFlags);
// Allocate string buffer // Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2); pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
metaData.GetMethodProps(methodProps.Token, metaData.GetMethodProps(methodProps.Token,
out methodProps.ClassToken, out methodProps.ClassToken,
pString, pString,
@ -193,7 +226,7 @@ namespace Debugger.Wrappers.MetaData
out sigBlobSize, out sigBlobSize,
out methodProps.CodeRVA, out methodProps.CodeRVA,
out methodProps.ImplFlags); out methodProps.ImplFlags);
methodProps.Name = Marshal.PtrToStringUni(pString); methodProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString); Marshal.FreeHGlobal(pString);
@ -201,23 +234,23 @@ namespace Debugger.Wrappers.MetaData
//methodProps.Signature = new SignatureStream(pSigBlob, sigBlobSize); //methodProps.Signature = new SignatureStream(pSigBlob, sigBlobSize);
//Marshal.FreeCoTaskMem(pSigBlob); //Marshal.FreeCoTaskMem(pSigBlob);
return methodProps; return methodProps;
} }
public ParamProps GetParamForMethodIndex(uint methodToken, uint parameterSequence) public ParamProps GetParamForMethodIndex(uint methodToken, uint parameterSequence)
{ {
uint paramToken = 0; uint paramToken = 0;
metaData.GetParamForMethodIndex(methodToken, parameterSequence, ref paramToken); metaData.GetParamForMethodIndex(methodToken, parameterSequence, ref paramToken);
return GetParamProps(paramToken); return GetParamProps(paramToken);
} }
public ParamProps GetParamProps(uint paramToken) public ParamProps GetParamProps(uint paramToken)
{ {
ParamProps paramProps; ParamProps paramProps;
paramProps.Token = paramToken; paramProps.Token = paramToken;
uint unused; uint unused;
uint pStringLenght = 0; // Terminating character included in pStringLenght uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero; IntPtr pString = IntPtr.Zero;
@ -231,7 +264,7 @@ namespace Debugger.Wrappers.MetaData
out unused, out unused,
IntPtr.Zero, IntPtr.Zero,
out unused); out unused);
// Allocate string buffer // Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2); pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
@ -245,13 +278,13 @@ namespace Debugger.Wrappers.MetaData
out unused, out unused,
IntPtr.Zero, IntPtr.Zero,
out unused); out unused);
paramProps.Name = Marshal.PtrToStringUni(pString); paramProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString); Marshal.FreeHGlobal(pString);
return paramProps; return paramProps;
} }
public TypeDefProps FindTypeDefByName(string typeName, uint enclosingClassToken) public TypeDefProps FindTypeDefByName(string typeName, uint enclosingClassToken)
{ {
uint typeDefToken; uint typeDefToken;

0
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/NativeMethods.cs → src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/NativeMethods.cs

24
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/_SECURITY_ATTRIBUTES.cs

@ -0,0 +1,24 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
namespace Debugger.Wrappers.CorDebug
{
using System;
public static class _SECURITY_ATTRIBUTES
{
public static Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES Default;
static unsafe _SECURITY_ATTRIBUTES() {
Default = new Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES();
Default.bInheritHandle = 0;
Default.lpSecurityDescriptor = IntPtr.Zero;
Default.nLength = (uint)sizeof(Debugger.Interop.CorDebug._SECURITY_ATTRIBUTES);
}
}
}
Loading…
Cancel
Save