Skip to content

Commit

Permalink
cleanup c++filt
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Aug 25, 2013
1 parent 642df45 commit 7a5faf7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/main.cpp
Expand Up @@ -211,6 +211,7 @@ static void dumpBacktrace( unsigned int depth )
depth = 20;

#if (defined(linux) && !defined(ANDROID)) || defined(__FreeBSD__)
int stderr_fd = -1;
if ( access( "/usr/bin/c++filt", X_OK ) < 0 )
{
myPrint( "Stacktrace (c++filt NOT FOUND):\n" );
Expand All @@ -230,15 +231,25 @@ static void dumpBacktrace( unsigned int depth )
}

myPrint( "Stacktrace (piped through c++filt):\n" );
stderr_fd = dup( STDERR_FILENO );
close( fd[0] ); // close reading end
close( STDERR_FILENO ); // close stderr
dup( fd[1] ); // stderr to pipe
close( fd[1] ); // close duped pipe
}

void **buffer = new void *[ depth ];
int nptrs = backtrace( buffer, depth );
backtrace_symbols_fd( buffer, nptrs, STDERR_FILENO );
delete [] buffer;
if ( stderr_fd >= 0 )
{
int status;
close( STDERR_FILENO );
dup( stderr_fd );
close( stderr_fd );
wait( &status );
}
#elif defined(Q_OS_WIN)
void **buffer = new void *[ depth ];

Expand Down

0 comments on commit 7a5faf7

Please sign in to comment.