异常类型的介绍
windows下c/c++常见的异常类型:
- SEH exception
int *p = 0;
*p = 0;
- terminate
terminate()
- unexpected
unexpected();
- pure virtual method call
- invalid parameter
- new operator fault
- SIGABRT
- SIGFPE
- SIGILL
- SIGINT
- SIGSEGV
- SIGTERM
- RaiseException
RaiseException(123, EXCEPTION_NONCONTINUABLE, 0, NULL);
-
throw C++ typed exception
-
stack overflow exception
char szchar[12] = { 0 };
sprintf(szchar, "%s", "dfsdfsdfsdfsdfsdsdfsdfsdfsdfsdfsdfsdfsdfsdfsfsffsdfsdfsdfsfsdf");
其中 1~14 这些异常类型,通过
SetUnhandledExceptionFilter
_set_purecall_handler
_set_new_handler
_set_invalid_parameter_handler
_set_abort_behavior
signal
set_terminate
set_unexpected
dump捕获的方法
win7系统可以通过修改SetUnhandledExceptionFilter实现重定向,但在win8之后这个方法也无效了。因此以下方法:
1、使用SetUnhandledExceptionFilter
2、使用异常捕获库
已经无法捕获15这类异常了。
解决方法
进程中捕获异常固然是一个好方法,但学习成本高、同时需要验证的异常太多,万一漏了几种呢 ?而跨进程捕获异常,通过注册表的AeDebug实现对进程所有异常的捕获也是一个好方法。下载地址:自动捕获异常