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