【发布时间】:2013-10-29 06:41:47
【问题描述】:
我写了一个 ASSERT 宏,如下代码:
do{
if (true) {
int ret = _DbgCheckMsg(__WSHORT_FILE__, __LINE__, L"haha", L"haha", (const wchar_t*)nullptr);
if (ret == 1) {
TRACEF("called int 3");
__asm int 3;
TRACEF("after called int 3");
} else if (ret == -1)
_DbgAbort();
}
} while (0);
在 Visual Studio 中使用 F5 运行,或者在没有 F5 但不在 wndproc 处理程序中运行时,它运行良好,但如果在没有 F5 和 wndproc 消息处理程序中运行,wndproc 只是默默地吞下断点异常,就像它对c 标准断言函数。
但我需要在 wndproc 消息处理程序中触发 jit 对话框,而无需先附加调试器。我该怎么办?
我曾尝试在 SEH 中扭曲 wndproc,但没有帮助,因为它会中断异常处理程序而不是中断消息处理程序代码。
LRESULT CALLBACK WndProcWrapper(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
__try {
return WndProc(hWnd, message, wParam, lParam);
} __except(GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
TRACEF("exception caught");
//LPEXCEPTION_POINTERS pep = GetExceptionInformation();
}
}
【问题讨论】:
-
@EdwardClements:DebugBreak() 没有帮助,因为它实际上是 __asm int 3;