Files
clang-p2996/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/main.m
Kuba Mracek c3f1e62920 [lldb] Extract more fields from NSException values
This patch teaches LLDB about more fields on NSException Obj-C objects, specifically we can now retrieve the "name" and "reason" of an NSException. The goal is to eventually be able to have SB API that can provide details about the currently thrown/caught/processed exception.

Differential Revision: https://reviews.llvm.org/D43884

llvm-svn: 346695
2018-11-12 19:12:31 +00:00

37 lines
1.1 KiB
Objective-C

//===-- main.m ------------------------------------------------*- ObjC -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#import <Foundation/Foundation.h>
void foo()
{
NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"some_value", @"some_key", nil];
@throw [[NSException alloc] initWithName:@"ThrownException" reason:@"SomeReason" userInfo:info];
}
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"some_value", @"some_key", nil];
NSException *e1 = [[NSException alloc] initWithName:@"ExceptionName" reason:@"SomeReason" userInfo:info];
NSException *e2;
@try {
foo();
} @catch(NSException *e) {
e2 = e;
}
NSLog(@"1"); // Set break point at this line.
[pool drain];
return 0;
}