Fix spacing issues (using 8 space tab stops and indents, but I think that should only matter for the final fprintf().

This commit is contained in:
Steve Checkoway
2006-01-14 01:54:22 +00:00
parent a1a1061792
commit bc3d7d8af4
+109 -109
View File
@@ -41,21 +41,21 @@ static void output_stack_trace( FILE *out, const void **BacktracePointers )
return; return;
} }
for( int i = 0; BacktracePointers[i]; ++i) for( int i = 0; BacktracePointers[i]; ++i)
{ {
BacktraceNames bn; BacktraceNames bn;
bn.FromAddr( BacktracePointers[i] ); bn.FromAddr( BacktracePointers[i] );
bn.Demangle(); bn.Demangle();
/* Don't show the main module name. */ /* Don't show the main module name. */
if( bn.File == g_pCrashHandlerArgv0 ) if( bn.File == g_pCrashHandlerArgv0 )
bn.File = ""; bn.File = "";
if( bn.Symbol == "__libc_start_main" ) if( bn.Symbol == "__libc_start_main" )
break; break;
fprintf( out, "%s\n", bn.Format().c_str() ); fprintf( out, "%s\n", bn.Format().c_str() );
} }
} }
#if !defined(MACOSX) #if !defined(MACOSX)
@@ -189,78 +189,78 @@ bool child_read( int fd, void *p, int size )
* heavyweights like malloc and CString are OK. (Don't crash!) */ * heavyweights like malloc and CString are OK. (Don't crash!) */
static void child_process() static void child_process()
{ {
/* 1. Read the CrashData. */ /* 1. Read the CrashData. */
CrashData crash; CrashData crash;
if( !child_read(3, &crash, sizeof(CrashData)) ) if( !child_read(3, &crash, sizeof(CrashData)) )
return; return;
/* 2. Read info. */ /* 2. Read info. */
int size; int size;
if( !child_read(3, &size, sizeof(size)) ) if( !child_read(3, &size, sizeof(size)) )
return; return;
char *Info = new char [size]; char *Info = new char [size];
if( !child_read(3, Info, size) ) if( !child_read(3, Info, size) )
return; return;
/* 3. Read AdditionalLog. */ /* 3. Read AdditionalLog. */
if( !child_read(3, &size, sizeof(size)) ) if( !child_read(3, &size, sizeof(size)) )
return; return;
char *AdditionalLog = new char [size]; char *AdditionalLog = new char [size];
if( !child_read(3, AdditionalLog, size) ) if( !child_read(3, AdditionalLog, size) )
return; return;
/* 4. Read RecentLogs. */ /* 4. Read RecentLogs. */
int cnt = 0; int cnt = 0;
if( !child_read(3, &cnt, sizeof(cnt)) ) if( !child_read(3, &cnt, sizeof(cnt)) )
return; return;
char *Recent[1024]; char *Recent[1024];
for( int i = 0; i < cnt; ++i ) for( int i = 0; i < cnt; ++i )
{ {
if( !child_read(3, &size, sizeof(size)) ) if( !child_read(3, &size, sizeof(size)) )
return; return;
Recent[i] = new char [size]; Recent[i] = new char [size];
if( !child_read(3, Recent[i], size) ) if( !child_read(3, Recent[i], size) )
return; return;
} }
/* 5. Read CHECKPOINTs. */ /* 5. Read CHECKPOINTs. */
if( !child_read(3, &size, sizeof(size)) ) if( !child_read(3, &size, sizeof(size)) )
return; return;
char *temp = new char [size]; char *temp = new char [size];
if( !child_read(3, temp, size) ) if( !child_read(3, temp, size) )
return; return;
vector<CString> Checkpoints; vector<CString> Checkpoints;
split(temp, "$$", Checkpoints); split(temp, "$$", Checkpoints);
delete [] temp; delete [] temp;
/* 6. Read the crashed thread's name. */ /* 6. Read the crashed thread's name. */
if( !child_read(3, &size, sizeof(size)) ) if( !child_read(3, &size, sizeof(size)) )
return; return;
temp = new char [size]; temp = new char [size];
if( !child_read(3, temp, size) ) if( !child_read(3, temp, size) )
return; return;
const CString CrashedThread(temp); const CString CrashedThread(temp);
delete[] temp; delete[] temp;
/* Wait for the child to either finish cleaning up or die. XXX: /* Wait for the child to either finish cleaning up or die. XXX:
* This should time out, in case something deadlocks. */ * This should time out, in case something deadlocks. */
char x; char x;
int ret = read( 3, &x, sizeof(x) ); int ret = read( 3, &x, sizeof(x) );
if( ret > 0 ) if( ret > 0 )
{ {
fprintf( stderr, "Unexpected child read() result: %i\n", ret ); fprintf( stderr, "Unexpected child read() result: %i\n", ret );
/* keep going */ /* keep going */
} }
else if( (ret == -1 && errno != EPIPE) || ret != 0 ) else if( (ret == -1 && errno != EPIPE) || ret != 0 )
{ {
/* We expect an EOF or EPIPE. What happened? */ /* We expect an EOF or EPIPE. What happened? */
fprintf( stderr, "Unexpected child read() result: %i (%s)\n", ret, strerror(errno) ); fprintf( stderr, "Unexpected child read() result: %i (%s)\n", ret, strerror(errno) );
/* keep going */ /* keep going */
} }
const char *home = getenv( "HOME" ); const char *home = getenv( "HOME" );
CString sCrashInfoPath = "/tmp"; CString sCrashInfoPath = "/tmp";
@@ -275,17 +275,17 @@ static void child_process()
exit(1); exit(1);
} }
fprintf( CrashDump, "%s crash report", PRODUCT_NAME_VER ); fprintf( CrashDump, "%s crash report", PRODUCT_NAME_VER );
#if defined(HAVE_VERSION_INFO) #if defined(HAVE_VERSION_INFO)
fprintf( CrashDump, " (build %u)", version_num); fprintf( CrashDump, " (build %u)", version_num);
#endif #endif
fprintf( CrashDump, "\n" ); fprintf( CrashDump, "\n" );
fprintf( CrashDump, "--------------------------------------\n" ); fprintf( CrashDump, "--------------------------------------\n" );
fprintf( CrashDump, "\n" ); fprintf( CrashDump, "\n" );
CString reason; CString reason;
switch( crash.type ) switch( crash.type )
{ {
case CrashData::SIGNAL: case CrashData::SIGNAL:
{ {
CString Signal = SignalName( crash.signal ); CString Signal = SignalName( crash.signal );
@@ -317,56 +317,56 @@ static void child_process()
crash.reason[ sizeof(crash.reason)-1] = 0; crash.reason[ sizeof(crash.reason)-1] = 0;
reason = crash.reason; reason = crash.reason;
break; break;
} }
fprintf( CrashDump, "Crash reason: %s\n", reason.c_str() ); fprintf( CrashDump, "Crash reason: %s\n", reason.c_str() );
fprintf( CrashDump, "Crashed thread: %s\n\n", CrashedThread.c_str() ); fprintf( CrashDump, "Crashed thread: %s\n\n", CrashedThread.c_str() );
fprintf(CrashDump, "Checkpoints:\n"); fprintf(CrashDump, "Checkpoints:\n");
for( unsigned i=0; i<Checkpoints.size(); ++i ) for( unsigned i=0; i<Checkpoints.size(); ++i )
fprintf( CrashDump, Checkpoints[i] ); fprintf( CrashDump, Checkpoints[i] );
fprintf( CrashDump, "\n" ); fprintf( CrashDump, "\n" );
for( int i = 0; i < CrashData::MAX_BACKTRACE_THREADS; ++i ) for( int i = 0; i < CrashData::MAX_BACKTRACE_THREADS; ++i )
{ {
if( !crash.BacktracePointers[i][0] ) if( !crash.BacktracePointers[i][0] )
break; break;
fprintf( CrashDump, "Thread: %s\n", crash.m_ThreadName[i] ); fprintf( CrashDump, "Thread: %s\n", crash.m_ThreadName[i] );
output_stack_trace( CrashDump, crash.BacktracePointers[i] ); output_stack_trace( CrashDump, crash.BacktracePointers[i] );
fprintf( CrashDump, "\n" ); fprintf( CrashDump, "\n" );
} }
fprintf( CrashDump, "Static log:\n" ); fprintf( CrashDump, "Static log:\n" );
fprintf( CrashDump, "%s", Info ); fprintf( CrashDump, "%s", Info );
fprintf( CrashDump, "%s", AdditionalLog ); fprintf( CrashDump, "%s", AdditionalLog );
fprintf(CrashDump, "\nPartial log:\n" ); fprintf(CrashDump, "\nPartial log:\n" );
for( int i = 0; i < cnt; ++i ) for( int i = 0; i < cnt; ++i )
fprintf( CrashDump, "%s\n", Recent[i] ); fprintf( CrashDump, "%s\n", Recent[i] );
fprintf( CrashDump, "\n" ); fprintf( CrashDump, "\n" );
fprintf( CrashDump, "-- End of report\n" ); fprintf( CrashDump, "-- End of report\n" );
fclose( CrashDump) ; fclose( CrashDump) ;
#if defined(MACOSX) #if defined(MACOSX)
/* Forcibly kill our parent. */ /* Forcibly kill our parent. */
kill( getppid(), SIGKILL ); kill( getppid(), SIGKILL );
InformUserOfCrash( sCrashInfoPath ); InformUserOfCrash( sCrashInfoPath );
#else #else
/* stdout may have been inadvertently closed by the crash in the parent; /* stdout may have been inadvertently closed by the crash in the parent;
* write to /dev/tty instead. */ * write to /dev/tty instead. */
FILE *tty = fopen( "/dev/tty", "w" ); FILE *tty = fopen( "/dev/tty", "w" );
if( tty == NULL ) if( tty == NULL )
tty = stderr; tty = stderr;
fprintf( tty, fprintf( tty,
"\n" "\n"
PRODUCT_NAME " has crashed. Debug information has been output to\n" PRODUCT_NAME " has crashed. Debug information has been output to\n"
"\n" "\n"
" " + sCrashInfoPath + "\n" " " + sCrashInfoPath + "\n"
"\n" "\n"
"Please report a bug at:\n" "Please report a bug at:\n"
"\n" "\n"
" " REPORT_BUG_URL "\n" " " REPORT_BUG_URL "\n"
"\n" ); "\n" );
#endif #endif
} }