diff options
-rw-r--r-- | lldb/test/foundation/TestObjCMethods.py | 28 | ||||
-rw-r--r-- | lldb/test/foundation/main.m | 37 |
2 files changed, 60 insertions, 5 deletions
diff --git a/lldb/test/foundation/TestObjCMethods.py b/lldb/test/foundation/TestObjCMethods.py index 0d40d956bf4..c7c6753bdc6 100644 --- a/lldb/test/foundation/TestObjCMethods.py +++ b/lldb/test/foundation/TestObjCMethods.py @@ -11,17 +11,17 @@ class FoundationTestCase(TestBase): mydir = "foundation" def test_with_dsym(self): - """Test setting objc breakpoints using regexp-break.""" + """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" self.buildDsym() self.break_on_objc_methods() def test_with_dwarf(self): - """Test setting objc breakpoints using regexp-break.""" + """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" self.buildDwarf() self.break_on_objc_methods() def break_on_objc_methods(self): - """Test setting objc breakpoints using regexp-break.""" + """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -29,9 +29,17 @@ class FoundationTestCase(TestBase): self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1") + # Stop at -[MyString initWithNSString:]. + self.expect("breakpoint set -n '-[MyString initWithNSString:]'", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: name = '-[MyString initWithNSString:]', locations = 1") + + # Stop at the "description" selector. + self.expect("breakpoint set -S description", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 3: name = 'description', locations = 1") + # Stop at -[NSAutoreleasePool release]. self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 2: name = '-[NSAutoreleasePool release]', locations = 1") + startstr = "Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1") self.runCmd("run", RUN_SUCCEEDED) @@ -41,6 +49,18 @@ class FoundationTestCase(TestBase): self.runCmd("process continue") + # Followed by a.out`-[MyString initWithNSString:]. + self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", + substrs = ["a.out`-[MyString initWithNSString:]"]) + + self.runCmd("process continue") + + # Followed by -[MyString description]. + self.expect("thread backtrace", "Stop at -[MyString description]", + substrs = ["a.out`-[MyString description]"]) + + self.runCmd("process continue") + # Followed by -[NSAutoreleasePool release]. self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", substrs = ["Foundation`-[NSAutoreleasePool release]"]) diff --git a/lldb/test/foundation/main.m b/lldb/test/foundation/main.m index 3efbb558688..6b20489ac6f 100644 --- a/lldb/test/foundation/main.m +++ b/lldb/test/foundation/main.m @@ -1,9 +1,43 @@ #import <Foundation/Foundation.h> +@interface MyString : NSObject { + NSString *str; + NSDate *date; +} +- (id)initWithNSString:(NSString *)string; +@end + +@implementation MyString +- (id)initWithNSString:(NSString *)string +{ + [super init]; + str = [NSString stringWithString:string]; + date = [NSDate date]; + return self; +} + +- (void)dealloc +{ + [date release]; + [str release]; + [super dealloc]; +} + +- (NSString *)description +{ + return [str stringByAppendingFormat:@" with timestamp: %@", date]; +} +@end + int main (int argc, char const *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSString *str = [NSString stringWithFormat:@"Hello from '%s'", argv[0]]; + NSString *str = [NSString stringWithFormat:@"Hello from '%s'", argv[0]]; + NSLog(@"NSString instance: %@", str); + + MyString *my = [[MyString alloc] initWithNSString:str]; + NSLog(@"MyString instance: %@", [my description]); + id str_id = str; SEL sel = @selector(length); BOOL responds = [str respondsToSelector:sel]; @@ -12,6 +46,7 @@ int main (int argc, char const *argv[]) printf("sizeof(SEL) = %zu\n", sizeof(SEL)); printf("[str length] = %zu\n", [str length]); printf("str = '%s'\n", [str cStringUsingEncoding: [NSString defaultCStringEncoding]]); + [pool release]; return 0; } |