Prompt to try skipping exceptions
This commit is contained in:
parent
31c1674479
commit
e6a5287a76
|
@ -46,6 +46,7 @@ namespace CxbxDebugger
|
|||
KernelProvider KernelSymbolProvider;
|
||||
|
||||
bool bContinue = true;
|
||||
WinDebug.CONTINUE_STATUS ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||
|
||||
private void Init()
|
||||
{
|
||||
|
@ -436,9 +437,18 @@ namespace CxbxDebugger
|
|||
{
|
||||
Thread.UpdateContext();
|
||||
|
||||
bool OverrideContinue = bContinue;
|
||||
|
||||
foreach (IDebuggerExceptionEvents Event in ExceptionEvents)
|
||||
{
|
||||
Event.OnAccessViolation(Thread, DebugInfo.ExceptionRecord.ExceptionAddress);
|
||||
OverrideContinue |= Event.OnAccessViolation(Thread, DebugInfo.ExceptionRecord.ExceptionAddress);
|
||||
}
|
||||
|
||||
// Attempt to skip this exception if requested
|
||||
if (OverrideContinue)
|
||||
{
|
||||
bContinue = true;
|
||||
ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_EXCEPTION_NOT_HANDLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -527,8 +537,7 @@ namespace CxbxDebugger
|
|||
public void RunThreaded()
|
||||
{
|
||||
WinDebug.DEBUG_EVENT DbgEvt = new WinDebug.DEBUG_EVENT();
|
||||
|
||||
WinDebug.CONTINUE_STATUS ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||
ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||
|
||||
foreach (IDebuggerGeneralEvents Event in GeneralEvents)
|
||||
{
|
||||
|
@ -586,6 +595,7 @@ namespace CxbxDebugger
|
|||
|
||||
// TODO: Stop doing this once we raise an exception
|
||||
WinDebug.NativeMethods.ContinueDebugEvent(DbgEvt.dwProcessId, DbgEvt.dwThreadId, ContinueStatus);
|
||||
ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||
}
|
||||
|
||||
State = RunState.Ended;
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace CxbxDebugger
|
|||
|
||||
public interface IDebuggerExceptionEvents
|
||||
{
|
||||
void OnAccessViolation(DebuggerThread Thread, IntPtr Address);
|
||||
bool OnAccessViolation(DebuggerThread Thread, IntPtr Address);
|
||||
}
|
||||
|
||||
public interface IDebuggerFileEvents
|
||||
|
|
|
@ -150,6 +150,11 @@ namespace CxbxDebugger
|
|||
}
|
||||
}
|
||||
|
||||
private bool DebugAsk(string Message)
|
||||
{
|
||||
return MessageBox.Show(Message, "Cxbx Debugger", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
|
||||
}
|
||||
|
||||
private void SetDebugProcessActive(bool Active)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
|
@ -272,9 +277,15 @@ namespace CxbxDebugger
|
|||
frm.DebugLog(string.Format("OutputDebugString \"{0}\"", Message));
|
||||
}
|
||||
|
||||
public void OnAccessViolation(DebuggerThread Thread, IntPtr Address)
|
||||
public bool OnAccessViolation(DebuggerThread Thread, IntPtr Address)
|
||||
{
|
||||
string ProcessName = Path.GetFileName(Thread.OwningProcess.Path);
|
||||
string ProcessName = "??";
|
||||
|
||||
var Module = frm.DebuggerInst.ResolveModule((uint)Address);
|
||||
if( Module != null )
|
||||
{
|
||||
ProcessName = Path.GetFileName(Module.Path);
|
||||
}
|
||||
|
||||
// TODO Include GetLastError string
|
||||
string ExceptionMessage = string.Format("Access violation thrown in {0} 0x{1:X8}", ProcessName, (uint)Address);
|
||||
|
@ -283,6 +294,8 @@ namespace CxbxDebugger
|
|||
|
||||
// Already suspended at this point, so we can rebuild the callstack list
|
||||
frm.PopulateThreadList(frm.cbThreads.Items, Thread);
|
||||
|
||||
return frm.DebugAsk(ExceptionMessage + "\nTry to skip this error?");
|
||||
}
|
||||
|
||||
public void OnFileOpened(DebuggerMessages.FileOpened Info)
|
||||
|
|
Loading…
Reference in New Issue