模拟硬件异常
任何人都可以告诉我下一个函数的代码,它会引发 EXCEPTION_FLT_STACK_CHECK 或 EXCEPTION_BREAKPOINT,因为我可以在 main func 中捕获它们:
int _tmain(int argc, _TCHAR* argv[])
{
__try
{
FaultingStack(); // What I need to write in this function???
}
__except(GetExceptionCode() == EXCEPTION_FLT_STACK_CHECK ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
return FALSE;
}
return TRUE;
return 0;
}
不建议 RaiseException func,我需要一个错误代码的示例,而不是软件引发的异常
UPD:我还需要一个代码下一个异常 EXCEPTION_INT_OVERFLOW 的代码片段
Can anyone tell me a code for next function, which raises EXCEPTION_FLT_STACK_CHECK or EXCEPTION_BREAKPOINT, for I could catch them in main func:
int _tmain(int argc, _TCHAR* argv[])
{
__try
{
FaultingStack(); // What I need to write in this function???
}
__except(GetExceptionCode() == EXCEPTION_FLT_STACK_CHECK ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
return FALSE;
}
return TRUE;
return 0;
}
Do not suggest RaiseException func, I need an example of fault code, not software raised exception
UPD: I need one more code snippet for next exception EXCEPTION_INT_OVERFLOW
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
断点异常很容易引发。您可以使用以下其中一项(全部相同):
现在,
EXCEPTION_FLT_STACK_CHECK
与无效的浮点寄存器堆栈状态相关。第一个应该启用与 FP 堆栈相关的 FP 异常:
接下来,使 FP 堆栈上溢/下溢:
Breakpoint exception is raised easily. You can use one of the following (which is all the same):
Now,
EXCEPTION_FLT_STACK_CHECK
is related to the invalid floating-point register stack state.First one should enable FP exceptions related to the FP stack:
Next, make FP stack overflow/underflow:
假设是 MSVC,因为这是一个 Windows 问题。您可以使用 __debugbreak() 内在函数获取断点异常。无需附加调试器即可进行测试。浮点堆栈检查故障需要揭露 FPU 控制字中的下溢/溢出异常。并且,比如说,过于频繁地弹出堆栈。我将它们都整合到一个示例程序中:
`
Assuming MSVC since this is a Windows question. You can get a breakpoint exception by using the __debugbreak() intrinsic. Test without attaching a debugger. A floating point stack check fault requires unmasking the under/overflow exceptions in the FPU control word. And, say, popping the stack too often. I rolled them both in one sample program:
`