Merged [18171]: An exception like [http://www.visualdistortion.org/crash/view.jsp...
[adiumx.git] / Other / XtrasCreator / AXCAppDelegate.m
blob33d4ee0b7f14b923b6ca4ddc0bdab7888f56eca0
1 //
2 //  LMXAppDelegate.m
3 //  LMX
4 //
5 //  Created by Mac-arena the Bored Zo on 2005-10-17.
6 //  Copyright 2005 Mac-arena the Bored Zo. All rights reserved.
7 //
9 #import "AXCAppDelegate.h"
11 #include <sys/types.h>
12 #include <unistd.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];
23         return 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];
47         [task launch];
48         [task waitUntilExit];
50         NSFileHandle *fh = [pipe fileHandleForReading];
51         NSData *data = [fh readDataToEndOfFile];
52         NSString *stackTrace = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
54         [task release];
56         NSLog(@"got %@ with reason %@; stack trace follows\n%@", [exception name], [exception reason], stackTrace);
58         return NO; //because we just did
61 @end