Skip to content

Commit

Permalink
Added CrashProbe crashes as a submodule.
Browse files Browse the repository at this point in the history
  • Loading branch information
kstenerud committed Jan 25, 2017
1 parent c03e441 commit eda32ce
Show file tree
Hide file tree
Showing 7 changed files with 683 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -20,4 +20,5 @@ Thumbs.db
.~*
*.orig
*.xccheckout
*.xcscmblueprint
Carthage/Build
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "Source/CrashProbe"]
path = Source/CrashProbe
url = https://github.com/bitstadium/CrashProbe.git
86 changes: 68 additions & 18 deletions iOS/Crash-Tester/AppDelegate+UI.m
Expand Up @@ -22,8 +22,8 @@
#import <KSCrash/KSCrashReportSinkQuincyHockey.h>
#import <KSCrash/KSCrashReportSinkStandard.h>
#import <KSCrash/KSCrashReportSinkVictory.h>


#import <CrashLib/CrashLib.h>
#import <CrashLib/CRLFramelessDWARF.h>

MAKE_CATEGORIES_LOADABLE(AppDelegate_UI)

Expand Down Expand Up @@ -56,10 +56,10 @@ - (CommandTVC*) commandTVCWithCommands:(NSArray*) commands
- (void) setBackButton:(UIViewController*) controller
{
controller.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStyleDone
target:nil
action:nil];
[[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStyleDone
target:nil
action:nil];
}

#pragma mark Commands
Expand Down Expand Up @@ -92,6 +92,16 @@ - (NSArray*) topLevelCommands
[controller.navigationController pushViewController:cmdController animated:YES];
}]];


[commands addObject:
[CommandEntry commandWithName:@"CrashProbe Crashes"
accessoryType:UITableViewCellAccessoryDisclosureIndicator
block:^(UIViewController* controller)
{
CommandTVC* cmdController = [self commandTVCWithCommands:[blockSelf crash2Commands]];
cmdController.title = @"CrashProbe Crashes";
[controller.navigationController pushViewController:cmdController animated:YES];
}]];
return commands;
}

Expand Down Expand Up @@ -203,7 +213,7 @@ - (NSArray*) mailCommands
{
[CrashTesterCommands mailSideBySideWithUserAndSystemData];
}]];

return commands;
}

Expand Down Expand Up @@ -250,15 +260,15 @@ - (NSArray*) printCommands
{
[CrashTesterCommands printSideBySide];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Apple Style + user & system data"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[CrashTesterCommands printSideBySideWithUserAndSystemData];
}]];

return commands;
}

Expand Down Expand Up @@ -364,7 +374,7 @@ - (NSArray*) crashCommands
{
[self.crasher throwUncaughtCPPException];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Bad Pointer"
accessoryType:UITableViewCellAccessoryNone
Expand Down Expand Up @@ -428,39 +438,39 @@ - (NSArray*) crashCommands
{
[self.crasher doIllegalInstruction];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Deallocated Object"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[self.crasher accessDeallocatedObject];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Deallocated Proxy"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[self.crasher accessDeallocatedPtrProxy];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Corrupt Memory"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[self.crasher corruptMemory];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Zombie NSException"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[self.crasher zombieNSException];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Crash in Handler"
accessoryType:UITableViewCellAccessoryNone
Expand All @@ -469,32 +479,72 @@ - (NSArray*) crashCommands
blockSelf.crashInHandler = YES;
[self.crasher dereferenceBadPointer];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Deadlock main queue"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[self.crasher deadlock];
}]];

[commands addObject:
[CommandEntry commandWithName:@"Deadlock pthread"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[self.crasher pthreadAPICrash];
}]];

[commands addObject:
[CommandEntry commandWithName:@"User Defined (soft) Crash"
accessoryType:UITableViewCellAccessoryNone
block:^(__unused UIViewController* controller)
{
[self.crasher userDefinedCrash];
}]];


return commands;
}

#define NEW_CRASH(TEXT, CLASS) \
[commands addObject: \
[CommandEntry commandWithName:TEXT \
accessoryType:UITableViewCellAccessoryNone \
block:^(__unused UIViewController* controller) \
{ \
[[CLASS new] crash]; \
}]]

- (NSArray*) crash2Commands
{
NSMutableArray* commands = [NSMutableArray array];
__block AppDelegate* blockSelf = self;

NEW_CRASH(@"Async Safe Thread", CRLCrashAsyncSafeThread);
NEW_CRASH(@"CXX Exception", CRLCrashCXXException);
NEW_CRASH(@"ObjC Exception", CRLCrashObjCException);
NEW_CRASH(@"NSLog", CRLCrashNSLog);
NEW_CRASH(@"ObjC Msg Send", CRLCrashObjCMsgSend);
NEW_CRASH(@"Released Object", CRLCrashReleasedObject);
NEW_CRASH(@"RO Page", CRLCrashROPage);
NEW_CRASH(@"Privileged Instruction", CRLCrashPrivInst);
NEW_CRASH(@"Undefined Instruction", CRLCrashUndefInst);
NEW_CRASH(@"NULL", CRLCrashNULL);
NEW_CRASH(@"Garbage", CRLCrashGarbage);
NEW_CRASH(@"NX Page", CRLCrashNXPage);
NEW_CRASH(@"Stack Guard", CRLCrashStackGuard);
NEW_CRASH(@"Trap", CRLCrashTrap);
NEW_CRASH(@"Abort", CRLCrashAbort);
NEW_CRASH(@"Corrupt Malloc", CRLCrashCorruptMalloc);
NEW_CRASH(@"Corrupt ObjC", CRLCrashCorruptObjC);
NEW_CRASH(@"Overwrite Link Register", CRLCrashOverwriteLinkRegister);
NEW_CRASH(@"Smash Stack Bottom", CRLCrashSmashStackBottom);
NEW_CRASH(@"Smash Stack Top", CRLCrashSmashStackTop);
NEW_CRASH(@"Frameless Dwarf", CRLFramelessDWARF);


return commands;
}

Expand Down

0 comments on commit eda32ce

Please sign in to comment.