Skip to content
Permalink
Browse files

Add local symbols to stack trace in crash

  • Loading branch information
NathanW2 committed Nov 11, 2017
1 parent 41abc0b commit e4596052c06c480d618b29c0fe3c2e72f2481b7a
Showing with 22 additions and 10 deletions.
  1. +22 −10 src/crashhandler/qgsstacktrace.cpp
@@ -508,27 +508,34 @@ bool printType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, void *valueLocat
return printGivenType( stackTrace, pSymInfo, symbolTag, pSymInfo->TypeIndex, valueLocation, false );
}


BOOL CALLBACK enumParams(
_In_ PSYMBOL_INFOW pSymInfo,
_In_ ULONG SymbolSize,
_In_opt_ PVOID UserContext )
{
if ( ( pSymInfo->Flags & SYMFLAG_PARAMETER ) == 0 )
if ( ( pSymInfo->Flags & SYMFLAG_LOCAL ) == 0 )
{
return TRUE;
}

StackTrace *stackTrace = ( StackTrace * )UserContext;

if ( stackTrace->isFirstParameter )
stackTrace->written +=
swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written,
L"\n" );

if ( pSymInfo->Flags & SYMFLAG_PARAMETER )
{
stackTrace->isFirstParameter = false;
stackTrace->written +=
swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written,
L"Parm: " );
}
else
else if ( pSymInfo->Flags & SYMFLAG_LOCAL )
{
stackTrace->written +=
swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written,
L", " );
L"Local: " );
}

stackTrace->written +=
@@ -612,6 +619,14 @@ BOOL CALLBACK enumParams(
return TRUE;
}
}
else if ( pSymInfo->Flags & SYMFLAG_LOCAL )
{
#ifndef _WIN64
valueLocation = ( ( char * )stackTrace->contextRecord->Ebp ) + pSymInfo->Address;
#else
valueLocation = ( ( char * )stackTrace->contextRecord->Rbp ) + pSymInfo->Address;
#endif
}
else if ( pSymInfo->Flags & SYMFLAG_REGREL )
{
switch ( pSymInfo->Register )
@@ -711,7 +726,7 @@ void getStackTrace( StackTrace *stackTrace, QString symbolPath, QgsStackTrace *t

stackTrace->written +=
swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written - 1,
L">%02i: 0x%08llX %ls (", i, symbol->Address, symbol->Name );
L">%02i: 0x%08llX %ls", i, symbol->Address, symbol->Name );

IMAGEHLP_STACK_FRAME stackFrame = { 0 };
stackFrame.InstructionOffset = symbol->Address;
@@ -721,9 +736,6 @@ void getStackTrace( StackTrace *stackTrace, QString symbolPath, QgsStackTrace *t
SymEnumSymbolsW( stackTrace->process, 0, NULL, enumParams, stackTrace );
}

swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written,
L")" );

DWORD pos;
IMAGEHLP_LINEW64 lineInfo = { 0 };
lineInfo.SizeOfStruct = sizeof( lineInfo );
@@ -734,7 +746,7 @@ void getStackTrace( StackTrace *stackTrace, QString symbolPath, QgsStackTrace *t

stackTrace->written +=
swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written,
L" at %ls:%lu", lineInfo.FileName, lineInfo.LineNumber );
L"\nSource: %ls:%lu", lineInfo.FileName, lineInfo.LineNumber );
}

stackTrace->written +=

0 comments on commit e459605

Please sign in to comment.
You can’t perform that action at this time.