[Lldb-commits] [lldb] r121894 - in /lldb/trunk/test/foundation: Makefile TestObjCMethods.py main.m my-base.h my-base.m

Jim Ingham jingham at apple.com
Wed Dec 15 12:47:34 PST 2010


Author: jingham
Date: Wed Dec 15 14:47:34 2010
New Revision: 121894

URL: http://llvm.org/viewvc/llvm-project?rev=121894&view=rev
Log:
Added a test for finding the correct values for ivars when a property causes the ivar offsets
in the DWARF to be incorrect.

Added:
    lldb/trunk/test/foundation/my-base.h
    lldb/trunk/test/foundation/my-base.m
Modified:
    lldb/trunk/test/foundation/Makefile
    lldb/trunk/test/foundation/TestObjCMethods.py
    lldb/trunk/test/foundation/main.m

Modified: lldb/trunk/test/foundation/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/Makefile?rev=121894&r1=121893&r2=121894&view=diff
==============================================================================
--- lldb/trunk/test/foundation/Makefile (original)
+++ lldb/trunk/test/foundation/Makefile Wed Dec 15 14:47:34 2010
@@ -1,6 +1,6 @@
 LEVEL = ../make
 
-OBJC_SOURCES := main.m
+OBJC_SOURCES := main.m my-base.m
 LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
 
 include $(LEVEL)/Makefile.rules

Modified: lldb/trunk/test/foundation/TestObjCMethods.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=121894&r1=121893&r2=121894&view=diff
==============================================================================
--- lldb/trunk/test/foundation/TestObjCMethods.py (original)
+++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Dec 15 14:47:34 2010
@@ -39,6 +39,16 @@
         self.buildDwarf()
         self.data_type_and_expr_objc()
 
+    @python_api_test
+    def test_print_ivars_correctly_with_dsym (self):
+        self.buildDsym()
+        self.print_ivars_correctly()
+
+    @python_api_test
+    def test_print_ivars_correctly_with_dwarf (self):
+        self.buildDwarf()
+        self.print_ivars_correctly()
+
     def break_on_objc_methods(self):
         """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'."""
         exe = os.path.join(os.getcwd(), "a.out")
@@ -100,7 +110,8 @@
         # Call super's setUp().
         TestBase.setUp(self)
         # Find the line number to break inside main().
-        self.line = line_number('main.m', '// Set break point at this line.')
+        self.main_source = "main.m"
+        self.line = line_number(self.main_source, '// Set break point at this line.')
 
     def data_type_and_expr_objc(self):
         """Lookup objective-c data types and evaluate expressions."""
@@ -151,7 +162,7 @@
 
         # This should display the str and date member fields as well.
         self.expect("frame variable -t *self", VARIABLES_DISPLAYED_CORRECTLY,
-            substrs = ["(MyString) *self",
+            substrs = ["(MyString *) self",
                        "(NSString *) str",
                        "(NSDate *) date"])
 
@@ -189,7 +200,54 @@
         self.expect("expression -o -- my", "Object description displayed correctly",
             patterns = ["Hello from.*a.out.*with timestamp: "])
 
+    @unittest2.expectedFailure
+    # See: <rdar://problem/8717050> lldb needs to use the ObjC runtime symbols for ivar offsets
+    # Only fails for the ObjC 2.0 runtime.
+    def print_ivars_correctly(self) :
+        exe = os.path.join(os.getcwd(), "a.out")
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target.IsValid(), VALID_TARGET)
+
+        break1 = target.BreakpointCreateByLocation(self.main_source, self.line)
+        self.assertTrue(break1.IsValid(), VALID_BREAKPOINT)
+
+        # Now launch the process, and do not stop at entry point.
+        self.process = target.LaunchProcess([], [], os.ctermid(), 0, False)
+
+        self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+
+        # The stop reason of the thread should be breakpoint.
+        thread = self.process.GetThreadAtIndex(0)
+        if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
+            from lldbutil import StopReasonString
+            self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %
+                      StopReasonString(thread.GetStopReason()))
+
+        # Make sure we stopped at the first breakpoint.
+
+        cur_frame = thread.GetFrameAtIndex(0)
+
+        line_number = cur_frame.GetLineEntry().GetLine()
+        self.assertTrue (line_number == self.line, "Hit the first breakpoint.")
+
+        my_var = cur_frame.FindVariable("my")
+        self.assertTrue(my_var.IsValid(), "Made a variable object for my")
+
+        str_var = cur_frame.FindVariable("str")
+        self.assertTrue(str_var.IsValid(), "Made a variable object for str")
+
+        # Now make sure that the my->str == str:
+
+        my_str_var = my_var.GetChildMemberWithName("str")
+        self.assertTrue(my_str_var.IsValid(), "Found a str ivar in my")
+
+        str_value = int(str_var.GetValue(cur_frame), 0)
+
+        my_str_value = int(my_str_var.GetValue(cur_frame), 0)
 
+        self.assertTrue(str_value == my_str_value, "Got the correct value for my->str")
+        
 if __name__ == '__main__':
     import atexit
     lldb.SBDebugger.Initialize()

Modified: lldb/trunk/test/foundation/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=121894&r1=121893&r2=121894&view=diff
==============================================================================
--- lldb/trunk/test/foundation/main.m (original)
+++ lldb/trunk/test/foundation/main.m Wed Dec 15 14:47:34 2010
@@ -1,12 +1,14 @@
 #import <Foundation/Foundation.h>
 #include <unistd.h>
+#import "my-base.h"
 
- at interface MyString : NSObject {
+ at interface MyString : MyBase {
     NSString *str;
     NSDate *date;
     BOOL _desc_pauses;
 }
 
+ at property(retain) NSString * str_property;
 @property BOOL descriptionPauses;
 
 - (id)initWithNSString:(NSString *)string;
@@ -14,6 +16,7 @@
 
 @implementation MyString
 @synthesize descriptionPauses = _desc_pauses;
+ at synthesize str_property = str;
 
 - (id)initWithNSString:(NSString *)string
 {
@@ -88,8 +91,7 @@
     NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program];
     MyString *my = [[MyString alloc] initWithNSString:str];
     NSLog(@"MyString instance: %@", [my description]);
-    // Set break point at this line.  Test 'expression -o -- my'.
-    my.descriptionPauses = YES;
+    my.descriptionPauses = YES;     // Set break point at this line.  Test 'expression -o -- my'.
     NSLog(@"MyString instance: %@", [my description]);
 }
 

Added: lldb/trunk/test/foundation/my-base.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/my-base.h?rev=121894&view=auto
==============================================================================
--- lldb/trunk/test/foundation/my-base.h (added)
+++ lldb/trunk/test/foundation/my-base.h Wed Dec 15 14:47:34 2010
@@ -0,0 +1,8 @@
+ at interface MyBase : NSObject 
+{
+#if !__OBJC2__
+  int maybe_used; // The 1.0 runtime needs to have backed properties...
+#endif
+}
+ at property int propertyMovesThings;
+ at end

Added: lldb/trunk/test/foundation/my-base.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/my-base.m?rev=121894&view=auto
==============================================================================
--- lldb/trunk/test/foundation/my-base.m (added)
+++ lldb/trunk/test/foundation/my-base.m Wed Dec 15 14:47:34 2010
@@ -0,0 +1,10 @@
+#import <Foundation/Foundation.h>
+#import "my-base.h"
+ at implementation MyBase
+#if __OBJC2__
+ at synthesize propertyMovesThings;
+#else
+ at synthesize propertyMovesThings = maybe_used;
+#endif
+ at end
+





More information about the lldb-commits mailing list