Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -23,10 +23,11 @@ #include #include #import "OFObject.h" +#import "OFArray.h" #import "OFTimer.h" #import "OFRunLoop.h" #import "OFThread.h" #import "OFAllocFailedException.h" @@ -104,12 +105,22 @@ #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) static void uncaught_exception_handler(id exception) { + OFArray *backtrace = nil; + fprintf(stderr, "\nRuntime error: Unhandled exception:\n%s\n", [[exception description] UTF8String]); + + if ([exception respondsToSelector: @selector(backtrace)]) + backtrace = [exception backtrace]; + + if (backtrace != nil) + fprintf(stderr, "\nBacktrace:\n %s\n\n", + [[backtrace componentsJoinedByString: @"\n "] UTF8String]); + abort(); } #endif static void Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -17,13 +17,16 @@ #include "config.h" #include #import "OFString.h" +#import "OFArray.h" #import "OFStdIOStream.h" #import "OFFile.h" #import "OFAutoreleasePool.h" + +#import "OFException.h" #import "TestsAppDelegate.h" #ifdef _PSP # include @@ -84,13 +87,21 @@ } @catch (id e) { TestsAppDelegate *delegate = [[OFApplication sharedApplication] delegate]; OFString *string = [OFString stringWithFormat: @"\nRuntime error: Unhandled exception:\n%@\n", e]; + OFString *backtrace = [[e backtrace] + componentsJoinedByString: @"\n "]; [delegate outputString: string inColor: RED]; + if (backtrace != nil) { + backtrace = [OFString stringWithFormat: + @"\nBacktrace:\n %@\n\n", backtrace]; + [delegate outputString: backtrace + inColor: RED]; + } [delegate outputString: @"Press home button to exit!\n" inColor: NO_COLOR]; for (;;) { WPAD_ScanPads();