aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/objc/self
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/objc/self')
-rw-r--r--packages/Python/lldbsuite/test/lang/objc/self/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py36
-rw-r--r--packages/Python/lldbsuite/test/lang/objc/self/main.m54
3 files changed, 96 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/objc/self/Makefile b/packages/Python/lldbsuite/test/lang/objc/self/Makefile
new file mode 100644
index 000000000000..bdae30428be4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/self/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+LD_EXTRAS ?= -framework Foundation
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py b/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py
new file mode 100644
index 000000000000..37db151f9ae3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py
@@ -0,0 +1,36 @@
+"""
+Tests that ObjC member variables are available where they should be.
+"""
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class ObjCSelfTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_with_run_command(self):
+ """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ self.set_breakpoint(line_number('main.m', '// breakpoint 1'))
+ self.set_breakpoint(line_number('main.m', '// breakpoint 2'))
+
+ self.runCmd("process launch", RUN_SUCCEEDED)
+
+ self.expect("expression -- m_a = 2",
+ startstr = "(int) $0 = 2")
+
+ self.runCmd("process continue")
+
+ # This would be disallowed if we enforced const. But we don't.
+ self.expect("expression -- m_a = 2",
+ error=True)
+
+ self.expect("expression -- s_a",
+ startstr = "(int) $1 = 5")
+
+ def set_breakpoint(self, line):
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True)
diff --git a/packages/Python/lldbsuite/test/lang/objc/self/main.m b/packages/Python/lldbsuite/test/lang/objc/self/main.m
new file mode 100644
index 000000000000..928aaf2ff024
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/self/main.m
@@ -0,0 +1,54 @@
+//===-- main.m ------------------------------------------*- Objective-C -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+@interface A : NSObject
+{
+ int m_a;
+}
+-(id)init;
+-(void)accessMember:(int)a;
++(void)accessStaticMember:(int)a;
+@end
+
+static int s_a = 5;
+
+@implementation A
+-(id)init
+{
+ self = [super init];
+
+ if (self)
+ m_a = 2;
+
+ return self;
+}
+
+-(void)accessMember:(int)a
+{
+ m_a = a; // breakpoint 1
+}
+
++(void)accessStaticMember:(int)a
+{
+ s_a = a; // breakpoint 2
+}
+@end
+
+int main()
+{
+ NSAutoreleasePool *pool = [NSAutoreleasePool alloc];
+ A *my_a = [[A alloc] init];
+
+ [my_a accessMember:3];
+ [A accessStaticMember:5];
+
+ [pool release];
+}