[Lldb-commits] [lldb] r164321 - in /lldb/trunk/test/lang/objc/hidden-ivars: InternalDefiner.h InternalDefiner.m Makefile TestHiddenIvars.py main.m

Greg Clayton gclayton at apple.com
Thu Sep 20 14:38:45 PDT 2012


Author: gclayton
Date: Thu Sep 20 16:38:45 2012
New Revision: 164321

URL: http://llvm.org/viewvc/llvm-project?rev=164321&view=rev
Log:
<rdar://problem/12315386>

Test suite to catch fragile base class ivar issues.


Modified:
    lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.h
    lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.m
    lldb/trunk/test/lang/objc/hidden-ivars/Makefile
    lldb/trunk/test/lang/objc/hidden-ivars/TestHiddenIvars.py
    lldb/trunk/test/lang/objc/hidden-ivars/main.m

Modified: lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.h?rev=164321&r1=164320&r2=164321&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.h (original)
+++ lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.h Thu Sep 20 16:38:45 2012
@@ -1,10 +1,11 @@
 #import <Foundation/Foundation.h>
+#import <stdint.h>
 
 @interface InternalDefiner : NSObject {
 @public
-    int foo;
+    uintptr_t foo;
 }
 
--(int)setBarTo:(int)newBar;
+-(id)initWithFoo:(uintptr_t)f andBar:(uintptr_t)b;
 
 @end

Modified: lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.m?rev=164321&r1=164320&r2=164321&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.m (original)
+++ lldb/trunk/test/lang/objc/hidden-ivars/InternalDefiner.m Thu Sep 20 16:38:45 2012
@@ -1,18 +1,31 @@
 #import "InternalDefiner.h"
 
 @interface InternalDefiner () {
-    int bar;
+    uintptr_t bar;
 }
 
 @end
 
 @implementation InternalDefiner
 
--(int)setBarTo:(int)newBar
+-(id)init
 {
-    int oldBar = bar;
-    bar = newBar;
-    return oldBar;
+    if (self = [super init])
+    {
+        foo = 2;
+        bar = 3;
+    }
+    return self;
+}
+
+-(id)initWithFoo:(uintptr_t)f andBar:(uintptr_t)b
+{
+    if (self = [super init])
+    {
+        foo = f;
+        bar = b;
+    }
+    return self;
 }
 
 @end

Modified: lldb/trunk/test/lang/objc/hidden-ivars/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/hidden-ivars/Makefile?rev=164321&r1=164320&r2=164321&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/hidden-ivars/Makefile (original)
+++ lldb/trunk/test/lang/objc/hidden-ivars/Makefile Thu Sep 20 16:38:45 2012
@@ -1,6 +1,6 @@
 LEVEL = ../../../make
 
-DYLIB_NAME := libInternalDefiner
+DYLIB_NAME := InternalDefiner
 DYLIB_OBJC_SOURCES := InternalDefiner.m
 OBJC_SOURCES := main.m
 

Modified: lldb/trunk/test/lang/objc/hidden-ivars/TestHiddenIvars.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/hidden-ivars/TestHiddenIvars.py?rev=164321&r1=164320&r2=164321&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/hidden-ivars/TestHiddenIvars.py (original)
+++ lldb/trunk/test/lang/objc/hidden-ivars/TestHiddenIvars.py Thu Sep 20 16:38:45 2012
@@ -70,21 +70,45 @@
         self.common_setup()
 
         # This should display correctly.
+        self.expect("expression (j->_definer->foo)", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["= 4"])
+
         self.expect("expression (j->_definer->bar)", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["= 5"])
             
         self.expect("expression *(j->_definer)", VARIABLES_DISPLAYED_CORRECTLY,
-            substrs = ["foo = 0", "bar = 5"])
+            substrs = ["foo = 4", "bar = 5"])
+
+        self.expect("expression (k->foo)", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["= 2"])
+
+        self.expect("expression (k->bar)", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["= 3"])
+
+        self.expect("expression *(k)", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["foo = 2", "bar = 3"])
 
     def frame_var(self):
         self.common_setup()
 
         # This should display correctly.
+        self.expect("frame variable j->_definer->foo", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["= 4"])
+
         self.expect("frame variable j->_definer->bar", VARIABLES_DISPLAYED_CORRECTLY,
             substrs = ["= 5"])
             
         self.expect("frame variable *j->_definer", VARIABLES_DISPLAYED_CORRECTLY,
-            substrs = ["foo = 0", "bar = 5"])
+            substrs = ["foo = 4", "bar = 5"])
+
+        self.expect("frame variable k->foo", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["= 2"])
+
+        self.expect("frame variable k->bar", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["= 3"])
+
+        self.expect("frame variable *k", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["foo = 2", "bar = 3"])
                        
 if __name__ == '__main__':
     import atexit

Modified: lldb/trunk/test/lang/objc/hidden-ivars/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/hidden-ivars/main.m?rev=164321&r1=164320&r2=164321&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/hidden-ivars/main.m (original)
+++ lldb/trunk/test/lang/objc/hidden-ivars/main.m Thu Sep 20 16:38:45 2012
@@ -13,8 +13,29 @@
 
 -(id)init
 {
-    _definer = [InternalDefiner alloc];
-    [_definer setBarTo:5];
+    if (self = [super init])
+    {
+        _definer = [[InternalDefiner alloc] initWithFoo:4 andBar:5];
+    }
+    return self;
+}
+
+ at end
+
+ at interface InheritContainer : InternalDefiner 
+{
+}
+
+-(id)init;
+ at end
+
+ at implementation InheritContainer
+
+-(id)init
+{
+    if (self = [super initWithFoo:2 andBar:3])
+    {
+    }
     return self;
 }
 
@@ -25,8 +46,10 @@
 
     @autoreleasepool {
         Container *j = [[Container alloc] init];
+        InheritContainer *k = [[InheritContainer alloc] init];
 
-        printf("ivar value = %d", j->_definer->foo); // Set breakpoint 0 here.
+        printf("ivar value = %u\n", (unsigned)j->_definer->foo); // Set breakpoint 0 here.
+        printf("ivar value = %u\n", (unsigned)k->foo);           // Set breakpoint 1 here.
     }   
     return 0;
 }





More information about the lldb-commits mailing list