[Lldb-commits] [lldb] r136386 - in /lldb/trunk/test/lang: cpp/namespace/main.cpp objc/radar-9691614/ objc/radar-9691614/Makefile objc/radar-9691614/TestObjCMethodReturningBOOL.py objc/radar-9691614/main.m

Johnny Chen johnny.chen at apple.com
Thu Jul 28 13:46:14 PDT 2011


Author: johnny
Date: Thu Jul 28 15:46:14 2011
New Revision: 136386

URL: http://llvm.org/viewvc/llvm-project?rev=136386&view=rev
Log:
Add a reproducible test case (expression parser crashes) to the lldb test suite.

rdar://problem/9691614.

Added:
    lldb/trunk/test/lang/objc/radar-9691614/
    lldb/trunk/test/lang/objc/radar-9691614/Makefile
    lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py
    lldb/trunk/test/lang/objc/radar-9691614/main.m
Modified:
    lldb/trunk/test/lang/cpp/namespace/main.cpp

Modified: lldb/trunk/test/lang/cpp/namespace/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/namespace/main.cpp?rev=136386&r1=136385&r2=136386&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/namespace/main.cpp (original)
+++ lldb/trunk/test/lang/cpp/namespace/main.cpp Thu Jul 28 15:46:14 2011
@@ -51,6 +51,7 @@
     }
 }
 
+#include <stdio.h>
 int Foo::myfunc(int a)
 {
     ::my_uint_t anon_uint = 0;
@@ -59,6 +60,8 @@
     Y::uint_t y_uint = 3;
     i = 3;
     j = 4;
+    printf("::i=%d\n", ::i);
+    printf("A::B::j=%d\n", A::B::j);
     return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; // Set break point at this line.
 }
 

Added: lldb/trunk/test/lang/objc/radar-9691614/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/radar-9691614/Makefile?rev=136386&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/radar-9691614/Makefile (added)
+++ lldb/trunk/test/lang/objc/radar-9691614/Makefile Thu Jul 28 15:46:14 2011
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation

Added: lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py?rev=136386&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py (added)
+++ lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py Thu Jul 28 15:46:14 2011
@@ -0,0 +1,62 @@
+"""
+Test that objective-c method returning BOOL works correctly.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+ at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+class MethodReturningBOOLTestCase(TestBase):
+
+    mydir = os.path.join("lang", "objc", "radar-9691614")
+
+    def test_method_ret_BOOL_with_dsym(self):
+        """Test that objective-c method returning BOOL works correctly."""
+        d = {'EXE': self.exe_name}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.objc_method_ret_BOOL(self.exe_name)
+
+    def test_method_ret_BOOL_with_dwarf(self):
+        """Test that objective-c method returning BOOL works correctly."""
+        d = {'EXE': self.exe_name}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.objc_method_ret_BOOL(self.exe_name)
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # We'll use the test method name as the exe_name.
+        self.exe_name = self.testMethodName
+        # Find the line number to break inside main().
+        self.main_source = "main.m"
+        self.line = line_number(self.main_source, '// Set breakpoint here.')
+
+    @unittest2.skip("rdar://problem/9691614 Expression parser crashes")
+    def objc_method_ret_BOOL(self, exe_name):
+        """Test that objective-c method returning BOOL works correctly."""
+        exe = os.path.join(os.getcwd(), exe_name)
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        self.expect("breakpoint set -f %s -l %d" % (self.main_source, self.line),
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" %
+                        (self.main_source, self.line))
+
+        self.runCmd("run", RUN_SUCCEEDED)
+        self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = [" at %s:%d" % (self.main_source, self.line),
+                       "stop reason = breakpoint"])
+
+        # rdar://problem/9691614
+        self.runCmd('p (int)[my isValid]')
+
+        
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/lang/objc/radar-9691614/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/radar-9691614/main.m?rev=136386&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/radar-9691614/main.m (added)
+++ lldb/trunk/test/lang/objc/radar-9691614/main.m Thu Jul 28 15:46:14 2011
@@ -0,0 +1,67 @@
+#import <Foundation/Foundation.h>
+#include <stdio.h>
+
+ at interface MyString : NSObject {
+    NSString *str;
+    NSDate *date;
+    BOOL _is_valid;
+}
+
+- (id)initWithNSString:(NSString *)string;
+- (BOOL)isValid;
+ at end
+
+ at implementation MyString
+- (id)initWithNSString:(NSString *)string
+{
+    if (self = [super init])
+    {
+        str = [NSString stringWithString:string];
+        date = [NSDate date];
+    }
+    _is_valid = YES;
+    return self;
+}
+
+- (BOOL)isValid
+{
+    return _is_valid;
+}
+
+- (void)dealloc
+{
+    [date release];
+    [str release];
+    [super dealloc];
+}
+
+- (NSString *)description
+{
+    return [str stringByAppendingFormat:@" with timestamp: %@", date];
+}
+ at end
+
+void
+Test_MyString (const char *program)
+{
+    NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program];
+    MyString *my = [[MyString alloc] initWithNSString:str];
+    if ([my isValid])
+        printf("my is valid!\n");
+
+    NSLog(@"NSString instance: %@", [str description]); // Set breakpoint here.
+                                                        // Test 'p (int)[my isValid]'.
+                                                        // The expression parser should not crash -- rdar://problem/9691614.
+
+    NSLog(@"MyString instance: %@", [my description]);
+}
+
+int main (int argc, char const *argv[])
+{
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+    Test_MyString (argv[0]);
+
+    [pool release];
+    return 0;
+}





More information about the lldb-commits mailing list