Break correctly on breakpoint exceptions
Suspend was previously called which would trace at the wrong location
This commit is contained in:
parent
e0e2c434d2
commit
0259feb0a9
|
@ -8,6 +8,7 @@ using WinProcesses = VsChromium.Core.Win32.Processes;
|
||||||
using WinDebug = VsChromium.Core.Win32.Debugging;
|
using WinDebug = VsChromium.Core.Win32.Debugging;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using WinLowLevel = LowLevelDesign.Win32.Windows.NativeMethods;
|
using WinLowLevel = LowLevelDesign.Win32.Windows.NativeMethods;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace CxbxDebugger
|
namespace CxbxDebugger
|
||||||
{
|
{
|
||||||
|
@ -48,6 +49,8 @@ namespace CxbxDebugger
|
||||||
DebuggerSymbolServer SymbolSrv;
|
DebuggerSymbolServer SymbolSrv;
|
||||||
KernelProvider KernelSymbolProvider;
|
KernelProvider KernelSymbolProvider;
|
||||||
|
|
||||||
|
ManualResetEvent bpStall = new ManualResetEvent(false);
|
||||||
|
|
||||||
bool bContinue = true;
|
bool bContinue = true;
|
||||||
WinDebug.CONTINUE_STATUS ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
WinDebug.CONTINUE_STATUS ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||||
|
|
||||||
|
@ -611,10 +614,14 @@ namespace CxbxDebugger
|
||||||
uint BpCode = DebugInfo.ExceptionRecord.ExceptionCode;
|
uint BpCode = DebugInfo.ExceptionRecord.ExceptionCode;
|
||||||
bool FirstChance = (DebugInfo.dwFirstChance != 0);
|
bool FirstChance = (DebugInfo.dwFirstChance != 0);
|
||||||
|
|
||||||
|
bpStall.Reset();
|
||||||
|
|
||||||
foreach (IDebuggerExceptionEvents Event in ExceptionEvents)
|
foreach (IDebuggerExceptionEvents Event in ExceptionEvents)
|
||||||
{
|
{
|
||||||
Event.OnBreakpoint(Thread, BpAddr, BpCode, FirstChance);
|
Event.OnBreakpoint(Thread, BpAddr, BpCode, FirstChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bpStall.WaitOne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -628,6 +635,11 @@ namespace CxbxDebugger
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void BreakpointContinue()
|
||||||
|
{
|
||||||
|
bpStall.Set();
|
||||||
|
}
|
||||||
|
|
||||||
public void RunThreaded()
|
public void RunThreaded()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace CxbxDebugger
|
||||||
Debugger DebuggerInst;
|
Debugger DebuggerInst;
|
||||||
string[] CachedArgs;
|
string[] CachedArgs;
|
||||||
string CachedTitle = "";
|
string CachedTitle = "";
|
||||||
|
bool SuspendedOnBp = false;
|
||||||
|
|
||||||
DebuggerFormEvents DebugEvents;
|
DebuggerFormEvents DebugEvents;
|
||||||
|
|
||||||
|
@ -307,28 +308,30 @@ namespace CxbxDebugger
|
||||||
{
|
{
|
||||||
Invoke(new MethodInvoker(delegate ()
|
Invoke(new MethodInvoker(delegate ()
|
||||||
{
|
{
|
||||||
bool should_suspend = false;
|
SuspendedOnBp = true;
|
||||||
if( cbBreakpointAll.Checked )
|
|
||||||
{
|
bool auto_resume = true;
|
||||||
should_suspend = true;
|
if (cbBreakpointAll.Checked == false)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Ignore all submodule breakpoints
|
// Ignore all submodule breakpoints
|
||||||
// (effectively triggers from Cxbx.exe and default.xbe)
|
// (effectively triggers from Cxbx.exe and default.xbe)
|
||||||
|
|
||||||
if (cbBreakpointCxbx.Checked)
|
if (cbBreakpointCxbx.Checked)
|
||||||
{
|
{
|
||||||
should_suspend = Module.Core;
|
auto_resume = (!Module.Core);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_suspend)
|
if (auto_resume)
|
||||||
|
{
|
||||||
|
Resume();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
string module_name = Path.GetFileName(Module.Path);
|
string module_name = Path.GetFileName(Module.Path);
|
||||||
|
|
||||||
Suspend(string.Format("Breakpoint hit in {0} at 0x{1:x}", module_name, Address));
|
Suspend(string.Format("Breakpoint hit in {0} at 0x{1:x}", module_name, Address));
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +553,10 @@ namespace CxbxDebugger
|
||||||
{
|
{
|
||||||
if (DebuggerInst != null)
|
if (DebuggerInst != null)
|
||||||
{
|
{
|
||||||
DebuggerInst.Break();
|
if (!SuspendedOnBp)
|
||||||
|
{
|
||||||
|
DebuggerInst.Break();
|
||||||
|
}
|
||||||
|
|
||||||
NativeWrappers.FlashWindowTray(Handle);
|
NativeWrappers.FlashWindowTray(Handle);
|
||||||
PopulateThreadList(cbThreads, null);
|
PopulateThreadList(cbThreads, null);
|
||||||
|
@ -560,14 +566,21 @@ namespace CxbxDebugger
|
||||||
|
|
||||||
cbThreads.Enabled = true;
|
cbThreads.Enabled = true;
|
||||||
cbFrames.Enabled = true;
|
cbFrames.Enabled = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Resume()
|
private void Resume()
|
||||||
{
|
{
|
||||||
if (DebuggerInst != null)
|
if (DebuggerInst != null)
|
||||||
{
|
{
|
||||||
DebuggerInst.Resume();
|
if (SuspendedOnBp)
|
||||||
|
{
|
||||||
|
DebuggerInst.BreakpointContinue();
|
||||||
|
SuspendedOnBp = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebuggerInst.Resume();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lblStatus.Text = "Running";
|
lblStatus.Text = "Running";
|
||||||
|
|
Loading…
Reference in New Issue