summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
committerZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
commitc432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch)
tree4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets
parenta8a3bd210086b50242903ed95048fe5e53897878 (diff)
downloadbcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz
bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code structured into a bona-fide Python package. This has a number of benefits, but most notably the ability to more easily share Python code between different but related pieces of LLDB's Python infrastructure (for example, `scripts` can now share code with `test`). llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile6
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py74
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m15
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h27
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m19
5 files changed, 141 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile
new file mode 100644
index 00000000000..fdd3b5ebfa9
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := objc-ivar-offsets.m main.m
+LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
new file mode 100644
index 00000000000..edbce826886
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
@@ -0,0 +1,74 @@
+"""Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
+
+from __future__ import print_function
+
+import use_lldb_suite
+
+import os, time
+import lldb
+from lldbtest import *
+import lldbutil
+
+class TestObjCIvarOffsets(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.main_source = "main.m"
+ self.stop_line = line_number(self.main_source, '// Set breakpoint here.')
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test printing ObjC objects that use unbacked properties"""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByLocation(self.main_source, self.stop_line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ self.assertTrue (process, "Created a process.")
+ self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.")
+
+ thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
+ self.assertTrue (len(thread_list) == 1)
+ thread = thread_list[0]
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue (frame, "frame 0 is valid")
+
+ mine = thread.GetFrameAtIndex(0).FindVariable("mine")
+ self.assertTrue(mine, "Found local variable mine.")
+
+ # Test the value object value for BaseClass->_backed_int
+
+ error = lldb.SBError()
+
+ mine_backed_int = mine.GetChildMemberWithName ("_backed_int")
+ self.assertTrue(mine_backed_int, "Found mine->backed_int local variable.")
+ backed_value = mine_backed_int.GetValueAsSigned (error)
+ self.assertTrue (error.Success())
+ self.assertTrue (backed_value == 1111)
+
+ # Test the value object value for DerivedClass->_derived_backed_int
+
+ mine_derived_backed_int = mine.GetChildMemberWithName ("_derived_backed_int")
+ self.assertTrue(mine_derived_backed_int, "Found mine->derived_backed_int local variable.")
+ derived_backed_value = mine_derived_backed_int.GetValueAsSigned (error)
+ self.assertTrue (error.Success())
+ self.assertTrue (derived_backed_value == 3333)
+
+ # Make sure we also get bit-field offsets correct:
+
+ mine_flag2 = mine.GetChildMemberWithName ("flag2")
+ self.assertTrue(mine_flag2, "Found mine->flag2 local variable.")
+ flag2_value = mine_flag2.GetValueAsUnsigned (error)
+ self.assertTrue (error.Success())
+ self.assertTrue (flag2_value == 7)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m
new file mode 100644
index 00000000000..41943f48aef
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/main.m
@@ -0,0 +1,15 @@
+#include "objc-ivar-offsets.h"
+
+int
+main ()
+{
+ DerivedClass *mine = [[DerivedClass alloc] init];
+ mine.backed_int = 1111;
+ mine.unbacked_int = 2222;
+ mine.derived_backed_int = 3333;
+ mine.derived_unbacked_int = 4444;
+ mine->flag1 = 1;
+ mine->flag2 = 7;
+
+ return 0; // Set breakpoint here.
+}
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h
new file mode 100644
index 00000000000..99bbd427b06
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h
@@ -0,0 +1,27 @@
+#import <Foundation/Foundation.h>
+
+@interface BaseClass : NSObject
+{
+ int _backed_int;
+#if !__OBJC2__
+ int _unbacked_int;
+#endif
+}
+@property int backed_int;
+@property int unbacked_int;
+@end
+
+@interface DerivedClass : BaseClass
+{
+ int _derived_backed_int;
+#if !__OBJC2__
+ int _derived_unbacked_int;
+#endif
+ @public
+ uint32_t flag1 : 1;
+ uint32_t flag2 : 3;
+}
+
+@property int derived_backed_int;
+@property int derived_unbacked_int;
+@end
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m
new file mode 100644
index 00000000000..db87adea3d1
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.m
@@ -0,0 +1,19 @@
+#import "objc-ivar-offsets.h"
+
+@implementation BaseClass
+@synthesize backed_int = _backed_int;
+#if __OBJC2__
+@synthesize unbacked_int;
+#else
+@synthesize unbacked_int = _unbacked_int;
+#endif
+@end
+
+@implementation DerivedClass
+@synthesize derived_backed_int = _derived_backed_int;
+#if __OBJC2__
+@synthesize derived_unbacked_int;
+#else
+@synthesize derived_unbacked_int = _derived_unbacked_int;
+#endif
+@end
OpenPOWER on IntegriCloud