Skip to content
Permalink
Browse files

show source locations in windows backtraces

  • Loading branch information
jef-n committed Mar 5, 2016
1 parent 1e3dc29 commit 26d61956d75dd0e522f49a41cec9faef0f2e3719
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/app/main.cpp
@@ -262,15 +262,26 @@ static void dumpBacktrace( unsigned int depth )
SYMBOL_INFO *symbol = ( SYMBOL_INFO * ) qgsMalloc( sizeof( SYMBOL_INFO ) + 256 );
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof( SYMBOL_INFO );
IMAGEHLP_LINE *line = ( IMAGEHLP_LINE * ) qgsMalloc( sizeof( IMAGEHLP_LINE ) );
line->SizeOfStruct = sizeof( IMAGEHLP_LINE );

for ( int i = 0; i < nFrames; i++ )
{
DWORD dwDisplacement;
SymFromAddr( GetCurrentProcess(), ( DWORD64 )( buffer[ i ] ), 0, symbol );
symbol->Name[ 255 ] = 0;
myPrint( "%d: %s [%x]\n", i, symbol->Name, symbol->Address );
if ( SymGetLineFromAddr( GetCurrentProcess(), ( DWORD64 )( buffer[i] ), &dwDisplacement, line ) )
{
myPrint( "%s(%d) : (%s) frame %d, address %x\n", line->FileName, line->LineNumber, symbol->Name, i, symbol->Address );
}
else
{
myPrint( "%s(%d) : (%s) unknown source location, frame %d, address %x [GetLastError()=%d]\n", __FILE__, __LINE__, symbol->Name, i, symbol->Address, GetLastError() );
}
}

qgsFree( symbol );
qgsFree( line );
#else
Q_UNUSED( depth );
#endif

1 comment on commit 26d6195

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 commented on 26d6195 Mar 5, 2016

Does this only effect debug builds?

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