问题描述
我们在Windows上,我们希望针对应用程序意外退出的 all 方案进行故障转储(可能使用 MiniDumpWriteDump
).
We're on Windows and we want to get a crash dump (possibly using MiniDumpWriteDump
) for all scenarios where our application exit's unexpectedly.
到目前为止,我们已经确定并设置了以下内容:
So far we have identified, and set up, the following:
-
SetUnhandledExceptionFilter
用于未处理的异常(Win32以及常规" C ++异常.) -
_set_invalid_parameter_handler
用于CRT无效参数处理 -
_set_abort_behavior
加上一个SIGABRT
处理程序,以解决对abort()
的调用
SetUnhandledExceptionFilter
for unhandled exception (Win32 as well as "normal" C++ ones.)_set_invalid_parameter_handler
for the CRT invalid argument handling_set_abort_behavior
plus aSIGABRT
handler to account for calls toabort()
有什么我们想念的吗?(对某些代码进行非法模块化,非法调用 ExitProcess
, TerminateProcess
或 exit
变体之一.)
Is there anything we missed? (Modulo some code non-legitimately calling ExitProcess
, TerminateProcess
or one of the exit
variants.)
我会注意到,这里的问题与如何崩溃崩溃转储正交.例如,如果您要在发生 abort
的情况下进行崩溃转储,则必须始终使用 _set_abort_behaviour
,因为否则将中止 exit
s.
I'll note that this question here is orthogonal to how a crash dump is then obtained. E.g., if you want a crash dump in case of abort
, you always must use _set_abort_behaviour
because otherwise abort just exit
s.
我还将注意到,在Windows7 +上,不是设置 SetUHEF
并仅设置在注册表中正确" WER转储设置通常是可行的方法.
I'll also note that on Windows7+, not setting SetUHEF
and just setting up the "correct" WER dump settings in the registry is often a viable way.
推荐答案
我完全使用您列出的内容,加上 _set_purecall_handler
,以及以下方便的代码段:
I use exactly the ones you've listed, plus _set_purecall_handler
, plus this handy snippet of code:
void EnableCrashingOnCrashes()
{
typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags);
typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);
static const DWORD EXCEPTION_SWALLOWING = 0x1;
const HMODULE kernel32 = LoadLibraryA("kernel32.dll");
const tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32, "GetProcessUserModeExceptionPolicy");
const tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32, "SetProcessUserModeExceptionPolicy");
if(pGetPolicy && pSetPolicy)
{
DWORD dwFlags;
if(pGetPolicy(&dwFlags))
{
// Turn off the filter
pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING);
}
}
}
来源: http://randomascii.wordpress.com/2012/07/05/when-even-crashing-doesnt-work/
他网站上的其他这些文章也帮助我理解了这一点: http://randomascii.wordpress.com/2011/12/07/increased通过更多的崩溃/ http://randomascii.wordpress.com/2012/07/22/more-adventures未能正确崩溃/
These other articles on his site also helped me understand this:http://randomascii.wordpress.com/2011/12/07/increased-reliability-through-more-crashes/http://randomascii.wordpress.com/2012/07/22/more-adventures-in-failing-to-crash-properly/
这篇关于在所有错误情况下,我需要采取什么措施来进行故障转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!