[Lldb-commits] [lldb] r114134 - in /lldb/trunk/test/foundation: TestObjCMethods.py main.m
Johnny Chen
johnny.chen at apple.com
Thu Sep 16 16:57:33 PDT 2010
Author: johnny
Date: Thu Sep 16 18:57:33 2010
New Revision: 114134
URL: http://llvm.org/viewvc/llvm-project?rev=114134&view=rev
Log:
Added extra test scenarios to break on a selector with:
(lldb) breakpoint set -S description
and a compilation unit defined instance method with:
(lldb) breakpoint set -n '-[MyString initWithNSString:]'
Modified:
lldb/trunk/test/foundation/TestObjCMethods.py
lldb/trunk/test/foundation/main.m
Modified: lldb/trunk/test/foundation/TestObjCMethods.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=114134&r1=114133&r2=114134&view=diff
==============================================================================
--- lldb/trunk/test/foundation/TestObjCMethods.py (original)
+++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Sep 16 18:57:33 2010
@@ -11,17 +11,17 @@
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 @@
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 @@
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]"])
Modified: lldb/trunk/test/foundation/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=114134&r1=114133&r2=114134&view=diff
==============================================================================
--- lldb/trunk/test/foundation/main.m (original)
+++ lldb/trunk/test/foundation/main.m Thu Sep 16 18:57:33 2010
@@ -1,9 +1,43 @@
#import <Foundation/Foundation.h>
+ at interface MyString : NSObject {
+ NSString *str;
+ NSDate *date;
+}
+- (id)initWithNSString:(NSString *)string;
+ at end
+
+ at 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];
+}
+ at 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 @@
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;
}
More information about the lldb-commits
mailing list