Browse Source

Rewritten Debugger.ManagedCallbackProxy

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@821 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
687942aee9
  1. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs
  2. 275
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallbackProxy.cs

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs

@ -45,7 +45,7 @@ namespace Debugger @@ -45,7 +45,7 @@ namespace Debugger
public object CallInSTA(MethodInvokerWithReturnValue callDelegate)
{
return CallInSTA(callDelegate, true); // TODO: Make it false once it is safe
return CallInSTA(callDelegate, false);
}
object CallInSTA(MethodInvokerWithReturnValue callDelegate, bool mayAbandon)
@ -79,6 +79,11 @@ namespace Debugger @@ -79,6 +79,11 @@ namespace Debugger
}
}
public static T MarshalIntPtrTo<T>(IntPtr param)
{
return (T)MarshalIntPtrTo(param, typeof(T));
}
public static object MarshalIntPtrTo(IntPtr param, Type outputType)
{
// IntPtr requested as output (must be before the null check so that we pass IntPtr.Zero)

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

@ -14,11 +14,12 @@ using System.Windows.Forms; @@ -14,11 +14,12 @@ using System.Windows.Forms;
using Debugger.Interop.CorDebug;
// Regular expresion:
// ^{\t*}{(:Ll| )*{:i} *\(((.# {:i}, |\))|())^6\)*}\n\t*\{(.|\n)@\}
// ^{\t*}{(:Ll| )*{:i} *\(((.# {:i}, |\))|())^6\)*}\n\t*\{(.|\n)@\t\}
// Output: \1 - intention \2 - declaration \3 - function name \4-9 parameters
// Replace with:
// \1\2\n\1{\n\1\tCallbackReceived("\3", new object[] {\4, \5, \6, \7, \8, \9});\n\1}
// \1\2\n\1{\n\1\tCall(delegate {\n\1\t \trealCallback.\3(\n\1\t \t\tMTA2STA.MarshalIntPtrTo(\4),\n\1\t \t\tMTA2STA.MarshalIntPtrTo(\5),\n\1\t \t\tMTA2STA.MarshalIntPtrTo(\6),\n\1\t \t\tMTA2STA.MarshalIntPtrTo(\7),\n\1\t \t\tMTA2STA.MarshalIntPtrTo(\8),\n\1\t \t\tMTA2STA.MarshalIntPtrTo(\9),\n\1\t \t);\n\1\t });\n\1}
namespace Debugger
{
@ -50,136 +51,285 @@ namespace Debugger @@ -50,136 +51,285 @@ namespace Debugger
}
}
void Call(MethodInvoker d)
{
mta2sta.CallInSTA(d);
}
public void StepComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pStepper, Debugger.Interop.CorDebug.CorDebugStepReason reason)
{
CallbackReceived("StepComplete", new object[] {pAppDomain, pThread, pStepper, reason});
Call(delegate {
realCallback.StepComplete(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugStepper>(pStepper),
reason
);
});
}
public void Break(System.IntPtr pAppDomain, System.IntPtr pThread)
{
CallbackReceived("Break", new object[] {pAppDomain, pThread});
Call(delegate {
realCallback.Break(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
});
}
public void ControlCTrap(System.IntPtr pProcess)
{
CallbackReceived("ControlCTrap", new object[] {pProcess});
Call(delegate {
realCallback.ControlCTrap(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess)
);
});
}
public void Exception(System.IntPtr pAppDomain, System.IntPtr pThread, int unhandled)
{
CallbackReceived("Exception", new object[] {pAppDomain, pThread, unhandled});
Call(delegate {
realCallback.Exception(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
unhandled
);
});
}
public void Breakpoint(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pBreakpoint)
{
CallbackReceived("Breakpoint", new object[] {pAppDomain, pThread, pBreakpoint});
Call(delegate {
realCallback.Breakpoint(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
pBreakpoint
);
});
}
public void CreateProcess(System.IntPtr pProcess)
{
CallbackReceived("CreateProcess", new object[] {pProcess});
Call(delegate {
realCallback.CreateProcess(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess)
);
});
}
public void CreateAppDomain(System.IntPtr pProcess, System.IntPtr pAppDomain)
{
CallbackReceived("CreateAppDomain", new object[] {pProcess, pAppDomain});
Call(delegate {
realCallback.CreateAppDomain(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain)
);
});
}
public void CreateThread(System.IntPtr pAppDomain, System.IntPtr pThread)
{
CallbackReceived("CreateThread", new object[] {pAppDomain, pThread});
Call(delegate {
realCallback.CreateThread(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
});
}
public void LoadAssembly(System.IntPtr pAppDomain, System.IntPtr pAssembly)
{
CallbackReceived("LoadAssembly", new object[] {pAppDomain, pAssembly});
Call(delegate {
realCallback.LoadAssembly(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugAssembly>(pAssembly)
);
});
}
public void LoadModule(System.IntPtr pAppDomain, System.IntPtr pModule)
{
CallbackReceived("LoadModule", new object[] {pAppDomain, pModule});
Call(delegate {
realCallback.LoadModule(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugModule>(pModule)
);
});
}
public void NameChange(System.IntPtr pAppDomain, System.IntPtr pThread)
{
CallbackReceived("NameChange", new object[] {pAppDomain, pThread});
Call(delegate {
realCallback.NameChange(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
});
}
public void LoadClass(System.IntPtr pAppDomain, System.IntPtr c)
{
CallbackReceived("LoadClass", new object[] {pAppDomain, c});
Call(delegate {
realCallback.LoadClass(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugClass>(c)
);
});
}
public void UnloadClass(System.IntPtr pAppDomain, System.IntPtr c)
{
CallbackReceived("UnloadClass", new object[] {pAppDomain, c});
Call(delegate {
realCallback.UnloadClass(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugClass>(c)
);
});
}
public void ExitThread(System.IntPtr pAppDomain, System.IntPtr pThread)
{
CallbackReceived("ExitThread", new object[] {pAppDomain, pThread});
Call(delegate {
realCallback.ExitThread(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread)
);
});
}
public void UnloadModule(System.IntPtr pAppDomain, System.IntPtr pModule)
{
CallbackReceived("UnloadModule", new object[] {pAppDomain, pModule});
Call(delegate {
realCallback.UnloadModule(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugModule>(pModule)
);
});
}
public void UnloadAssembly(System.IntPtr pAppDomain, System.IntPtr pAssembly)
{
CallbackReceived("UnloadAssembly", new object[] {pAppDomain, pAssembly});
Call(delegate {
realCallback.UnloadAssembly(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugAssembly>(pAssembly)
);
});
}
public void ExitAppDomain(System.IntPtr pProcess, System.IntPtr pAppDomain)
{
CallbackReceived("ExitAppDomain", new object[] {pProcess, pAppDomain});
Call(delegate {
realCallback.ExitAppDomain(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain)
);
});
}
public void ExitProcess(System.IntPtr pProcess)
{
CallbackReceived("ExitProcess", new object[] {pProcess});
Call(delegate {
realCallback.ExitProcess(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess)
);
});
}
public void BreakpointSetError(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pBreakpoint, uint dwError)
{
CallbackReceived("BreakpointSetError", new object[] {pAppDomain, pThread, pBreakpoint, dwError});
Call(delegate {
realCallback.BreakpointSetError(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugBreakpoint>(pBreakpoint),
dwError
);
});
}
public void LogSwitch(System.IntPtr pAppDomain, System.IntPtr pThread, int lLevel, uint ulReason, System.IntPtr pLogSwitchName, System.IntPtr pParentName)
{
CallbackReceived("LogSwitch", new object[] {pAppDomain, pThread, lLevel, ulReason, pLogSwitchName});
Call(delegate {
realCallback.LogSwitch(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
lLevel,
ulReason,
MTA2STA.MarshalIntPtrTo<string>(pLogSwitchName),
MTA2STA.MarshalIntPtrTo<string>(pParentName)
);
});
}
public void EvalException(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pEval)
{
CallbackReceived("EvalException", new object[] {pAppDomain, pThread, pEval});
Call(delegate {
realCallback.EvalException(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugEval>(pEval)
);
});
}
public void LogMessage(System.IntPtr pAppDomain, System.IntPtr pThread, int lLevel, System.IntPtr pLogSwitchName, System.IntPtr pMessage)
{
CallbackReceived("LogMessage", new object[] {pAppDomain, pThread, lLevel, pLogSwitchName, pMessage});
Call(delegate {
realCallback.LogMessage(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
lLevel,
MTA2STA.MarshalIntPtrTo<string>(pLogSwitchName),
MTA2STA.MarshalIntPtrTo<string>(pMessage)
);
});
}
public void EditAndContinueRemap(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pFunction, int fAccurate)
{
CallbackReceived("EditAndContinueRemap", new object[] {pAppDomain, pThread, pFunction, fAccurate});
Call(delegate {
realCallback.EditAndContinueRemap(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFunction>(pFunction),
fAccurate
);
});
}
public void EvalComplete(System.IntPtr pAppDomain, System.IntPtr pThread, System.IntPtr pEval)
{
CallbackReceived("EvalComplete", new object[] {pAppDomain, pThread, pEval});
Call(delegate {
realCallback.EvalComplete(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugEval>(pEval)
);
});
}
public void DebuggerError(System.IntPtr pProcess, int errorHR, uint errorCode)
{
CallbackReceived("DebuggerError", new object[] {pProcess, errorHR, errorCode});
Call(delegate {
realCallback.DebuggerError(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
errorHR,
errorCode
);
});
}
public void UpdateModuleSymbols(System.IntPtr pAppDomain, System.IntPtr pModule, System.IntPtr pSymbolStream)
{
CallbackReceived("UpdateModuleSymbols", new object[] {pAppDomain, pModule, pSymbolStream});
Call(delegate {
realCallback.UpdateModuleSymbols(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugModule>(pModule),
MTA2STA.MarshalIntPtrTo<Debugger.Interop.CorDebug.IStream>(pSymbolStream)
);
});
}
@ -188,42 +338,95 @@ namespace Debugger @@ -188,42 +338,95 @@ namespace Debugger
public void ChangeConnection(IntPtr pProcess, uint dwConnectionId)
{
CallbackReceived("ChangeConnection", new object[] {pProcess, dwConnectionId});
Call(delegate {
realCallback.ChangeConnection(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
dwConnectionId
);
});
}
public void CreateConnection(IntPtr pProcess, uint dwConnectionId, ref ushort pConnName)
{
CallbackReceived("CreateConnection", new object[] {pProcess, dwConnectionId, pConnName});
ushort pName = pConnName;
Call(delegate {
realCallback.CreateConnection(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
dwConnectionId,
ref pName
);
});
}
public void DestroyConnection(IntPtr pProcess, uint dwConnectionId)
{
CallbackReceived("DestroyConnection", new object[] {pProcess, dwConnectionId});
Call(delegate {
realCallback.DestroyConnection(
MTA2STA.MarshalIntPtrTo<ICorDebugProcess>(pProcess),
dwConnectionId
);
});
}
public void Exception(IntPtr pAppDomain, IntPtr pThread, IntPtr pFrame, uint nOffset, CorDebugExceptionCallbackType dwEventType, uint dwFlags)
{
CallbackReceived("Exception2", new object[] {pAppDomain, pThread, pFrame, nOffset, dwEventType, dwFlags});
Call(delegate {
realCallback.Exception2(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFrame>(pFrame),
nOffset,
dwEventType,
dwFlags
);
});
}
public void ExceptionUnwind(IntPtr pAppDomain, IntPtr pThread, CorDebugExceptionUnwindCallbackType dwEventType, uint dwFlags)
{
CallbackReceived("ExceptionUnwind", new object[] {pAppDomain, pThread, dwEventType, dwFlags});
Call(delegate {
realCallback.ExceptionUnwind(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
dwEventType,
dwFlags
);
});
}
public void FunctionRemapComplete(IntPtr pAppDomain, IntPtr pThread, IntPtr pFunction)
{
CallbackReceived("FunctionRemapComplete", new object[] {pAppDomain, pThread, pFunction});
Call(delegate {
realCallback.FunctionRemapComplete(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFunction>(pFunction)
);
});
}
public void FunctionRemapOpportunity(IntPtr pAppDomain, IntPtr pThread, IntPtr pOldFunction, IntPtr pNewFunction, uint oldILOffset)
{
CallbackReceived("FunctionRemapOpportunity", new object[] {pAppDomain, pThread, pOldFunction, pNewFunction, oldILOffset});
Call(delegate {
realCallback.FunctionRemapOpportunity(
MTA2STA.MarshalIntPtrTo<ICorDebugAppDomain>(pAppDomain),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugFunction>(pOldFunction),
MTA2STA.MarshalIntPtrTo<ICorDebugFunction>(pNewFunction),
oldILOffset
);
});
}
public void MDANotification(IntPtr pController, IntPtr pThread, IntPtr pMDA)
{
CallbackReceived("MDANotification", new object[] {pController, pThread, pMDA});
Call(delegate {
realCallback.MDANotification(
MTA2STA.MarshalIntPtrTo<ICorDebugController>(pController),
MTA2STA.MarshalIntPtrTo<ICorDebugThread>(pThread),
MTA2STA.MarshalIntPtrTo<ICorDebugMDA>(pMDA)
);
});
}
#endregion

Loading…
Cancel
Save