summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
commit061da546b983eb767bad15e67af1174fb0bcf31c (patch)
tree83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self
parentImport LLVM 10.0.0 release including clang, lld and lldb. (diff)
downloadwireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz
wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py39
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m53
3 files changed, 96 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile
new file mode 100644
index 00000000000..644046c69ea
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS ?= -framework Foundation
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py
new file mode 100644
index 00000000000..81d6b79ad53
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py
@@ -0,0 +1,39 @@
+"""
+Tests that ObjC member variables are available where they should be.
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import 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 " + self.getBuildArtifact("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/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m
new file mode 100644
index 00000000000..8f4e61202a3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/objc/self/main.m
@@ -0,0 +1,53 @@
+//===-- main.m ------------------------------------------*- Objective-C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#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];
+}