Skip to content

Commit

Permalink
Fix symbol path for osgeo4w installs
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed May 5, 2017
1 parent 3e05bd8 commit 52093a5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ int main( int argc, char *argv[] )
#endif

#ifdef Q_OS_WIN
if ( !QgsApplication::isRunningFromBuildDir() )
{
QString symbolPath( getenv( "QGIS_PREFIX_PATH" ) );
symbolPath = symbolPath + "\\pdb;http://msdl.microsoft.com/download/symbols;http://download.osgeo.org/osgeo4w/symstore ";
QgsStackTrace::setSymbolPath( symbolPath );
}
SetUnhandledExceptionFilter( QgsCrashHandler::handle );
#endif

Expand Down
25 changes: 22 additions & 3 deletions src/core/qgsstacktrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ QVector<QgsStackTrace::StackLine> QgsStackTrace::trace( _EXCEPTION_POINTERS *Exc
#endif

HANDLE process = GetCurrentProcess();
// TOOD Pull symbols from symbol server.
SymSetOptions( SYMOPT_DEFERRED_LOADS | SYMOPT_INCLUDE_32BIT_MODULES | SYMOPT_UNDNAME );
SymInitialize( process, NULL, TRUE );

PCSTR paths;
if ( QgsStackTrace::mSymbolPaths.isEmpty() )
{
paths = NULL;
}
else
{
paths = QgsStackTrace::mSymbolPaths.toStdString().c_str();
}

BOOL success = SymInitialize( process, paths, TRUE );

// StackWalk64() may modify context record passed to it, so we will
// use a copy.
Expand Down Expand Up @@ -121,10 +131,19 @@ QVector<QgsStackTrace::StackLine> QgsStackTrace::trace( _EXCEPTION_POINTERS *Exc
qgsFree( symbol );
qgsFree( line );
qgsFree( module );
SymCleanup( process );
return stack;

}
#endif

QString QgsStackTrace::mSymbolPaths;

void QgsStackTrace::setSymbolPath( QString symbolPaths )
{
mSymbolPaths = symbolPaths;
}

#endif // Q_OS_WIN

#ifdef Q_OS_LINUX
QVector<QgsStackTrace::StackLine> QgsStackTrace::trace( unsigned int maxFrames )
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsstacktrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class CORE_EXPORT QgsStackTrace
* \note Added in QGIS 3.0
*/
static QVector<QgsStackTrace::StackLine> trace( struct _EXCEPTION_POINTERS *ExceptionInfo );

/**
* Set the paths to load the PDB symbols from on Windows.
* @param paths The path, or series of paths separated by a semicolon (;), that is used to search for symbol files.
*/
static void setSymbolPath( QString searchPath );
#endif

#ifdef Q_OS_LINUX
Expand All @@ -81,6 +87,7 @@ class CORE_EXPORT QgsStackTrace

private:
QgsStackTrace();
static QString mSymbolPaths;

};

Expand Down

0 comments on commit 52093a5

Please sign in to comment.