summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files
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/commands/expression/two-files
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/commands/expression/two-files')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/TestObjCTypeQueryFromOtherCompileUnit.py40
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/foo.m28
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/main.m22
4 files changed, 96 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/Makefile
new file mode 100644
index 00000000000..c82383d9400
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/Makefile
@@ -0,0 +1,6 @@
+OBJC_SOURCES := main.m foo.m
+
+
+
+LD_EXTRAS := -framework Foundation
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/TestObjCTypeQueryFromOtherCompileUnit.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/TestObjCTypeQueryFromOtherCompileUnit.py
new file mode 100644
index 00000000000..c518bf0559f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/TestObjCTypeQueryFromOtherCompileUnit.py
@@ -0,0 +1,40 @@
+"""
+Regression test for <rdar://problem/8981098>:
+
+The expression parser's type search only looks in the current compilation unit for types.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ObjCTypeQueryTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break for main.m.
+ self.line = line_number(
+ 'main.m', "// Set breakpoint here, then do 'expr (NSArray*)array_token'.")
+
+ @skipUnlessDarwin
+ def test(self):
+ """The expression parser's type search should be wider than the current compilation unit."""
+ self.build()
+ self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # Now do a NSArry type query from the 'main.m' compile uint.
+ self.expect("expression (NSArray*)array_token",
+ substrs=['(NSArray *) $0 = 0x'])
+ # (NSArray *) $0 = 0x00007fff70118398
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/foo.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/foo.m
new file mode 100644
index 00000000000..1609ebd838f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/foo.m
@@ -0,0 +1,28 @@
+#import <Foundation/Foundation.h>
+
+NSMutableArray *
+GetArray ()
+{
+ static NSMutableArray *the_array = NULL;
+ if (the_array == NULL)
+ the_array = [[NSMutableArray alloc] init];
+ return the_array;
+}
+
+int
+AddElement (char *value)
+{
+ NSString *element = [NSString stringWithUTF8String: value];
+ int cur_elem = [GetArray() count];
+ [GetArray() addObject: element];
+ return cur_elem;
+}
+
+const char *
+GetElement (int idx)
+{
+ if (idx >= [GetArray() count])
+ return NULL;
+ else
+ return [[GetArray() objectAtIndex: idx] UTF8String];
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/main.m b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/main.m
new file mode 100644
index 00000000000..3f5738314e6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/expression/two-files/main.m
@@ -0,0 +1,22 @@
+#import <Foundation/Foundation.h>
+#include <stdio.h>
+
+extern int AddElement (char *value);
+extern char *GetElement (int idx);
+extern void *GetArray();
+
+int
+main ()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ int idx = AddElement ("some string");
+ void *array_token = GetArray();
+
+ char *string = GetElement (0); // Set breakpoint here, then do 'expr (NSArray*)array_token'.
+ if (string)
+ printf ("This: %s.\n", string);
+
+ [pool release];
+ return 0;
+}