WindowsFaultHandler: print the backtrace to stderr, not stdout

Otherwise the contents that vary per architecture and build will make it
impossible to self-check (tst_selftests)

Change-Id: Ibcde9b9795ad42ac9978fffd16f2cbc352c3503c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2022-05-26 16:34:12 -07:00 committed by Volker Hilsheimer
parent 764d82ceb5
commit 37aa9a9cef

View File

@ -1878,7 +1878,7 @@ private:
const int msecsFunctionTime = qRound(QTestLog::msecsFunctionTime());
const int msecsTotalTime = qRound(QTestLog::msecsTotalTime());
const void *exceptionAddress = exInfo->ExceptionRecord->ExceptionAddress;
printf("A crash occurred in %s.\n"
fprintf(stderr, "A crash occurred in %s.\n"
"Function time: %dms Total time: %dms\n\n"
"Exception address: 0x%p\n"
"Exception code : 0x%lx\n",
@ -1889,25 +1889,24 @@ private:
if (resolver.isValid()) {
DebugSymbolResolver::Symbol exceptionSymbol = resolver.resolveSymbol(DWORD64(exceptionAddress));
if (exceptionSymbol.name) {
printf("Nearby symbol : %s\n", exceptionSymbol.name);
fprintf(stderr, "Nearby symbol : %s\n", exceptionSymbol.name);
delete [] exceptionSymbol.name;
}
void *stack[maxStackFrames];
fputs("\nStack:\n", stdout);
fputs("\nStack:\n", stderr);
const unsigned frameCount = CaptureStackBackTrace(0, DWORD(maxStackFrames), stack, NULL);
for (unsigned f = 0; f < frameCount; ++f) {
DebugSymbolResolver::Symbol symbol = resolver.resolveSymbol(DWORD64(stack[f]));
if (symbol.name) {
printf("#%3u: %s() - 0x%p\n", f + 1, symbol.name, (const void *)symbol.address);
fprintf(stderr, "#%3u: %s() - 0x%p\n", f + 1, symbol.name, (const void *)symbol.address);
delete [] symbol.name;
} else {
printf("#%3u: Unable to obtain symbol\n", f + 1);
fprintf(stderr, "#%3u: Unable to obtain symbol\n", f + 1);
}
}
}
fputc('\n', stdout);
fflush(stdout);
fputc('\n', stderr);
return EXCEPTION_EXECUTE_HANDLER;
}