Browse Source

Moving functionality from NDebugger to Process - added ManagedCallbackSwitch

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1688 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
ac04c154eb
  1. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  3. 85
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs
  4. 254
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackSwitch.cs
  5. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  6. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs
  7. 23
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs

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

@ -383,6 +383,7 @@ @@ -383,6 +383,7 @@
<Compile Include="Src\Variables\Evals\NewObjectEval.cs" />
<Compile Include="Src\Debugger\IMutable.cs" />
<Compile Include="Src\Debugger\ExceptionEventArgs.cs" />
<Compile Include="Src\Debugger\Internal\ManagedCallbackSwitch.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />

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

@ -20,6 +20,9 @@ using Debugger.Wrappers.CorDebug; @@ -20,6 +20,9 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger
{
/// <summary>
/// Handles all callbacks of a given process
/// </summary>
class ManagedCallback
{
Process process;
@ -39,6 +42,7 @@ namespace Debugger @@ -39,6 +42,7 @@ namespace Debugger
void EnterCallback(PausedReason pausedReason, string name, ICorDebugProcess pProcess)
{
process.TraceMessage("Callback: " + name);
System.Diagnostics.Debug.Assert(process.CorProcess == pProcess);
// Check state
if (process.IsRunning ||
// After break is pressed we may receive some messages that were already queued
@ -46,7 +50,6 @@ namespace Debugger @@ -46,7 +50,6 @@ namespace Debugger
// ExitProcess may be called at any time when debuggee is killed
name == "ExitProcess") {
process = process.GetProcess(pProcess);
if (process.IsPaused && process.PauseSession.PausedReason == PausedReason.ForcedBreak) {
process.TraceMessage("Processing post-break callback");
// Continue the break, process is still breaked because of the callback
@ -394,14 +397,7 @@ namespace Debugger @@ -394,14 +397,7 @@ namespace Debugger
{
EnterCallback(PausedReason.Other, "ExitProcess", pProcess);
Process process = process.GetProcess(pProcess);
process.RemoveProcess(process);
if (process.Processes.Count == 0) {
// Exit callback and then terminate the debugger
process.MTA2STA.AsyncCall( delegate { process.TerminateDebugger(); } );
}
process.NotifyHasExpired();
}
#endregion

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

@ -23,21 +23,24 @@ using Debugger.Wrappers.CorDebug; @@ -23,21 +23,24 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger
{
/// <summary>
/// This proxy marshals the callback to the appropriate thread
/// </summary>
class ManagedCallbackProxy : ICorDebugManagedCallbacks
{
Process process;
ManagedCallback realCallback;
NDebugger debugger;
ManagedCallbackSwitch callbackSwitch;
public Process Process {
public NDebugger Debugger {
get {
return process;
return debugger;
}
}
public ManagedCallbackProxy(ManagedCallback realCallback)
public ManagedCallbackProxy(NDebugger debugger, ManagedCallbackSwitch callbackSwitch)
{
this.debugger = realCallback.Process;
this.realCallback = realCallback;
this.debugger = debugger;
this.callbackSwitch = callbackSwitch;
}
void Call(MethodInvoker callback)
@ -48,7 +51,7 @@ namespace Debugger @@ -48,7 +51,7 @@ namespace Debugger
public void StepComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pStepper, CorDebugStepReason reason)
{
Call(delegate {
realCallback.StepComplete(
callbackSwitch.StepComplete(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugStepper>(pStepper),
@ -60,7 +63,7 @@ namespace Debugger @@ -60,7 +63,7 @@ namespace Debugger
public void Break(System.IntPtr pAppDomain, System.IntPtr pThread)
{
Call(delegate {
realCallback.Break(
callbackSwitch.Break(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
@ -70,7 +73,7 @@ namespace Debugger @@ -70,7 +73,7 @@ namespace Debugger
public void ControlCTrap(System.IntPtr pProcess)
{
Call(delegate {
realCallback.ControlCTrap(
callbackSwitch.ControlCTrap(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess)
);
});
@ -79,7 +82,7 @@ namespace Debugger @@ -79,7 +82,7 @@ namespace Debugger
public void Exception(System.IntPtr pAppDomain, System.IntPtr pThread, int unhandled)
{
Call(delegate {
realCallback.Exception(
callbackSwitch.Exception(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
unhandled
@ -90,7 +93,7 @@ namespace Debugger @@ -90,7 +93,7 @@ namespace Debugger
public void Breakpoint(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pBreakpoint)
{
Call(delegate {
realCallback.Breakpoint(
callbackSwitch.Breakpoint(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
pBreakpoint // Do not marshal this one - it fails in .NET 1.1
@ -101,7 +104,7 @@ namespace Debugger @@ -101,7 +104,7 @@ namespace Debugger
public void CreateProcess(System.IntPtr pProcess)
{
Call(delegate {
realCallback.CreateProcess(
callbackSwitch.CreateProcess(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess)
);
});
@ -110,7 +113,7 @@ namespace Debugger @@ -110,7 +113,7 @@ namespace Debugger
public void CreateAppDomain(System.IntPtr pProcess, System.IntPtr pAppDomain)
{
Call(delegate {
realCallback.CreateAppDomain(
callbackSwitch.CreateAppDomain(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain)
);
@ -120,7 +123,7 @@ namespace Debugger @@ -120,7 +123,7 @@ namespace Debugger
public void CreateThread(System.IntPtr pAppDomain, System.IntPtr pThread)
{
Call(delegate {
realCallback.CreateThread(
callbackSwitch.CreateThread(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
@ -130,7 +133,7 @@ namespace Debugger @@ -130,7 +133,7 @@ namespace Debugger
public void LoadAssembly(System.IntPtr pAppDomain, System.IntPtr pAssembly)
{
Call(delegate {
realCallback.LoadAssembly(
callbackSwitch.LoadAssembly(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugAssembly>(pAssembly)
);
@ -140,7 +143,7 @@ namespace Debugger @@ -140,7 +143,7 @@ namespace Debugger
public void LoadModule(System.IntPtr pAppDomain, System.IntPtr pModule)
{
Call(delegate {
realCallback.LoadModule(
callbackSwitch.LoadModule(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugModule>(pModule)
);
@ -150,7 +153,7 @@ namespace Debugger @@ -150,7 +153,7 @@ namespace Debugger
public void NameChange(System.IntPtr pAppDomain, System.IntPtr pThread)
{
Call(delegate {
realCallback.NameChange(
callbackSwitch.NameChange(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
@ -160,7 +163,7 @@ namespace Debugger @@ -160,7 +163,7 @@ namespace Debugger
public void LoadClass(System.IntPtr pAppDomain, System.IntPtr c)
{
Call(delegate {
realCallback.LoadClass(
callbackSwitch.LoadClass(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugClass>(c)
);
@ -170,7 +173,7 @@ namespace Debugger @@ -170,7 +173,7 @@ namespace Debugger
public void UnloadClass(System.IntPtr pAppDomain, System.IntPtr c)
{
Call(delegate {
realCallback.UnloadClass(
callbackSwitch.UnloadClass(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugClass>(c)
);
@ -180,7 +183,7 @@ namespace Debugger @@ -180,7 +183,7 @@ namespace Debugger
public void ExitThread(System.IntPtr pAppDomain, System.IntPtr pThread)
{
Call(delegate {
realCallback.ExitThread(
callbackSwitch.ExitThread(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
@ -190,7 +193,7 @@ namespace Debugger @@ -190,7 +193,7 @@ namespace Debugger
public void UnloadModule(System.IntPtr pAppDomain, System.IntPtr pModule)
{
Call(delegate {
realCallback.UnloadModule(
callbackSwitch.UnloadModule(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugModule>(pModule)
);
@ -200,7 +203,7 @@ namespace Debugger @@ -200,7 +203,7 @@ namespace Debugger
public void UnloadAssembly(System.IntPtr pAppDomain, System.IntPtr pAssembly)
{
Call(delegate {
realCallback.UnloadAssembly(
callbackSwitch.UnloadAssembly(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugAssembly>(pAssembly)
);
@ -210,7 +213,7 @@ namespace Debugger @@ -210,7 +213,7 @@ namespace Debugger
public void ExitAppDomain(System.IntPtr pProcess, System.IntPtr pAppDomain)
{
Call(delegate {
realCallback.ExitAppDomain(
callbackSwitch.ExitAppDomain(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain)
);
@ -220,7 +223,7 @@ namespace Debugger @@ -220,7 +223,7 @@ namespace Debugger
public void ExitProcess(System.IntPtr pProcess)
{
Call(delegate {
realCallback.ExitProcess(
callbackSwitch.ExitProcess(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess)
);
});
@ -229,7 +232,7 @@ namespace Debugger @@ -229,7 +232,7 @@ namespace Debugger
public void BreakpointSetError(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pBreakpoint, uint dwError)
{
Call(delegate {
realCallback.BreakpointSetError(
callbackSwitch.BreakpointSetError(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugBreakpoint>(pBreakpoint),
@ -241,7 +244,7 @@ namespace Debugger @@ -241,7 +244,7 @@ namespace Debugger
public void LogSwitch(System.IntPtr pAppDomain, System.IntPtr pThread, int lLevel, uint ulReason, System.IntPtr pLogSwitchName, System.IntPtr pParentName)
{
Call(delegate {
realCallback.LogSwitch(
callbackSwitch.LogSwitch(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
lLevel,
@ -255,7 +258,7 @@ namespace Debugger @@ -255,7 +258,7 @@ namespace Debugger
public void EvalException(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pEval)
{
Call(delegate {
realCallback.EvalException(
callbackSwitch.EvalException(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugEval>(pEval)
@ -266,7 +269,7 @@ namespace Debugger @@ -266,7 +269,7 @@ namespace Debugger
public void LogMessage(System.IntPtr pAppDomain, System.IntPtr pThread, int lLevel, System.IntPtr pLogSwitchName, System.IntPtr pMessage)
{
Call(delegate {
realCallback.LogMessage(
callbackSwitch.LogMessage(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
lLevel,
@ -279,7 +282,7 @@ namespace Debugger @@ -279,7 +282,7 @@ namespace Debugger
public void EditAndContinueRemap(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pFunction, int fAccurate)
{
Call(delegate {
realCallback.EditAndContinueRemap(
callbackSwitch.EditAndContinueRemap(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFunction>(pFunction),
@ -291,7 +294,7 @@ namespace Debugger @@ -291,7 +294,7 @@ namespace Debugger
public void EvalComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pEval)
{
Call(delegate {
realCallback.EvalComplete(
callbackSwitch.EvalComplete(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugEval>(pEval)
@ -302,7 +305,7 @@ namespace Debugger @@ -302,7 +305,7 @@ namespace Debugger
public void DebuggerError(System.IntPtr pProcess, int errorHR, uint errorCode)
{
Call(delegate {
realCallback.DebuggerError(
callbackSwitch.DebuggerError(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
errorHR,
errorCode
@ -313,7 +316,7 @@ namespace Debugger @@ -313,7 +316,7 @@ namespace Debugger
public void UpdateModuleSymbols(System.IntPtr pAppDomain, System.IntPtr pModule, System.IntPtr pSymbolStream)
{
Call(delegate {
realCallback.UpdateModuleSymbols(
callbackSwitch.UpdateModuleSymbols(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugModule>(pModule),
MTA2STA.MarshalIntPtrTo<IStream>(pSymbolStream)
@ -328,7 +331,7 @@ namespace Debugger @@ -328,7 +331,7 @@ namespace Debugger
public void ChangeConnection(IntPtr pProcess, uint dwConnectionId)
{
Call(delegate {
realCallback.ChangeConnection(
callbackSwitch.ChangeConnection(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
dwConnectionId
);
@ -338,7 +341,7 @@ namespace Debugger @@ -338,7 +341,7 @@ namespace Debugger
public void CreateConnection(IntPtr pProcess, uint dwConnectionId, IntPtr pConnName)
{
Call(delegate {
realCallback.CreateConnection(
callbackSwitch.CreateConnection(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
dwConnectionId,
pConnName
@ -349,7 +352,7 @@ namespace Debugger @@ -349,7 +352,7 @@ namespace Debugger
public void DestroyConnection(IntPtr pProcess, uint dwConnectionId)
{
Call(delegate {
realCallback.DestroyConnection(
callbackSwitch.DestroyConnection(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
dwConnectionId
);
@ -359,7 +362,7 @@ namespace Debugger @@ -359,7 +362,7 @@ namespace Debugger
public void Exception(IntPtr pAppDomain, IntPtr pThread, IntPtr pFrame, uint nOffset, CorDebugExceptionCallbackType dwEventType, uint dwFlags)
{
Call(delegate {
realCallback.Exception2(
callbackSwitch.Exception2(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFrame>(pFrame),
@ -373,7 +376,7 @@ namespace Debugger @@ -373,7 +376,7 @@ namespace Debugger
public void ExceptionUnwind(IntPtr pAppDomain, IntPtr pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags)
{
Call(delegate {
realCallback.ExceptionUnwind(
callbackSwitch.ExceptionUnwind(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
dwEventType,
@ -385,7 +388,7 @@ namespace Debugger @@ -385,7 +388,7 @@ namespace Debugger
public void FunctionRemapComplete(IntPtr pAppDomain, IntPtr pThread, IntPtr pFunction)
{
Call(delegate {
realCallback.FunctionRemapComplete(
callbackSwitch.FunctionRemapComplete(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFunction>(pFunction)
@ -396,7 +399,7 @@ namespace Debugger @@ -396,7 +399,7 @@ namespace Debugger
public void FunctionRemapOpportunity(IntPtr pAppDomain, IntPtr pThread, IntPtr pOldFunction, IntPtr pNewFunction, uint oldILOffset)
{
Call(delegate {
realCallback.FunctionRemapOpportunity(
callbackSwitch.FunctionRemapOpportunity(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFunction>(pOldFunction),
@ -409,7 +412,7 @@ namespace Debugger @@ -409,7 +412,7 @@ namespace Debugger
public void MDANotification(IntPtr pController, IntPtr pThread, IntPtr pMDA)
{
Call(delegate {
realCallback.MDANotification(
callbackSwitch.MDANotification(
MTA2STA.MarshalIntPtrTo<ICorDebugController>(pController),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugMDA>(pMDA)

254
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackSwitch.cs

@ -0,0 +1,254 @@ @@ -0,0 +1,254 @@
// <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>
// Regular expresion:
// ^{\t*}{(:Ll| )*{:i} *\(((.# {:i}, |\))|())^6\)*}\n\t*\{(.|\n)@^\1\}
// Output: \1 - intention \2 - declaration \3 - function name \4-9 parameters
// Replace with:
// \1\2\n\1{\n\1\tGetProcessCallbackInterface(\4).\3(\4, \5, \6, \7, \8, \9);\n\1}
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
/// <summary>
/// This class forwards the callback the the approprite process
/// </summary>
class ManagedCallbackSwitch
{
NDebugger debugger;
public NDebugger Debugger {
get {
return debugger;
}
}
public ManagedCallbackSwitch(NDebugger debugger)
{
this.debugger = debugger;
}
public ManagedCallback GetProcessCallbackInterface(ICorDebugController c)
{
if (c.Is<ICorDebugAppDomain>()) {
return GetProcessCallbackInterface(c.CastTo<ICorDebugAppDomain>());
} else if (c.Is<ICorDebugProcess>()){
return GetProcessCallbackInterface(c.CastTo<ICorDebugProcess>());
} else {
throw new System.Exception("Unknown callback argument");
}
}
public ManagedCallback GetProcessCallbackInterface(ICorDebugAppDomain pAppDomain)
{
return GetProcessCallbackInterface(pAppDomain.Process);
}
public ManagedCallback GetProcessCallbackInterface(ICorDebugProcess pProcess)
{
Process process = debugger.GetProcess(pProcess);
return process.CallbackInterface;
}
#region Program folow control
public void StepComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugStepper pStepper, CorDebugStepReason reason)
{
GetProcessCallbackInterface(pAppDomain).StepComplete(pAppDomain, pThread, pStepper, reason);
}
// Do not pass the pBreakpoint parameter as ICorDebugBreakpoint - marshaling of it fails in .NET 1.1
public void Breakpoint(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, IntPtr pBreakpoint)
{
GetProcessCallbackInterface(pAppDomain).Breakpoint(pAppDomain, pThread, pBreakpoint);
}
public void BreakpointSetError(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugBreakpoint pBreakpoint, uint dwError)
{
GetProcessCallbackInterface(pAppDomain).BreakpointSetError(pAppDomain, pThread, pBreakpoint, dwError);
}
public unsafe void Break(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread)
{
GetProcessCallbackInterface(pAppDomain).Break(pAppDomain, pThread);
}
public void ControlCTrap(ICorDebugProcess pProcess)
{
GetProcessCallbackInterface(pProcess).ControlCTrap(pProcess);
}
public unsafe void Exception(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, int unhandled)
{
GetProcessCallbackInterface(pAppDomain).Exception(pAppDomain, pThread, unhandled);
}
#endregion
#region Various
public void LogSwitch(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, int lLevel, uint ulReason, string pLogSwitchName, string pParentName)
{
GetProcessCallbackInterface(pAppDomain).LogSwitch(pAppDomain, pThread, lLevel, ulReason, pLogSwitchName, pParentName);
}
public void LogMessage(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, int lLevel, string pLogSwitchName, string pMessage)
{
GetProcessCallbackInterface(pAppDomain).LogMessage(pAppDomain, pThread, lLevel, pLogSwitchName, pMessage);
}
public void EditAndContinueRemap(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugFunction pFunction, int fAccurate)
{
GetProcessCallbackInterface(pAppDomain).EditAndContinueRemap(pAppDomain, pThread, pFunction, fAccurate);
}
public void EvalException(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval)
{
GetProcessCallbackInterface(pAppDomain).EvalException(pAppDomain, pThread, corEval);
}
public void EvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval)
{
GetProcessCallbackInterface(pAppDomain).EvalComplete(pAppDomain, pThread, corEval);
}
public void DebuggerError(ICorDebugProcess pProcess, int errorHR, uint errorCode)
{
GetProcessCallbackInterface(pProcess).DebuggerError(pProcess, errorHR, errorCode);
}
public void UpdateModuleSymbols(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule, IStream pSymbolStream)
{
GetProcessCallbackInterface(pAppDomain).UpdateModuleSymbols(pAppDomain, pModule, pSymbolStream);
}
#endregion
#region Start of Application
public void CreateProcess(ICorDebugProcess pProcess)
{
GetProcessCallbackInterface(pProcess).CreateProcess(pProcess);
}
public void CreateAppDomain(ICorDebugProcess pProcess, ICorDebugAppDomain pAppDomain)
{
GetProcessCallbackInterface(pProcess).CreateAppDomain(pProcess, pAppDomain);
}
public void LoadAssembly(ICorDebugAppDomain pAppDomain, ICorDebugAssembly pAssembly)
{
GetProcessCallbackInterface(pAppDomain).LoadAssembly(pAppDomain, pAssembly);
}
public unsafe void LoadModule(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule)
{
GetProcessCallbackInterface(pAppDomain).LoadModule(pAppDomain, pModule);
}
public void NameChange(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread)
{
GetProcessCallbackInterface(pAppDomain).NameChange(pAppDomain, pThread);
}
public void CreateThread(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread)
{
GetProcessCallbackInterface(pAppDomain).CreateThread(pAppDomain, pThread);
}
public void LoadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
{
GetProcessCallbackInterface(pAppDomain).LoadClass(pAppDomain, c);
}
#endregion
#region Exit of Application
public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
{
GetProcessCallbackInterface(pAppDomain).UnloadClass(pAppDomain, c);
}
public void UnloadModule(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule)
{
GetProcessCallbackInterface(pAppDomain).UnloadModule(pAppDomain, pModule);
}
public void UnloadAssembly(ICorDebugAppDomain pAppDomain, ICorDebugAssembly pAssembly)
{
GetProcessCallbackInterface(pAppDomain).UnloadAssembly(pAppDomain, pAssembly);
}
public void ExitThread(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread)
{
GetProcessCallbackInterface(pAppDomain).ExitThread(pAppDomain, pThread);
}
public void ExitAppDomain(ICorDebugProcess pProcess, ICorDebugAppDomain pAppDomain)
{
GetProcessCallbackInterface(pProcess).ExitAppDomain(pProcess, pAppDomain);
}
public void ExitProcess(ICorDebugProcess pProcess)
{
GetProcessCallbackInterface(pProcess).ExitProcess(pProcess);
}
#endregion
#region ICorDebugManagedCallback2 Members
public void ChangeConnection(ICorDebugProcess pProcess, uint dwConnectionId)
{
GetProcessCallbackInterface(pProcess).ChangeConnection(pProcess, dwConnectionId);
}
public void CreateConnection(ICorDebugProcess pProcess, uint dwConnectionId, IntPtr pConnName)
{
GetProcessCallbackInterface(pProcess).CreateConnection(pProcess, dwConnectionId, pConnName);
}
public void DestroyConnection(ICorDebugProcess pProcess, uint dwConnectionId)
{
GetProcessCallbackInterface(pProcess).DestroyConnection(pProcess, dwConnectionId);
}
public void Exception2(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugFrame pFrame, uint nOffset, CorDebugExceptionCallbackType exceptionType, uint dwFlags)
{
GetProcessCallbackInterface(pAppDomain).Exception2(pAppDomain, pThread, pFrame, nOffset, exceptionType, dwFlags);
}
public void ExceptionUnwind(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags)
{
GetProcessCallbackInterface(pAppDomain).ExceptionUnwind(pAppDomain, pThread, dwEventType, dwFlags);
}
public void FunctionRemapComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugFunction pFunction)
{
GetProcessCallbackInterface(pAppDomain).FunctionRemapComplete(pAppDomain, pThread, pFunction);
}
public void FunctionRemapOpportunity(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugFunction pOldFunction, ICorDebugFunction pNewFunction, uint oldILOffset)
{
GetProcessCallbackInterface(pAppDomain).FunctionRemapOpportunity(pAppDomain, pThread, pOldFunction, pNewFunction, oldILOffset);
}
public void MDANotification(ICorDebugController c, ICorDebugThread t, ICorDebugMDA mda)
{
GetProcessCallbackInterface(c).MDANotification(c, t, mda);
}
#endregion
}
}

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

@ -19,7 +19,7 @@ namespace Debugger @@ -19,7 +19,7 @@ namespace Debugger
public partial class NDebugger: RemotingObjectBase
{
ICorDebug corDebug;
ManagedCallback managedCallback;
ManagedCallbackSwitch managedCallbackSwitch;
ManagedCallbackProxy managedCallbackProxy;
MTA2STA mta2sta = new MTA2STA();
@ -44,12 +44,6 @@ namespace Debugger @@ -44,12 +44,6 @@ namespace Debugger
}
}
internal ManagedCallback ManagedCallback {
get {
return managedCallback;
}
}
public NDebugger()
{
if (ApartmentState.STA == System.Threading.Thread.CurrentThread.GetApartmentState()) {
@ -105,8 +99,8 @@ namespace Debugger @@ -105,8 +99,8 @@ namespace Debugger
corDebug = new ICorDebug(NativeMethods.CreateDebuggingInterfaceFromVersion(3, this.debuggeeVersion));
managedCallback = new ManagedCallback(this);
managedCallbackProxy = new ManagedCallbackProxy(managedCallback);
managedCallbackSwitch = new ManagedCallbackSwitch(this);
managedCallbackProxy = new ManagedCallbackProxy(this, managedCallbackSwitch);
corDebug.Initialize();
corDebug.SetManagedHandler(new ICorDebugManagedCallback(managedCallbackProxy));

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs

@ -49,9 +49,12 @@ namespace Debugger @@ -49,9 +49,12 @@ namespace Debugger
internal void RemoveProcess(Process process)
{
processCollection.Remove(process);
process.NotifyHasExpired();
OnProcessExited(process);
// noProcessesHandle is set in NDebugger.TerminateDebugger
if (processCollection.Count == 0) {
// Exit callback and then terminate the debugger
this.MTA2STA.AsyncCall( delegate { this.TerminateDebugger(); } );
}
}
protected virtual void OnProcessStarted(Process process)

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

@ -17,9 +17,10 @@ namespace Debugger @@ -17,9 +17,10 @@ namespace Debugger
public partial class Process: RemotingObjectBase, IExpirable
{
NDebugger debugger;
ICorDebugProcess corProcess;
ManagedCallback callbackInterface;
Thread selectedThread;
PauseSession pauseSession;
@ -40,6 +41,7 @@ namespace Debugger @@ -40,6 +41,7 @@ namespace Debugger
if (Expired != null) {
Expired(this, new ProcessEventArgs(this));
}
debugger.RemoveProcess(this);
}
}
@ -62,11 +64,19 @@ namespace Debugger @@ -62,11 +64,19 @@ namespace Debugger
return debugger;
}
}
internal ManagedCallback CallbackInterface {
get {
return callbackInterface;
}
}
internal Process(NDebugger debugger, ICorDebugProcess corProcess)
{
this.debugger = debugger;
this.corProcess = corProcess;
this.callbackInterface = new ManagedCallback(this);
}
internal ICorDebugProcess CorProcess {
@ -187,6 +197,13 @@ namespace Debugger @@ -187,6 +197,13 @@ namespace Debugger
}
string debuggeeVersion;
public string DebuggeeVersion {
get {
return debuggeeVersion;
}
}
/// <summary>
/// Fired when System.Diagnostics.Trace.WriteLine() is called in debuged process

Loading…
Cancel
Save