forked from qt-creator/qt-creator
Utils: improve assert stack printing on windows
Ignore the two top level frames since those only contain the assert infrastructure and indent the stack to make it better distinguishible from the actual asserts. Change-Id: I7aaa4996de5f96404bd3766310a3ae07616fb705 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -64,7 +64,8 @@ void dumpBacktrace(int maxdepth)
|
||||
frame.AddrStack.Offset = ctx.Sp;
|
||||
frame.AddrFrame.Offset = ctx.Fp;
|
||||
#endif
|
||||
int depth = 0;
|
||||
// ignore the first two frames those contain only writeAssertLocation and dumpBacktrace
|
||||
int depth = -3;
|
||||
|
||||
static bool symbolsInitialized = false;
|
||||
if (!symbolsInitialized) {
|
||||
@@ -82,6 +83,8 @@ void dumpBacktrace(int maxdepth)
|
||||
&SymFunctionTableAccess64,
|
||||
&SymGetModuleBase64,
|
||||
NULL)) {
|
||||
if (++depth < 0)
|
||||
continue;
|
||||
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
|
||||
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
|
||||
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
@@ -95,7 +98,7 @@ void dumpBacktrace(int maxdepth)
|
||||
IMAGEHLP_LINE64 lineInfo;
|
||||
SymSetOptions(SYMOPT_LOAD_LINES);
|
||||
|
||||
QString out = QString("%1: 0x%2 at %3")
|
||||
QString out = QString(" %1: 0x%2 at %3")
|
||||
.arg(depth)
|
||||
.arg(QString::number(pSymbol->Address, 16))
|
||||
.arg(QString::fromLatin1(&pSymbol->Name[0], pSymbol->NameLen));
|
||||
@@ -105,7 +108,7 @@ void dumpBacktrace(int maxdepth)
|
||||
QString::number(lineInfo.LineNumber)));
|
||||
}
|
||||
qDebug().noquote() << out;
|
||||
if (++depth == maxdepth)
|
||||
if (depth == maxdepth)
|
||||
break;
|
||||
}
|
||||
mutex.unlock();
|
||||
|
Reference in New Issue
Block a user