summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla
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/c/vla
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/c/vla')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py45
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/main.c15
3 files changed, 63 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py
new file mode 100644
index 00000000000..09439e2bc4b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py
@@ -0,0 +1,45 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestVLA(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIf(compiler="clang", compiler_version=['<', '8.0'])
+ def test_variable_list(self):
+ self.build()
+ _, process, _, _ = lldbutil.run_to_source_breakpoint(
+ self, "break here", lldb.SBFileSpec('main.c'))
+
+ # Make sure no helper expressions show up in frame variable.
+ var_opts = lldb.SBVariablesOptions()
+ var_opts.SetIncludeArguments(False)
+ var_opts.SetIncludeLocals(True)
+ var_opts.SetInScopeOnly(True)
+ var_opts.SetIncludeStatics(False)
+ var_opts.SetIncludeRuntimeSupportValues(False)
+ var_opts.SetUseDynamic(lldb.eDynamicCanRunTarget)
+ all_locals = self.frame().GetVariables(var_opts)
+ for value in all_locals:
+ self.assertFalse("vla_expr" in value.name)
+
+ @decorators.skipIf(compiler="clang", compiler_version=['<', '8.0'])
+ def test_vla(self):
+ self.build()
+ _, process, _, _ = lldbutil.run_to_source_breakpoint(
+ self, "break here", lldb.SBFileSpec('main.c'))
+
+ def test(a, array):
+ for i in range(a):
+ self.expect("fr v vla[%d]"%i, substrs=["int", "%d"%(a-i)])
+ self.expect("expr vla[%d]"%i, substrs=["int", "%d"%(a-i)])
+ self.expect("fr v vla", substrs=array)
+ self.expect("expr vla", error=True, substrs=["incomplete"])
+
+ test(2, ["int []", "[0] = 2, [1] = 1"])
+ process.Continue()
+ test(4, ["int []", "[0] = 4, [1] = 3, [2] = 2, [3] = 1"])
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/main.c
new file mode 100644
index 00000000000..ba9cc185560
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/vla/main.c
@@ -0,0 +1,15 @@
+void pause() {}
+
+int foo(int a) {
+ int vla[a];
+
+ for (int i = 0; i < a; ++i)
+ vla[i] = a-i;
+
+ pause(); // break here
+ return vla[a-1];
+}
+
+int main (void) {
+ return foo(2) + foo(4);
+}