5 // Created by Mac-arena the Bored Zo on 2005-10-17.
6 // Copyright 2005 Mac-arena the Bored Zo. All rights reserved.
9 #import "AXCAppDelegate.h"
11 #include <sys/types.h>
13 #import <ExceptionHandling/NSExceptionHandler.h>
15 #import "AXCStartingPointsController.h"
16 #import "AXCPreferenceController.h"
18 @implementation AXCAppDelegate
20 - (BOOL)applicationOpenUntitledFile:(NSApplication *)theApplication
22 [startingPointsController setStartingPointsVisible:YES];
26 #pragma mark Ganked from LMXAppDelegate (in LMX)
28 - (void)applicationDidFinishLaunching:(NSNotification *)notification {
29 #pragma unused(notification)
30 NSExceptionHandler *excHandler = [NSExceptionHandler defaultExceptionHandler];
31 [excHandler setExceptionHandlingMask:NSLogUncaughtExceptionMask | NSLogUncaughtSystemExceptionMask | NSLogUncaughtRuntimeErrorMask | NSLogTopLevelExceptionMask | NSLogOtherExceptionMask];
32 [excHandler setDelegate:self];
35 - (BOOL)exceptionHandler:(NSExceptionHandler *)sender shouldLogException:(NSException *)exception mask:(unsigned int)aMask {
36 NSMutableArray *symbols = [[[[exception userInfo] objectForKey:NSStackTraceKey] componentsSeparatedByString:@" "] mutableCopy];
38 [symbols insertObject:@"-p" atIndex:0U];
39 [symbols insertObject:[[NSNumber numberWithInt:getpid()] stringValue] atIndex:1U];
41 NSTask *task = [[NSTask alloc] init];
42 [task setLaunchPath:@"/usr/bin/atos"];
43 [task setArguments:symbols];
44 NSPipe *pipe = [NSPipe pipe];
45 [task setStandardOutput:pipe];
50 NSFileHandle *fh = [pipe fileHandleForReading];
51 NSData *data = [fh readDataToEndOfFile];
52 NSString *stackTrace = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
56 NSLog(@"got %@ with reason %@; stack trace follows\n%@", [exception name], [exception reason], stackTrace);
58 return NO; //because we just did