Prompt to try skipping exceptions
This commit is contained in:
parent
31c1674479
commit
e6a5287a76
|
@ -46,6 +46,7 @@ namespace CxbxDebugger
|
||||||
KernelProvider KernelSymbolProvider;
|
KernelProvider KernelSymbolProvider;
|
||||||
|
|
||||||
bool bContinue = true;
|
bool bContinue = true;
|
||||||
|
WinDebug.CONTINUE_STATUS ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
|
@ -436,9 +437,18 @@ namespace CxbxDebugger
|
||||||
{
|
{
|
||||||
Thread.UpdateContext();
|
Thread.UpdateContext();
|
||||||
|
|
||||||
|
bool OverrideContinue = bContinue;
|
||||||
|
|
||||||
foreach (IDebuggerExceptionEvents Event in ExceptionEvents)
|
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()
|
public void RunThreaded()
|
||||||
{
|
{
|
||||||
WinDebug.DEBUG_EVENT DbgEvt = new WinDebug.DEBUG_EVENT();
|
WinDebug.DEBUG_EVENT DbgEvt = new WinDebug.DEBUG_EVENT();
|
||||||
|
ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||||
WinDebug.CONTINUE_STATUS ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
|
||||||
|
|
||||||
foreach (IDebuggerGeneralEvents Event in GeneralEvents)
|
foreach (IDebuggerGeneralEvents Event in GeneralEvents)
|
||||||
{
|
{
|
||||||
|
@ -586,6 +595,7 @@ namespace CxbxDebugger
|
||||||
|
|
||||||
// TODO: Stop doing this once we raise an exception
|
// TODO: Stop doing this once we raise an exception
|
||||||
WinDebug.NativeMethods.ContinueDebugEvent(DbgEvt.dwProcessId, DbgEvt.dwThreadId, ContinueStatus);
|
WinDebug.NativeMethods.ContinueDebugEvent(DbgEvt.dwProcessId, DbgEvt.dwThreadId, ContinueStatus);
|
||||||
|
ContinueStatus = WinDebug.CONTINUE_STATUS.DBG_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
State = RunState.Ended;
|
State = RunState.Ended;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace CxbxDebugger
|
||||||
|
|
||||||
public interface IDebuggerExceptionEvents
|
public interface IDebuggerExceptionEvents
|
||||||
{
|
{
|
||||||
void OnAccessViolation(DebuggerThread Thread, IntPtr Address);
|
bool OnAccessViolation(DebuggerThread Thread, IntPtr Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IDebuggerFileEvents
|
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)
|
private void SetDebugProcessActive(bool Active)
|
||||||
{
|
{
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
|
@ -272,9 +277,15 @@ namespace CxbxDebugger
|
||||||
frm.DebugLog(string.Format("OutputDebugString \"{0}\"", Message));
|
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
|
// TODO Include GetLastError string
|
||||||
string ExceptionMessage = string.Format("Access violation thrown in {0} 0x{1:X8}", ProcessName, (uint)Address);
|
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
|
// Already suspended at this point, so we can rebuild the callstack list
|
||||||
frm.PopulateThreadList(frm.cbThreads.Items, Thread);
|
frm.PopulateThreadList(frm.cbThreads.Items, Thread);
|
||||||
|
|
||||||
|
return frm.DebugAsk(ExceptionMessage + "\nTry to skip this error?");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnFileOpened(DebuggerMessages.FileOpened Info)
|
public void OnFileOpened(DebuggerMessages.FileOpened Info)
|
||||||
|
|
Loading…
Reference in New Issue