Skip to content

Commit d6da4de

Browse files
melakjef-n
authored andcommittedSep 9, 2013
fix gdb backtrace on FreeBSD
1 parent 45582e5 commit d6da4de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎src/app/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,15 @@ void qgisCrash( int signal )
253253
{
254254
// take full stacktrace using gdb
255255
// http://stackoverflow.com/questions/3151779/how-its-better-to-invoke-gdb-from-program-to-print-its-stacktrace
256+
// unfortunately, this is not so simple. the proper method is way more OS-specific
257+
// than this code would suggest, see http://stackoverflow.com/a/1024937
256258

257259
char exename[512];
260+
#if defined(__FreeBSD__)
261+
int len = readlink( "/proc/curproc/file", exename, sizeof( exename ) - 1 );
262+
#else
258263
int len = readlink( "/proc/self/exe", exename, sizeof( exename ) - 1 );
264+
#endif
259265
if ( len < 0 )
260266
{
261267
myPrint( "Could not read link (%d:%s)\n", errno, strerror( errno ) );

0 commit comments

Comments
 (0)
Please sign in to comment.