@ -30,7 +30,7 @@ static void StackTraceHandler(int sig) {
// reset to default handler
// reset to default handler
signal ( sig , SIG_DFL ) ;
signal ( sig , SIG_DFL ) ;
printf ( " Received signal %d (%s) \n " , sig , strsignal ( sig ) ) ;
f printf( stderr , " Received signal %d (%s) \n " , sig , strsignal ( sig ) ) ;
const int kMaxFrames = 100 ;
const int kMaxFrames = 100 ;
void * frames [ kMaxFrames ] ;
void * frames [ kMaxFrames ] ;
@ -44,9 +44,9 @@ static void StackTraceHandler(int sig) {
for ( int i = kSkip ; i < num_frames ; + + i )
for ( int i = kSkip ; i < num_frames ; + + i )
{
{
printf ( " #%-2d %p " , i - kSkip , frames [ i ] ) ;
f printf( stderr , " #%-2d %p " , i - kSkip , frames [ i ] ) ;
if ( symbols ) {
if ( symbols ) {
printf ( " %s " , symbols [ i ] ) ;
f printf( stderr , " %s " , symbols [ i ] ) ;
}
}
if ( executable ) {
if ( executable ) {
// out source to addr2line, for the address translation
// out source to addr2line, for the address translation
@ -57,14 +57,14 @@ static void StackTraceHandler(int sig) {
if ( f ) {
if ( f ) {
char line [ kLineMax ] ;
char line [ kLineMax ] ;
while ( fgets ( line , sizeof ( line ) , f ) ) {
while ( fgets ( line , sizeof ( line ) , f ) ) {
printf ( " %s " , line ) ;
f printf( stderr , " %s " , line ) ;
}
}
pclose ( f ) ;
pclose ( f ) ;
} else {
} else {
printf ( " \n " ) ;
f printf( stderr , " \n " ) ;
}
}
} else {
} else {
printf ( " \n " ) ;
f printf( stderr , " \n " ) ;
}
}
}
}
@ -79,6 +79,9 @@ void InstallStackTraceHandler() {
signal ( SIGSEGV , StackTraceHandler ) ;
signal ( SIGSEGV , StackTraceHandler ) ;
signal ( SIGBUS , StackTraceHandler ) ;
signal ( SIGBUS , StackTraceHandler ) ;
signal ( SIGABRT , StackTraceHandler ) ;
signal ( SIGABRT , StackTraceHandler ) ;
printf ( " Installed stack trace handler for SIGILL SIGSEGV SIGBUS SIGABRT \n " ) ;
}
}
} // namespace leveldb
} // namespace leveldb