summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c
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
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')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py170
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/main.c82
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py228
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/cmds.txt3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/main.c50
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py220
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/main.c103
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py81
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/main.c21
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile14
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.c6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/OneConstant.c1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py122
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.c6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/TwoConstant.c1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/main.c11
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py68
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/functions.c18
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/main.c23
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py126
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c58
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile2
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py59
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c25
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/README.txt5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py65
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.c8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.h4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/main.c18
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py83
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/main.c21
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py123
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/a.c14
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/cmds.txt3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c24
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py9
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c25
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py48
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/main.c16
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/other.c11
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/TestLocalVariables.py55
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/main.c19
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py91
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c20
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c12
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/main.c28
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py204
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/test.c44
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py139
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/main.c115
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py101
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.c22
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.h10
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/main.c13
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py88
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.c22
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.h12
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/main.c13
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories1
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py122
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/main.c40
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/TestStepOverDoesntBlock.py30
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/locking.cpp78
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py296
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py83
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/main.c68
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py56
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/main.c17
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/main.c46
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile8
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py95
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c23
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c41
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py52
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/main.c45
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/Makefile4
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py21
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/main.c5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py52
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/main.c18
-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
111 files changed, 4363 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
new file mode 100644
index 00000000000..69e23e3510b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
@@ -0,0 +1,170 @@
+"""Test that anonymous structs/unions are transparent to member access"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class AnonymousTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIf(
+ compiler="icc",
+ bugnumber="llvm.org/pr15036: LLDB generates an incorrect AST layout for an anonymous struct when DWARF is generated by ICC")
+ def test_expr_nest(self):
+ self.build()
+ self.common_setup(self.line0)
+
+ # These should display correctly.
+ self.expect("expression n->foo.d", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 4"])
+
+ self.expect("expression n->b", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 2"])
+
+ def test_expr_child(self):
+ self.build()
+ self.common_setup(self.line1)
+
+ # These should display correctly.
+ self.expect("expression c->foo.d", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 4"])
+
+ self.expect(
+ "expression c->grandchild.b",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 2"])
+
+ @skipIf(
+ compiler="icc",
+ bugnumber="llvm.org/pr15036: This particular regression was introduced by r181498")
+ def test_expr_grandchild(self):
+ self.build()
+ self.common_setup(self.line2)
+
+ # These should display correctly.
+ self.expect("expression g.child.foo.d", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 4"])
+
+ self.expect("expression g.child.b", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 2"])
+
+ def test_expr_parent(self):
+ self.build()
+ if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
+ self.skipTest(
+ "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
+ self.common_setup(self.line2)
+
+ # These should display correctly.
+ self.expect("expression pz", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["(type_z *) $", " = 0x0000"])
+
+ self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["(type_y) $", "dummy = 2"])
+
+ def test_expr_null(self):
+ self.build()
+ self.common_setup(self.line2)
+
+ # This should fail because pz is 0, but it succeeds on OS/X.
+ # This fails on Linux with an upstream error "Couldn't dematerialize struct", as does "p *n" with "int *n = 0".
+ # Note that this can also trigger llvm.org/pr15036 when run
+ # interactively at the lldb command prompt.
+ self.expect("expression *(type_z *)pz", error=True)
+
+ def test_child_by_name(self):
+ self.build()
+
+ # Set debugger into synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target
+ exe = self.getBuildArtifact("a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ break_in_main = target.BreakpointCreateBySourceRegex(
+ '// Set breakpoint 2 here.', lldb.SBFileSpec(self.source))
+ self.assertTrue(break_in_main, VALID_BREAKPOINT)
+
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, break_in_main)
+ if len(threads) != 1:
+ self.fail("Failed to stop at breakpoint in main.")
+
+ thread = threads[0]
+ frame = thread.frames[0]
+
+ if not frame.IsValid():
+ self.fail("Failed to get frame 0.")
+
+ var_n = frame.FindVariable("n")
+ if not var_n.IsValid():
+ self.fail("Failed to get the variable 'n'")
+
+ elem_a = var_n.GetChildMemberWithName("a")
+ if not elem_a.IsValid():
+ self.fail("Failed to get the element a in n")
+
+ error = lldb.SBError()
+ value = elem_a.GetValueAsSigned(error, 1000)
+ if not error.Success() or value != 0:
+ self.fail("failed to get the correct value for element a in n")
+
+ def test_nest_flat(self):
+ self.build()
+ self.common_setup(self.line2)
+
+ # These should display correctly.
+ self.expect('frame variable n --flat',
+ substrs=['n.a = 0',
+ 'n.b = 2',
+ 'n.foo.c = 0',
+ 'n.foo.d = 4'])
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break in main.c.
+ self.source = 'main.c'
+ self.line0 = line_number(self.source, '// Set breakpoint 0 here.')
+ self.line1 = line_number(self.source, '// Set breakpoint 1 here.')
+ self.line2 = line_number(self.source, '// Set breakpoint 2 here.')
+
+ def common_setup(self, line):
+
+ # Set debugger into synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target
+ exe = self.getBuildArtifact("a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set breakpoints inside and outside methods that take pointers to the
+ # containing struct.
+ lldbutil.run_break_set_by_file_and_line(
+ self, self.source, line, num_expected_locations=1, loc_exact=True)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/main.c
new file mode 100644
index 00000000000..58ac85b7d43
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/anonymous/main.c
@@ -0,0 +1,82 @@
+#include <stdio.h>
+
+struct anonymous_nest {
+ struct {
+ struct {
+ int a;
+ int b;
+ }; // anonymous
+ struct {
+ int c;
+ int d;
+ } foo;
+ }; // anonymous
+};
+
+struct anonymous_child {
+ struct {
+ struct {
+ int a;
+ int b;
+ } grandchild;
+ struct {
+ int c;
+ int d;
+ } foo;
+ }; // anonymous
+};
+
+struct anonymous_grandchild {
+ struct {
+ struct {
+ int a;
+ int b;
+ }; // anonymous
+ struct {
+ int c;
+ int d;
+ } foo;
+ } child;
+};
+
+int processor_nest (struct anonymous_nest *n)
+{
+ return n->foo.d + n->b; // Set breakpoint 0 here.
+}
+
+int processor_child (struct anonymous_child *c)
+{
+ return c->foo.d + c->grandchild.b; // Set breakpoint 1 here.
+}
+
+int processor_grandchild (struct anonymous_grandchild *g)
+{
+ return g->child.foo.d + g->child.b;
+}
+
+
+
+typedef struct {
+ int dummy;
+} type_y;
+
+typedef struct {
+ type_y y;
+} type_z;
+
+
+
+int main()
+{
+ struct anonymous_nest n = { 0, 2, 0, 4 };
+ struct anonymous_child c = { 0, 2, 0, 4 };
+ struct anonymous_grandchild g = { 0, 2, 0, 4 };
+ type_z *pz = 0;
+ type_z z = {{2}};
+
+ printf("%d\n", processor_nest(&n));
+ printf("%d\n", processor_child(&c));
+ printf("%d\n", processor_grandchild(&g)); // Set breakpoint 2 here.
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py
new file mode 100644
index 00000000000..cc9ae8edb6e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py
@@ -0,0 +1,228 @@
+"""Test breakpoint by file/line number; and list variables with array types."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ArrayTypesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.c', '// Set break point at this line.')
+
+ def test_and_run_command(self):
+ """Test 'frame variable var_name' on some variables with array types."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line, num_expected_locations=1, loc_exact=False)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The test suite sometimes shows that the process has exited without stopping.
+ #
+ # CC=clang ./dotest.py -v -t array_types
+ # ...
+ # Process 76604 exited with status = 0 (0x00000000)
+ self.runCmd("process status")
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=['resolved, hit count = 1'])
+
+ # Issue 'variable list' command on several array-type variables.
+
+ self.expect(
+ "frame variable --show-types strings",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr='(char *[4])',
+ substrs=[
+ '(char *) [0]',
+ '(char *) [1]',
+ '(char *) [2]',
+ '(char *) [3]',
+ 'Hello',
+ 'Hola',
+ 'Bonjour',
+ 'Guten Tag'])
+
+ self.expect(
+ "frame variable --show-types --raw -- char_16",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ '(char) [0]',
+ '(char) [15]'])
+
+ self.expect(
+ "frame variable --show-types ushort_matrix",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr='(unsigned short [2][3])')
+
+ self.expect(
+ "frame variable --show-types long_6",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr='(long [6])')
+
+ @expectedFailureNetBSD
+ @add_test_categories(['pyapi'])
+ def test_and_python_api(self):
+ """Use Python APIs to inspect variables with array types."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ # Sanity check the print representation of breakpoint.
+ bp = str(breakpoint)
+ self.expect(bp, msg="Breakpoint looks good", exe=False,
+ substrs=["file = 'main.c'",
+ "line = %d" % self.line,
+ "locations = 1"])
+ self.expect(
+ bp,
+ msg="Breakpoint is not resolved as yet",
+ exe=False,
+ matching=False,
+ substrs=["resolved = 1"])
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Sanity check the print representation of process.
+ proc = str(process)
+ self.expect(proc, msg="Process looks good", exe=False,
+ substrs=["state = stopped",
+ "executable = a.out"])
+
+ # The stop reason of the thread should be breakpoint.
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertIsNotNone(thread)
+
+ # Sanity check the print representation of thread.
+ thr = str(thread)
+ # TODO(zturner): Whether the TID is printed in hex or decimal should be controlled by a setting,
+ # and this test should read the value of the setting. This check is currently hardcoded to
+ # match the check in Core/FormatEntity.cpp in the function FormatEntity::Format() for
+ # the Entry::Type::ThreadID case of the switch statement.
+ if self.getPlatform() == "linux" or self.getPlatform() == "freebsd":
+ tidstr = "tid = %u" % thread.GetThreadID()
+ else:
+ tidstr = "tid = 0x%4.4x" % thread.GetThreadID()
+ self.expect(
+ thr,
+ "Thread looks good with stop reason = breakpoint",
+ exe=False,
+ substrs=[tidstr])
+
+ # The breakpoint should have a hit count of 1.
+ self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
+
+ # The breakpoint should be resolved by now.
+ bp = str(breakpoint)
+ self.expect(bp, "Breakpoint looks good and is resolved", exe=False,
+ substrs=["file = 'main.c'",
+ "line = %d" % self.line,
+ "locations = 1"])
+
+ # Sanity check the print representation of frame.
+ frame = thread.GetFrameAtIndex(0)
+ frm = str(frame)
+ self.expect(
+ frm,
+ "Frame looks good with correct index %d" %
+ frame.GetFrameID(),
+ exe=False,
+ substrs=[
+ "#%d" %
+ frame.GetFrameID()])
+
+ # Lookup the "strings" string array variable and sanity check its print
+ # representation.
+ variable = frame.FindVariable("strings")
+ var = str(variable)
+ self.expect(
+ var,
+ "Variable for 'strings' looks good with correct name",
+ exe=False,
+ substrs=[
+ "%s" %
+ variable.GetName()])
+ self.DebugSBValue(variable)
+ self.assertTrue(variable.GetNumChildren() == 4,
+ "Variable 'strings' should have 4 children")
+ byte_size = variable.GetByteSize()
+ self.assertTrue(byte_size >= 4*4 and byte_size <= 1024)
+
+ child3 = variable.GetChildAtIndex(3)
+ self.DebugSBValue(child3)
+ self.assertTrue(child3.GetSummary() == '"Guten Tag"',
+ 'strings[3] == "Guten Tag"')
+
+ # Lookup the "char_16" char array variable.
+ variable = frame.FindVariable("char_16")
+ self.DebugSBValue(variable)
+ self.assertTrue(variable.GetNumChildren() == 16,
+ "Variable 'char_16' should have 16 children")
+
+ # Lookup the "ushort_matrix" ushort[] array variable.
+ # Notice the pattern of int(child0_2.GetValue(), 0). We pass a
+ # base of 0 so that the proper radix is determined based on the contents
+ # of the string. Same applies to long().
+ variable = frame.FindVariable("ushort_matrix")
+ self.DebugSBValue(variable)
+ self.assertTrue(variable.GetNumChildren() == 2,
+ "Variable 'ushort_matrix' should have 2 children")
+ child0 = variable.GetChildAtIndex(0)
+ self.DebugSBValue(child0)
+ self.assertTrue(child0.GetNumChildren() == 3,
+ "Variable 'ushort_matrix[0]' should have 3 children")
+ child0_2 = child0.GetChildAtIndex(2)
+ self.DebugSBValue(child0_2)
+ self.assertTrue(int(child0_2.GetValue(), 0) == 3,
+ "ushort_matrix[0][2] == 3")
+
+ # Lookup the "long_6" char array variable.
+ variable = frame.FindVariable("long_6")
+ self.DebugSBValue(variable)
+ self.assertTrue(variable.GetNumChildren() == 6,
+ "Variable 'long_6' should have 6 children")
+ child5 = variable.GetChildAtIndex(5)
+ self.DebugSBValue(child5)
+ self.assertTrue(int(child5.GetValue(), 0) == 6,
+ "long_6[5] == 6")
+
+ # Last, check that "long_6" has a value type of eValueTypeVariableLocal
+ # and "argc" has eValueTypeVariableArgument.
+ from lldbsuite.test.lldbutil import value_type_to_str
+ self.assertTrue(
+ variable.GetValueType() == lldb.eValueTypeVariableLocal,
+ "Variable 'long_6' should have '%s' value type." %
+ value_type_to_str(
+ lldb.eValueTypeVariableLocal))
+ argc = frame.FindVariable("argc")
+ self.DebugSBValue(argc)
+ self.assertTrue(argc.GetValueType() == lldb.eValueTypeVariableArgument,
+ "Variable 'argc' should have '%s' value type." %
+ value_type_to_str(lldb.eValueTypeVariableArgument))
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/cmds.txt b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/cmds.txt
new file mode 100644
index 00000000000..8feebe21204
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/cmds.txt
@@ -0,0 +1,3 @@
+break main.c:42
+continue
+var
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/main.c
new file mode 100644
index 00000000000..eda7dc3d6ac
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/array_types/main.c
@@ -0,0 +1,50 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+int main (int argc, char const *argv[])
+{
+ struct point_tag {
+ int x;
+ int y;
+ };
+
+ struct rect_tag {
+ struct point_tag bottom_left;
+ struct point_tag top_right;
+ };
+ char char_16[16] = "Hello World\n";
+ char *strings[] = { "Hello", "Hola", "Bonjour", "Guten Tag" };
+ char char_matrix[3][3] = {{'a', 'b', 'c' }, {'d', 'e', 'f' }, {'g', 'h', 'i' }};
+ char char_matrix_matrix[3][2][3] =
+ { {{'a', 'b', 'c' }, {'d', 'e', 'f' }},
+ {{'A', 'B', 'C' }, {'D', 'E', 'F' }},
+ {{'1', '2', '3' }, {'4', '5', '6' }}};
+ short short_4[4] = { 1,2,3,4 };
+ short short_matrix[1][2] = { {1,2} };
+ unsigned short ushort_4[4] = { 1,2,3,4 };
+ unsigned short ushort_matrix[2][3] = {
+ { 1, 2, 3},
+ {11,22,33}
+ };
+ int int_2[2] = { 1, 2 };
+ unsigned int uint_2[2] = { 1, 2 };
+ long long_6[6] = { 1, 2, 3, 4, 5, 6 };
+ unsigned long ulong_6[6] = { 1, 2, 3, 4, 5, 6 };
+ struct point_tag points_2[2] = {
+ {1,2},
+ {3,4}
+ };
+ struct point_tag points_2_4_matrix[2][4] = { // Set break point at this line.
+ {{ 1, 2}, { 3, 4}, { 5, 6}, { 7, 8}},
+ {{11,22}, {33,44}, {55,66}, {77,88}}
+ };
+ struct rect_tag rects_2[2] = {
+ {{1,2}, {3,4}},
+ {{5,6}, {7,8}}
+ };
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
new file mode 100644
index 00000000000..7b28a321ff6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
@@ -0,0 +1,220 @@
+"""Show bitfields and check that they display correctly."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class BitfieldsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.c', '// Set break point at this line.')
+
+ # BitFields exhibit crashes in record layout on Windows
+ # (http://llvm.org/pr21800)
+ @skipIfWindows
+ def test_and_run_command(self):
+ """Test 'frame variable ...' on a variable with bitfields."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the main.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # This should display correctly.
+ self.expect(
+ "frame variable --show-types bits",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ '(uint32_t:1) b1 = 1',
+ '(uint32_t:2) b2 = 3',
+ '(uint32_t:3) b3 = 7',
+ '(uint32_t) b4 = 15',
+ '(uint32_t:5) b5 = 31',
+ '(uint32_t:6) b6 = 63',
+ '(uint32_t:7) b7 = 127',
+ '(uint32_t:4) four = 15'])
+
+ # And so should this.
+ # rdar://problem/8348251
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ '(uint32_t:1) b1 = 1',
+ '(uint32_t:2) b2 = 3',
+ '(uint32_t:3) b3 = 7',
+ '(uint32_t) b4 = 15',
+ '(uint32_t:5) b5 = 31',
+ '(uint32_t:6) b6 = 63',
+ '(uint32_t:7) b7 = 127',
+ '(uint32_t:4) four = 15'])
+
+ self.expect("expr (bits.b1)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '1'])
+ self.expect("expr (bits.b2)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '3'])
+ self.expect("expr (bits.b3)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '7'])
+ self.expect("expr (bits.b4)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '15'])
+ self.expect("expr (bits.b5)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '31'])
+ self.expect("expr (bits.b6)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '63'])
+ self.expect("expr (bits.b7)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '127'])
+ self.expect("expr (bits.four)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '15'])
+
+ self.expect(
+ "frame variable --show-types more_bits",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ '(uint32_t:3) a = 3',
+ '(uint8_t:1) b = \'\\0\'',
+ '(uint8_t:1) c = \'\\x01\'',
+ '(uint8_t:1) d = \'\\0\''])
+
+ self.expect("expr (more_bits.a)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', '3'])
+ self.expect("expr (more_bits.b)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint8_t', '\\0'])
+ self.expect("expr (more_bits.c)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint8_t', '\\x01'])
+ self.expect("expr (more_bits.d)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint8_t', '\\0'])
+
+ self.expect("expr (packed.a)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['char', "'a'"])
+ self.expect("expr (packed.b)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', "10"])
+ self.expect("expr/x (packed.c)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint32_t', "7112233"])
+
+ for bit in range(1,18):
+ expected = "1" if bit in [1, 5, 7, 13] else "0"
+ self.expect("expr even_more_bits.b" + str(bit), VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint8_t', expected])
+
+ for bit in [3, 10, 14]:
+ self.expect("expr even_more_bits.b" + str(bit) + " = 1", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['uint8_t', "1"])
+
+ self.expect(
+ "frame variable --show-types even_more_bits",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ '(uint8_t:1) b1 = \'\\x01\'',
+ '(uint8_t:1) b2 = \'\\0\'',
+ '(uint8_t:1) b3 = \'\\x01\'',
+ '(uint8_t:1) b4 = \'\\0\'',
+ '(uint8_t:1) b5 = \'\\x01\'',
+ '(uint8_t:1) b6 = \'\\0\'',
+ '(uint8_t:1) b7 = \'\\x01\'',
+ '(uint8_t:1) b8 = \'\\0\'',
+ '(uint8_t:1) b9 = \'\\0\'',
+ '(uint8_t:1) b10 = \'\\x01\'',
+ '(uint8_t:1) b12 = \'\\0\'',
+ '(uint8_t:1) b13 = \'\\x01\'',
+ '(uint8_t:1) b14 = \'\\x01\'',
+ '(uint8_t:1) b15 = \'\\0\'',
+ '(uint8_t:1) b16 = \'\\0\'',
+ '(uint8_t:1) b17 = \'\\0\'',
+ ])
+
+ self.expect("v/x large_packed", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["a = 0x0000000cbbbbaaaa", "b = 0x0000000dffffeee"])
+
+
+ @add_test_categories(['pyapi'])
+ # BitFields exhibit crashes in record layout on Windows
+ # (http://llvm.org/pr21800)
+ @skipIfWindows
+ def test_and_python_api(self):
+ """Use Python APIs to inspect a bitfields variable."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertIsNotNone(thread)
+
+ # The breakpoint should have a hit count of 1.
+ self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
+
+ # Lookup the "bits" variable which contains 8 bitfields.
+ frame = thread.GetFrameAtIndex(0)
+ bits = frame.FindVariable("bits")
+ self.DebugSBValue(bits)
+ self.assertTrue(
+ bits.GetTypeName() == 'Bits',
+ "bits.GetTypeName() == 'Bits'")
+ self.assertTrue(
+ bits.GetNumChildren() == 10,
+ "bits.GetNumChildren() == 10")
+ test_compiler = self.getCompiler()
+ self.assertTrue(bits.GetByteSize() == 32, "bits.GetByteSize() == 32")
+
+ # Notice the pattern of int(b1.GetValue(), 0). We pass a base of 0
+ # so that the proper radix is determined based on the contents of the
+ # string.
+ b1 = bits.GetChildMemberWithName("b1")
+ self.DebugSBValue(b1)
+ self.assertTrue(b1.GetName() == "b1" and
+ b1.GetTypeName() == "uint32_t:1" and
+ b1.IsInScope() and
+ int(b1.GetValue(), 0) == 1,
+ 'bits.b1 has type uint32_t:1, is in scope, and == 1')
+
+ b7 = bits.GetChildMemberWithName("b7")
+ self.DebugSBValue(b7)
+ self.assertTrue(b7.GetName() == "b7" and
+ b7.GetTypeName() == "uint32_t:7" and
+ b7.IsInScope() and
+ int(b7.GetValue(), 0) == 127,
+ 'bits.b7 has type uint32_t:7, is in scope, and == 127')
+
+ four = bits.GetChildMemberWithName("four")
+ self.DebugSBValue(four)
+ self.assertTrue(four.GetName() == "four" and
+ four.GetTypeName() == "uint32_t:4" and
+ four.IsInScope() and
+ int(four.GetValue(), 0) == 15,
+ 'bits.four has type uint32_t:4, is in scope, and == 15')
+
+ # Now kill the process, and we are done.
+ rc = target.GetProcess().Kill()
+ self.assertTrue(rc.Success())
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
new file mode 100644
index 00000000000..be3a1af76ba
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
@@ -0,0 +1,103 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+int main (int argc, char const *argv[])
+{
+ struct Bits
+ {
+ uint32_t : 1, // Unnamed bitfield
+ b1 : 1,
+ b2 : 2,
+ : 2, // Unnamed bitfield
+ b3 : 3,
+ : 2, // Unnamed bitfield (this will get removed)
+ b4 __attribute__ ((aligned(16))),
+ b5 : 5,
+ b6 : 6,
+ b7 : 7,
+ four : 4;
+ };
+
+ printf("%lu", sizeof(struct Bits));
+
+ struct Bits bits;
+ int i;
+ for (i=0; i<(1<<1); i++)
+ bits.b1 = i; //// break $source:$line
+ for (i=0; i<(1<<2); i++)
+ bits.b2 = i; //// break $source:$line
+ for (i=0; i<(1<<3); i++)
+ bits.b3 = i; //// break $source:$line
+ for (i=0; i<(1<<4); i++)
+ bits.b4 = i; //// break $source:$line
+ for (i=0; i<(1<<5); i++)
+ bits.b5 = i; //// break $source:$line
+ for (i=0; i<(1<<6); i++)
+ bits.b6 = i; //// break $source:$line
+ for (i=0; i<(1<<7); i++)
+ bits.b7 = i; //// break $source:$line
+ for (i=0; i<(1<<4); i++)
+ bits.four = i; //// break $source:$line
+
+ struct MoreBits
+ {
+ uint32_t a : 3;
+ uint8_t : 1;
+ uint8_t b : 1;
+ uint8_t c : 1;
+ uint8_t d : 1;
+ };
+
+ struct MoreBits more_bits;
+
+ more_bits.a = 3;
+ more_bits.b = 0;
+ more_bits.c = 1;
+ more_bits.d = 0;
+
+ struct EvenMoreBits
+ {
+ uint8_t b1 : 1, b2 : 1, b3 : 1, b4 : 1, b5 : 1, b6 : 1,
+ b7 : 1, b8 : 1, b9 : 1, b10 : 1, b11 : 1, b12 : 1,
+ b13 : 1, b14 : 1, b15 : 1, b16 : 1, b17 : 1;
+ };
+
+ struct EvenMoreBits even_more_bits;
+ memset(&even_more_bits, 0, sizeof(even_more_bits));
+ even_more_bits.b1 = 1;
+ even_more_bits.b5 = 1;
+ even_more_bits.b7 = 1;
+ even_more_bits.b13 = 1;
+
+#pragma pack(1)
+ struct PackedBits
+ {
+ char a;
+ uint32_t b : 5,
+ c : 27;
+ };
+#pragma pack()
+ struct PackedBits packed;
+ packed.a = 'a';
+ packed.b = 10;
+ packed.c = 0x7112233;
+
+ struct LargePackedBits {
+ uint64_t a: 36;
+ uint64_t b: 36;
+ } __attribute__((packed));
+
+ struct LargePackedBits large_packed =
+ (struct LargePackedBits){ 0xcbbbbaaaa, 0xdffffeeee };
+
+ return 0; //// Set break point at this line.
+
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/Makefile
new file mode 100644
index 00000000000..57083c95274
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/Makefile
@@ -0,0 +1,4 @@
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -fblocks
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py
new file mode 100644
index 00000000000..cd82d159248
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py
@@ -0,0 +1,81 @@
+"""Test that lldb can invoke blocks and access variables inside them"""
+
+
+
+import unittest2
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class BlocksTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ lines = []
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break at.
+ self.lines.append(line_number('main.c', '// Set breakpoint 0 here.'))
+ self.lines.append(line_number('main.c', '// Set breakpoint 1 here.'))
+
+ def launch_common(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ self.is_started = False
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ for line in self.lines:
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", line, num_expected_locations=1, loc_exact=True)
+
+ self.wait_for_breakpoint()
+
+ @skipUnlessDarwin
+ def test_expr(self):
+ self.launch_common()
+
+ self.expect("expression a + b", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 7"])
+
+ self.expect("expression c", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 1"])
+
+ self.wait_for_breakpoint()
+
+ # This should display correctly.
+ self.expect("expression (int)neg (-12)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["= 12"])
+
+ @skipUnlessDarwin
+ def test_define(self):
+ self.launch_common()
+
+ self.runCmd(
+ "expression int (^$add)(int, int) = ^int(int a, int b) { return a + b; };")
+ self.expect(
+ "expression $add(2,3)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[" = 5"])
+
+ self.runCmd("expression int $a = 3")
+ self.expect(
+ "expression int (^$addA)(int) = ^int(int b) { return $a + b; };",
+ "Proper error is reported on capture",
+ error=True)
+
+ def wait_for_breakpoint(self):
+ if not self.is_started:
+ self.is_started = True
+ self.runCmd("process launch", RUN_SUCCEEDED)
+ else:
+ self.runCmd("process continue", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/main.c
new file mode 100644
index 00000000000..415e6c6d033
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/blocks/main.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+int main()
+{
+ int c = 1;
+
+ int (^add)(int, int) = ^int(int a, int b)
+ {
+ return a + b + c; // Set breakpoint 0 here.
+ };
+
+ int (^neg)(int) = ^int(int a)
+ {
+ return -a;
+ };
+
+ printf("%d\n", add(3, 4));
+ printf("%d\n", neg(-5)); // Set breakpoint 1 here.
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile
new file mode 100644
index 00000000000..59778ab5d9f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile
@@ -0,0 +1,14 @@
+LD_EXTRAS := -L. -LOne -l$(LIB_PREFIX)One -LTwo -l$(LIB_PREFIX)Two
+C_SOURCES := main.c
+
+include Makefile.rules
+
+.PHONY:
+a.out: lib_One lib_Two
+
+lib_%:
+ $(MAKE) VPATH=$(SRCDIR)/$* -I $(SRCDIR) -f $(SRCDIR)/$*.mk
+
+clean::
+ $(MAKE) -f $(SRCDIR)/One.mk clean
+ $(MAKE) -f $(SRCDIR)/Two.mk clean
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk
new file mode 100644
index 00000000000..18f3725d22f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk
@@ -0,0 +1,8 @@
+DYLIB_NAME := One
+DYLIB_C_SOURCES := One.c OneConstant.c
+DYLIB_ONLY := YES
+
+include Makefile.rules
+
+OneConstant.o: OneConstant.c
+ $(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.c
new file mode 100644
index 00000000000..6bd729f6570
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.c
@@ -0,0 +1,6 @@
+#include "One.h"
+#include <stdio.h>
+
+void one() {
+ printf("One\n"); // break here
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h
new file mode 100644
index 00000000000..aae27571bb9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h
@@ -0,0 +1,4 @@
+#ifndef ONE_H
+#define ONE_H
+LLDB_TEST_API void one();
+#endif
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/OneConstant.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/OneConstant.c
new file mode 100644
index 00000000000..8255c2fce99
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/OneConstant.c
@@ -0,0 +1 @@
+int __attribute__ ((visibility("hidden"))) conflicting_symbol = 11111;
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
new file mode 100644
index 00000000000..9d088e308ed
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
@@ -0,0 +1,122 @@
+"""Test that conflicting symbols in different shared libraries work correctly"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestConflictingSymbols(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ TestBase.setUp(self)
+ lldbutil.mkdir_p(self.getBuildArtifact("One"))
+ lldbutil.mkdir_p(self.getBuildArtifact("Two"))
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489")
+ @expectedFailureNetBSD
+ def test_conflicting_symbols(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ environment = self.registerSharedLibrariesWithTarget(
+ target, ['One', 'Two'])
+
+ lldbutil.run_break_set_by_source_regexp(self, '// break here',
+ extra_options='-f One.c', num_expected_locations=-2)
+ lldbutil.run_break_set_by_source_regexp(self, '// break here',
+ extra_options='-f Two.c', num_expected_locations=-2)
+ lldbutil.run_break_set_by_source_regexp(self, '// break here',
+ extra_options='-f main.c', num_expected_locations=1)
+
+ process = target.LaunchSimple(
+ None, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # This should display correctly.
+ self.expect(
+ "expr (unsigned long long)conflicting_symbol",
+ "Symbol from One should be found",
+ substrs=[
+ "11111"])
+
+ self.runCmd("continue", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ self.expect(
+ "expr (unsigned long long)conflicting_symbol",
+ "Symbol from Two should be found",
+ substrs=[
+ "22222"])
+
+ self.runCmd("continue", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ self.expect(
+ "expr (unsigned long long)conflicting_symbol",
+ "An error should be printed when symbols can't be ordered",
+ error=True,
+ substrs=[
+ "Multiple internal symbols"])
+
+ @expectedFailureAll(bugnumber="llvm.org/pr35043")
+ @skipIfWindows # This test is "passing" on Windows, but it is a false positive.
+ def test_shadowed(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ environment = self.registerSharedLibrariesWithTarget(
+ target, ['One', 'Two'])
+
+ lldbutil.run_break_set_by_source_regexp(self, '// break here',
+ extra_options='-f main.c', num_expected_locations=1)
+
+ process = target.LaunchSimple(
+ None, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # As we are shadowing the conflicting symbol, there should be no
+ # ambiguity in this expression.
+ self.expect(
+ "expr int conflicting_symbol = 474747; conflicting_symbol",
+ substrs=[ "474747"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk
new file mode 100644
index 00000000000..79b256a0e85
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk
@@ -0,0 +1,8 @@
+DYLIB_NAME := Two
+DYLIB_C_SOURCES := Two.c TwoConstant.c
+DYLIB_ONLY := YES
+
+include Makefile.rules
+
+TwoConstant.o: TwoConstant.c
+ $(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.c
new file mode 100644
index 00000000000..8d8d668b8c3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.c
@@ -0,0 +1,6 @@
+#include "Two.h"
+#include <stdio.h>
+
+void two() {
+ printf("Two\n"); // break here
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h
new file mode 100644
index 00000000000..450fe5a3551
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h
@@ -0,0 +1,4 @@
+#ifndef TWO_H
+#define TWO_H
+LLDB_TEST_API void two();
+#endif
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/TwoConstant.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/TwoConstant.c
new file mode 100644
index 00000000000..9fc7c4b7951
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/TwoConstant.c
@@ -0,0 +1 @@
+int __attribute__ ((visibility("hidden"))) conflicting_symbol = 22222;
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/main.c
new file mode 100644
index 00000000000..4dcd443c049
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/main.c
@@ -0,0 +1,11 @@
+#include "One/One.h"
+#include "Two/Two.h"
+
+#include <stdio.h>
+
+int main() {
+ one();
+ two();
+ printf("main\n"); // break here
+ return(0);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/Makefile
new file mode 100644
index 00000000000..325be90d17e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := main.c functions.c
+
+CFLAGS_EXTRAS := -O3
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
new file mode 100644
index 00000000000..59fa6bcb0a1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
@@ -0,0 +1,68 @@
+"""Check that compiler-generated constant values work correctly"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ConstVariableTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureAll(
+ oslist=["freebsd", "linux"],
+ compiler="clang", compiler_version=["<", "3.5"])
+ @expectedFailureAll(
+ oslist=["freebsd", "linux"],
+ compiler="clang", compiler_version=["=", "3.7"])
+ @expectedFailureAll(
+ oslist=["freebsd", "linux"],
+ compiler="clang", compiler_version=["=", "3.8"])
+ @expectedFailureAll(oslist=["freebsd", "linux"], compiler="icc")
+ @expectedFailureAll(archs=['mips', 'mipsel', 'mips64', 'mips64el'])
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
+ @expectedFailureNetBSD
+ def test_and_run_command(self):
+ """Test interpreted and JITted expressions on constant values."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the main.
+ lldbutil.run_break_set_by_symbol(
+ self, "main", num_expected_locations=1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ self.runCmd("next")
+ self.runCmd("next")
+
+ # Try frame variable.
+ self.expect("frame variable index", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['(int32_t) index = 512'])
+
+ # Try an interpreted expression.
+ self.expect("expr (index + 512)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['1024'])
+
+ # Try a JITted expression.
+ self.expect(
+ "expr (int)getpid(); (index - 256)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['256'])
+
+ self.runCmd("kill")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/functions.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/functions.c
new file mode 100644
index 00000000000..c9ea63837c8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/functions.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+void foo()
+{
+ printf("foo()\n");
+}
+
+int bar()
+{
+ int ret = 3;
+ printf("bar()->%d\n", ret);
+ return ret;
+}
+
+void baaz(int i)
+{
+ printf("baaz(%d)\n", i);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/main.c
new file mode 100644
index 00000000000..50a924e01d9
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/const_variables/main.c
@@ -0,0 +1,23 @@
+#include <stdint.h>
+#include <stdio.h>
+
+extern int foo();
+extern int bar();
+extern int baaz(int i);
+
+int main()
+{
+ int32_t index;
+
+ foo();
+
+ index = 512;
+
+ if (bar())
+ {
+ printf("COMPILER PLEASE STOP HERE\n");
+ index = 256;
+ }
+
+ baaz(index);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
new file mode 100644
index 00000000000..af9b6fb8d46
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
@@ -0,0 +1,126 @@
+"""Look up enum type information and check for correct display."""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+
+
+class EnumTypesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.c', '// Set break point at this line.')
+
+ def test(self):
+ """Test 'image lookup -t days' and check for correct display and enum value printing."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_to_source_breakpoint(
+ self, '// Breakpoint for bitfield', lldb.SBFileSpec("main.c"))
+
+ self.expect("fr var a", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = A$'])
+ self.expect("fr var b", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = B$'])
+ self.expect("fr var c", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = C$'])
+ self.expect("fr var ab", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = AB$'])
+ self.expect("fr var ac", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = A | C$'])
+ self.expect("fr var all", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = ALL$'])
+ # Test that an enum that doesn't match the heuristic we use in
+ # ClangASTContext::DumpEnumValue, gets printed as a raw integer.
+ self.expect("fr var omega", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = 7$'])
+ # Test the behavior in case have a variable of a type considered
+ # 'bitfield' by the heuristic, but the value isn't actually fully
+ # covered by the enumerators.
+ self.expect("p (enum bitfield)nonsense", DATA_TYPES_DISPLAYED_CORRECTLY,
+ patterns=[' = B | C | 0x10$'])
+
+ # Break inside the main.
+ bkpt_id = lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+ self.runCmd("c", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # Look up information about the 'days' enum type.
+ # Check for correct display.
+ self.expect("image lookup -t days", DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=['enum days {',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday',
+ 'Sunday',
+ 'kNumDays',
+ '}'])
+
+ enum_values = ['-4',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday',
+ 'Sunday',
+ 'kNumDays',
+ '5']
+
+ # Make sure a pointer to an anonymous enum type does crash LLDB and displays correctly using
+ # frame variable and expression commands
+ self.expect(
+ 'frame variable f.op',
+ DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=[
+ 'ops *',
+ 'f.op'],
+ patterns=['0x0+$'])
+ self.expect(
+ 'frame variable *f.op',
+ DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=[
+ 'ops',
+ '*f.op',
+ '<parent is NULL>'])
+ self.expect(
+ 'expr f.op',
+ DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=[
+ 'ops *',
+ '$'],
+ patterns=['0x0+$'])
+ self.expect(
+ 'expr *f.op',
+ DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=['error:'],
+ error=True)
+
+ bkpt = self.target().FindBreakpointByID(bkpt_id)
+ for enum_value in enum_values:
+ self.expect(
+ "frame variable day",
+ 'check for valid enumeration value',
+ substrs=[enum_value])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
new file mode 100644
index 00000000000..675af5ecec5
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
@@ -0,0 +1,58 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+#include <stdio.h>
+
+// Forward declare an enumeration (only works in C, not C++)
+typedef enum ops ops;
+
+struct foo {
+ ops *op;
+};
+
+int main (int argc, char const *argv[])
+{
+ enum bitfield {
+ None = 0,
+ A = 1 << 0,
+ B = 1 << 1,
+ C = 1 << 2,
+ AB = A | B,
+ ALL = A | B | C,
+ };
+
+ enum non_bitfield {
+ Alpha = 3,
+ Beta = 4
+ };
+
+ enum days {
+ Monday = -3,
+ Tuesday,
+ Wednesday,
+ Thursday,
+ Friday,
+ Saturday,
+ Sunday,
+ kNumDays
+ };
+
+ enum bitfield a = A, b = B, c = C, ab = AB, ac = A | C, all = ALL;
+ int nonsense = a + b + c + ab + ac + all;
+ enum non_bitfield omega = Alpha | Beta;
+
+ enum days day;
+ struct foo f;
+ f.op = NULL; // Breakpoint for bitfield
+ for (day = Monday - 1; day <= kNumDays + 1; day++)
+ {
+ printf("day as int is %i\n", (int)day); // Set break point at this line.
+ }
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
new file mode 100644
index 00000000000..c9319d6e688
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
new file mode 100644
index 00000000000..90d8530ff71
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
@@ -0,0 +1,59 @@
+"""
+Make sure FindTypes finds struct types with the struct prefix.
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestFindTypesOnStructType(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_find_types_struct_type(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ self.build()
+ self.do_test()
+
+ def do_test(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ exe = self.getBuildArtifact("a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Make sure this works with struct
+ type_list = target.FindTypes("struct mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with struct")
+
+ # Make sure this works without the struct:
+ type_list = target.FindTypes("mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without struct")
+
+ # Make sure it works with union
+ type_list = target.FindTypes("union myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with union")
+
+ # Make sure this works without the union:
+ type_list = target.FindTypes("myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without union")
+
+ # Make sure it works with typedef
+ type_list = target.FindTypes("typedef MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with typedef")
+
+ # Make sure this works without the typedef:
+ type_list = target.FindTypes("MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without typedef")
+
+
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
new file mode 100644
index 00000000000..fa009af27e1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+struct mytype {
+ int c;
+ int d;
+};
+
+union myunion {
+ int num;
+ char *str;
+};
+
+typedef struct mytype MyType;
+
+int main()
+{
+ struct mytype v;
+ MyType *v_ptr = &v;
+
+ union myunion u = {5};
+ v.c = u.num;
+ v.d = 10;
+ return v.c + v.d;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/Makefile
new file mode 100644
index 00000000000..472e733aaad
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c foo.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/README.txt b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/README.txt
new file mode 100644
index 00000000000..b7b66f75162
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/README.txt
@@ -0,0 +1,5 @@
+This example has a function call in foo.c named "foo" that takes a forward
+declaration to "struct bar" and uses it as a pointer argument. In main.c
+we have a real declaration for "struct bar". We want to be able to find the
+real definition of "struct bar" when we are stopped in foo in foo.c such that
+when we stop in "foo" we see the contents of the "bar_ptr".
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py
new file mode 100644
index 00000000000..9ea13612c07
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py
@@ -0,0 +1,65 @@
+"""Test that forward declaration of a data structure gets resolved correctly."""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ForwardDeclarationTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def do_test(self, dictionary=None):
+ """Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
+ self.build(dictionary=dictionary)
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_symbol(
+ self, "foo", num_expected_locations=1, sym_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # This should display correctly.
+ # Note that the member fields of a = 1 and b = 2 is by design.
+ self.expect(
+ "frame variable --show-types *bar_ptr",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ '(bar) *bar_ptr = ',
+ '(int) a = 1',
+ '(int) b = 2'])
+
+ # And so should this.
+ self.expect(
+ "expression --show-types -- *bar_ptr",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ '(bar)',
+ '(int) a = 1',
+ '(int) b = 2'])
+
+ def test(self):
+ self.do_test()
+
+ @no_debug_info_test
+ @skipIfDarwin
+ @skipIf(compiler=no_match("clang"))
+ @skipIf(compiler_version=["<", "7.0"])
+ def test_debug_names(self):
+ """Test that we are able to find complete types when using DWARF v5
+ accelerator tables"""
+ self.do_test(dict(CFLAGS_EXTRAS="-mllvm -accel-tables=Dwarf"))
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.c
new file mode 100644
index 00000000000..2e050e77778
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include "foo.h"
+
+int
+foo (struct bar *bar_ptr)
+{
+ return printf ("bar_ptr = %p\n", bar_ptr);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.h
new file mode 100644
index 00000000000..3040927cb47
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/foo.h
@@ -0,0 +1,4 @@
+
+struct bar;
+
+int foo (struct bar *bar_ptr);
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/main.c
new file mode 100644
index 00000000000..6f9787c30a3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/forward/main.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include "foo.h"
+
+struct bar
+{
+ int a;
+ int b;
+};
+
+int
+main (int argc, char const *argv[])
+{
+ struct bar b= { 1, 2 };
+
+ foo (&b);
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py
new file mode 100644
index 00000000000..3753eab64ef
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py
@@ -0,0 +1,83 @@
+"""Test variable with function ptr type and that break on the function works."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class FunctionTypesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.c', '// Set break point at this line.')
+
+ def test(self):
+ """Test 'callback' has function ptr type, then break on the function."""
+ self.build()
+ self.runToBreakpoint()
+
+ # Check that the 'callback' variable display properly.
+ self.expect(
+ "frame variable --show-types callback",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr='(int (*)(const char *)) callback =')
+
+ # And that we can break on the callback function.
+ lldbutil.run_break_set_by_symbol(
+ self,
+ "string_not_empty",
+ num_expected_locations=1,
+ sym_exact=True)
+ self.runCmd("continue")
+
+ # Check that we do indeed stop on the string_not_empty function.
+ self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['a.out`string_not_empty',
+ 'stop reason = breakpoint'])
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
+ @expectedFailureNetBSD
+ def test_pointers(self):
+ """Test that a function pointer to 'printf' works and can be called."""
+ self.build()
+ self.runToBreakpoint()
+
+ self.expect("expr string_not_empty",
+ substrs=['(int (*)(const char *)) $0 = ', '(a.out`'])
+
+ if self.platformIsDarwin():
+ regexps = ['lib.*\.dylib`printf']
+ else:
+ regexps = ['printf']
+ self.expect("expr (int (*)(const char*, ...))printf",
+ substrs=['(int (*)(const char *, ...)) $1 = '],
+ patterns=regexps)
+
+ self.expect("expr $1(\"Hello world\\n\")",
+ startstr='(int) $2 = 12')
+
+ def runToBreakpoint(self):
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the main.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/main.c
new file mode 100644
index 00000000000..f8710f67720
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/function_types/main.c
@@ -0,0 +1,21 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+int string_not_empty (const char *s)
+{
+ if (s && s[0])
+ return 1;
+ return 0;
+}
+
+int main (int argc, char const *argv[])
+{
+ int (*callback)(const char *) = string_not_empty;
+
+ return callback(0); // Set break point at this line.
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/Makefile
new file mode 100644
index 00000000000..7b94b6556f2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/Makefile
@@ -0,0 +1,6 @@
+C_SOURCES := main.c
+
+DYLIB_NAME := a
+DYLIB_C_SOURCES := a.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
new file mode 100644
index 00000000000..690d1abb3cf
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
@@ -0,0 +1,123 @@
+"""Show global variables and check that they do indeed have global scopes."""
+
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GlobalVariablesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.source = 'main.c'
+ self.line = line_number(
+ self.source, '// Set break point at this line.')
+ self.shlib_names = ["a"]
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+ def test_without_process(self):
+ """Test that static initialized variables can be inspected without
+ process."""
+ self.build()
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+ self.assertTrue(target, VALID_TARGET)
+ self.expect("target variable g_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['(int *)'])
+ self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['42'])
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+ @expectedFailureNetBSD
+ def test_c_global_variables(self):
+ """Test 'frame variable --scope --no-args' which omits args and shows scopes."""
+ self.build()
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ # Break inside the main.
+ lldbutil.run_break_set_by_file_and_line(
+ self, self.source, self.line, num_expected_locations=1, loc_exact=True)
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ environment = self.registerSharedLibrariesWithTarget(
+ target, self.shlib_names)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # Test that the statically initialized variable can also be
+ # inspected *with* a process.
+ self.expect("target variable g_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['(int *)'])
+ self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['42'])
+
+ # Check that GLOBAL scopes are indicated for the variables.
+ self.expect(
+ "frame variable --show-types --scope --show-globals --no-args",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ 'STATIC: (const int) g_file_static_int = 2',
+ 'STATIC: (const char *) g_func_static_cstr',
+ 'GLOBAL: (const char *) g_file_global_cstr',
+ '"g_file_global_cstr"',
+ 'GLOBAL: (int) g_file_global_int = 42',
+ 'GLOBAL: (int) g_common_1 = 21',
+ 'GLOBAL: (int *) g_ptr',
+ 'STATIC: (const char *) g_file_static_cstr',
+ '"g_file_static_cstr"'
+ ])
+
+ # 'frame variable' should support address-of operator.
+ self.runCmd("frame variable &g_file_global_int")
+
+ # Exercise the 'target variable' command to display globals in a.c
+ # file.
+ self.expect("target variable g_a", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['g_a', '123'])
+ self.expect(
+ "target variable g_marked_spot.x",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ 'g_marked_spot.x',
+ '20'])
+
+ # rdar://problem/9747668
+ # runCmd: target variable g_marked_spot.y
+ # output: (int) g_marked_spot.y = <a.o[0x214] can't be resolved, in not currently loaded.
+ # >
+ self.expect(
+ "target variable g_marked_spot.y",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ 'g_marked_spot.y',
+ '21'])
+ self.expect(
+ "target variable g_marked_spot.y",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ matching=False,
+ substrs=["can't be resolved"])
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/a.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/a.c
new file mode 100644
index 00000000000..ce3e6f9a2d4
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/a.c
@@ -0,0 +1,14 @@
+//===-- a.c -----------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+int g_a = 123;
+struct Point {
+ int x;
+ int y;
+};
+struct Point g_marked_spot = { 20, 21 };
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/cmds.txt b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/cmds.txt
new file mode 100644
index 00000000000..6906a0729ae
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/cmds.txt
@@ -0,0 +1,3 @@
+break main.c:5
+continue
+var -global g_a -global g_global_int
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
new file mode 100644
index 00000000000..ea54eb927c0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
@@ -0,0 +1,24 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+int g_common_1; // Not initialized on purpose to cause it to be undefined external in .o file
+int g_file_global_int = 42;
+static const int g_file_static_int = 2;
+const char *g_file_global_cstr = "g_file_global_cstr";
+static const char *g_file_static_cstr = "g_file_static_cstr";
+int *g_ptr = &g_file_global_int;
+
+extern int g_a;
+int main (int argc, char const *argv[])
+{
+ g_common_1 = g_file_global_int / g_file_static_int;
+ static const char *g_func_static_cstr = "g_func_static_cstr";
+ printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
+ return g_file_global_int + g_a + g_common_1 + *g_ptr; // Set break point at this line. //// break $source:$line; continue; var -global g_a -global g_global_int
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
new file mode 100644
index 00000000000..311c5ec8e12
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
@@ -0,0 +1,9 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__,
+ globals(),
+ [decorators.expectedFailureAll(compiler="clang",
+ compiler_version=["<",
+ "3.5"],
+ bugnumber="llvm.org/pr27845")])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c
new file mode 100644
index 00000000000..8fe49180800
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+
+inline void test1(int) __attribute__ ((always_inline));
+inline void test2(int) __attribute__ ((always_inline));
+
+void test2(int b) {
+ printf("test2(%d)\n", b); //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"])
+ {
+ int c = b * 2;
+ printf("c=%d\n", c); //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"])
+ //% self.expect("expression c", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["84"])
+ }
+}
+
+void test1(int a) {
+ printf("test1(%d)\n", a);
+ test2(a+1);//% self.runCmd("step")
+ //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["24"])
+}
+
+int main() {
+ test2(42);
+ test1(23);
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py
new file mode 100644
index 00000000000..2b8307ace0f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py
@@ -0,0 +1,48 @@
+"""
+If there is a definition of a type in the current
+Execution Context's CU, then we should use that type
+even if there are other definitions of the type in other
+CU's. Assert that that is true.
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestUseClosestType(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ @expectedFailureAll(bugnumber="<rdar://problem/53262085>")
+ def test_use_in_expr(self):
+ """Use the shadowed type directly, see if we get a conflicting type definition."""
+ self.build()
+ self.main_source_file = lldb.SBFileSpec("main.c")
+ self.expr_test()
+
+ def run_and_check_expr(self, num_children, child_type):
+ frame = self.thread.GetFrameAtIndex(0)
+ result = frame.EvaluateExpression("struct Foo *$mine = (struct Foo *) malloc(sizeof(struct Foo)); $mine")
+ self.assertTrue(result.GetError().Success(), "Failed to parse an expression using a multiply defined type: %s"%(result.GetError().GetCString()), )
+ self.assertEqual(result.GetTypeName(), "struct Foo *", "The result has the right typename.")
+ self.assertEqual(result.GetNumChildren(), num_children, "Got the right number of children")
+ self.assertEqual(result.GetChildAtIndex(0).GetTypeName(), child_type, "Got the right type.")
+
+ def expr_test(self):
+ """ Run to a breakpoint in main.c, check that an expression referring to Foo gets the
+ local three int version. Then run to a breakpoint in other.c and check that an
+ expression referring to Foo gets the two char* version. """
+
+ (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+ "Set a breakpoint in main", self.main_source_file)
+
+ self.run_and_check_expr(3, "int")
+ lldbutil.run_to_source_breakpoint(self, "Set a breakpoint in other", lldb.SBFileSpec("other.c"))
+ self.run_and_check_expr(2, "char *")
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/main.c
new file mode 100644
index 00000000000..321facfee21
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/main.c
@@ -0,0 +1,16 @@
+extern int callme(int input);
+
+struct Foo {
+ int a;
+ int b;
+ int c;
+};
+
+int
+main(int argc, char **argv)
+{
+ // Set a breakpoint in main
+ struct Foo mine = {callme(argc), 10, 20};
+ return mine.a;
+}
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/other.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/other.c
new file mode 100644
index 00000000000..24b72d45ea8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_types/other.c
@@ -0,0 +1,11 @@
+struct Foo {
+ char *ptr1;
+ char *ptr2;
+};
+
+int
+callme(int input)
+{
+ struct Foo myFoo = { "string one", "Set a breakpoint in other"};
+ return myFoo.ptr1[0] + myFoo.ptr2[0] + input;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/Makefile
new file mode 100644
index 00000000000..d3998eeef99
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := main.c
+
+CFLAGS_EXTRAS := -O1
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/TestLocalVariables.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/TestLocalVariables.py
new file mode 100644
index 00000000000..381292a445b
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/TestLocalVariables.py
@@ -0,0 +1,55 @@
+"""Show local variables and check that they can be inspected.
+
+This test was added after we made a change in clang to normalize
+DW_OP_constu(X < 32) to DW_OP_litX which broke the debugger because
+it didn't read the value as an unsigned.
+"""
+
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LocalVariablesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.source = 'main.c'
+ self.line = line_number(
+ self.source, '// Set break point at this line.')
+
+ @skipIfWindows
+ def test_c_local_variables(self):
+ """Test local variable value."""
+ self.build()
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ # Break inside the main.
+ lldbutil.run_break_set_by_file_and_line(
+ self, self.source, self.line, num_expected_locations=1, loc_exact=True)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ self.expect("frame variable i", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['(unsigned int) i = 10'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/main.c
new file mode 100644
index 00000000000..2ab579a71a7
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/local_variables/main.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+void bar(unsigned i)
+{
+ printf("%d\n", i);
+}
+
+void foo(unsigned j)
+{
+ unsigned i = j;
+ bar(i);
+ i = 10;
+ bar(i); // Set break point at this line.
+}
+
+int main(int argc, char** argv)
+{
+ foo(argc);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
new file mode 100644
index 00000000000..948e8bed786
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
@@ -0,0 +1,91 @@
+"""Test that importing modules in C works as expected."""
+
+
+
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CModulesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfFreeBSD
+ @expectedFailureAll(
+ oslist=["linux"],
+ bugnumber="http://llvm.org/pr23456 'fopen' has unknown return type")
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
+ @skipIf(macos_version=["<", "10.12"])
+ @expectedFailureNetBSD
+ def test_expr(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # Enable logging of the imported AST.
+ log_file = os.path.join(self.getBuildDir(), "lldb-ast-log.txt")
+ self.runCmd("log enable lldb ast -f '%s'" % log_file)
+
+ self.expect(
+ "expr -l objc++ -- @import Darwin; 3",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "int",
+ "3"])
+
+ # This expr command imports __sFILE with definition
+ # (FILE is a typedef to __sFILE.)
+ self.expect(
+ "expr *fopen(\"/dev/zero\", \"w\")",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "FILE",
+ "_close"])
+
+ # Check that the AST log contains exactly one definition of __sFILE.
+ f = open(log_file)
+ log_lines = f.readlines()
+ f.close()
+ os.remove(log_file)
+ self.assertEqual(" ".join(log_lines).count("struct __sFILE definition"),
+ 1)
+
+ self.expect("expr *myFile", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["a", "5", "b", "9"])
+
+ self.expect(
+ "expr MIN((uint64_t)2, (uint64_t)3)",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "uint64_t",
+ "2"])
+
+ self.expect("expr stdin", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=["(FILE *)", "0x"])
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.c', '// Set breakpoint 0 here.')
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
new file mode 100644
index 00000000000..df321a75faa
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+
+int printf(const char * __restrict format, ...);
+
+typedef struct {
+ int a;
+ int b;
+} MYFILE;
+
+int main()
+{
+ MYFILE *myFile = malloc(sizeof(MYFILE));
+
+ myFile->a = 5;
+ myFile->b = 9;
+
+ printf("%d\n", myFile->a + myFile->b); // Set breakpoint 0 here.
+
+ free(myFile);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py
new file mode 100644
index 00000000000..cdfbaae0ce3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [decorators.no_debug_info_test])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c
new file mode 100644
index 00000000000..cbb4a144418
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c
@@ -0,0 +1,12 @@
+#include <stdint.h>
+
+struct Foo {
+ int8_t a;
+ int16_t b;
+};
+
+int main (int argc, char const *argv[]) {
+ struct Foo f;
+ return f.a; //% self.expect("expr offsetof(Foo, a)", substrs = ['= 0'])
+ //% self.expect("expr offsetof(Foo, b)", substrs = ['= 2'])
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/main.c
new file mode 100644
index 00000000000..1159669ebf1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/recurse/main.c
@@ -0,0 +1,28 @@
+#include <stdint.h>
+#include <stdio.h>
+
+uint32_t
+recurse_crash (uint32_t depth)
+{
+ if (depth > 0)
+ return recurse_crash (depth - 1);
+ return 0;
+}
+
+int
+main (int argc, char const *argv[])
+{
+ // If we have more than one argument, then it should a depth to recurse to.
+ // If we have just the program name as an argument, use UINT32_MAX so we
+ // eventually crash the program by overflowing the stack
+ uint32_t depth = UINT32_MAX;
+ if (argc > 1)
+ {
+ char *end = NULL;
+ depth = strtoul (argv[1], &end, 0);
+ if (end == NULL || *end != '\0')
+ depth = UINT32_MAX;
+ }
+ recurse_crash (depth);
+ return 0;
+} \ No newline at end of file
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
new file mode 100644
index 00000000000..e4d42f6525d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := test.c
+
+CFLAGS_EXTRAS := -O1 -D_FORTIFY_SOURCE=0
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py
new file mode 100644
index 00000000000..af0ad2a0871
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py
@@ -0,0 +1,204 @@
+"""Check that compiler-generated register values work correctly"""
+
+from __future__ import print_function
+
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+# This method attempts to figure out if a given variable
+# is in a register.
+#
+# Return:
+# True if the value has a readable value and is in a register
+# False otherwise
+
+
+def is_variable_in_register(frame, var_name):
+ # Ensure we can lookup the variable.
+ var = frame.FindVariable(var_name)
+ # print("\nchecking {}...".format(var_name))
+ if var is None or not var.IsValid():
+ # print("{} cannot be found".format(var_name))
+ return False
+
+ # Check that we can get its value. If not, this
+ # may be a variable that is just out of scope at this point.
+ value = var.GetValue()
+ # print("checking value...")
+ if value is None:
+ # print("value is invalid")
+ return False
+ # else:
+ # print("value is {}".format(value))
+
+ # We have a variable and we can get its value. The variable is in
+ # a register if we cannot get an address for it, assuming it is
+ # not a struct pointer. (This is an approximation - compilers can
+ # do other things with spitting up a value into multiple parts of
+ # multiple registers, but what we're verifying here is much more
+ # than it was doing before).
+ var_addr = var.GetAddress()
+ # print("checking address...")
+ if var_addr.IsValid():
+ # We have an address, it must not be in a register.
+ # print("var {} is not in a register: has a valid address {}".format(var_name, var_addr))
+ return False
+ else:
+ # We don't have an address but we can read the value.
+ # It is likely stored in a register.
+ # print("var {} is in a register (we don't have an address for it)".format(var_name))
+ return True
+
+
+def is_struct_pointer_in_register(frame, var_name, trace):
+ # Ensure we can lookup the variable.
+ var = frame.FindVariable(var_name)
+ if trace:
+ print("\nchecking {}...".format(var_name))
+
+ if var is None or not var.IsValid():
+ # print("{} cannot be found".format(var_name))
+ return False
+
+ # Check that we can get its value. If not, this
+ # may be a variable that is just out of scope at this point.
+ value = var.GetValue()
+ # print("checking value...")
+ if value is None:
+ if trace:
+ print("value is invalid")
+ return False
+ else:
+ if trace:
+ print("value is {}".format(value))
+
+ var_loc = var.GetLocation()
+ if trace:
+ print("checking location: {}".format(var_loc))
+ if var_loc is None or var_loc.startswith("0x"):
+ # The frame var is not in a register but rather a memory location.
+ # print("frame var {} is not in a register".format(var_name))
+ return False
+ else:
+ # print("frame var {} is in a register".format(var_name))
+ return True
+
+
+def re_expr_equals(val_type, val):
+ # Match ({val_type}) ${sum_digits} = {val}
+ return re.compile(r'\(' + val_type + '\) \$\d+ = ' + str(val))
+
+
+class RegisterVariableTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureAll(compiler="clang", compiler_version=['<', '3.5'])
+ @expectedFailureAll(compiler="gcc", compiler_version=[
+ '>=', '4.8.2'], archs=["i386"])
+ @expectedFailureAll(compiler="gcc", compiler_version=[
+ '<', '4.9'], archs=["x86_64"])
+ def test_and_run_command(self):
+ """Test expressions on register values."""
+
+ # This test now ensures that each probable
+ # register variable location is actually a register, and
+ # if so, whether we can print out the variable there.
+ # It only requires one of them to be handled in a non-error
+ # way.
+ register_variables_count = 0
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the main.
+ lldbutil.run_break_set_by_source_regexp(
+ self, "break", num_expected_locations=3)
+
+ ####################
+ # First breakpoint
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # Try some variables that should be visible
+ frame = self.dbg.GetSelectedTarget().GetProcess(
+ ).GetSelectedThread().GetSelectedFrame()
+ if is_variable_in_register(frame, 'a'):
+ register_variables_count += 1
+ self.expect("expr a", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=[re_expr_equals('int', 2)])
+
+ if is_struct_pointer_in_register(frame, 'b', self.TraceOn()):
+ register_variables_count += 1
+ self.expect("expr b->m1", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=[re_expr_equals('int', 3)])
+
+ #####################
+ # Second breakpoint
+
+ self.runCmd("continue")
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # Try some variables that should be visible
+ frame = self.dbg.GetSelectedTarget().GetProcess(
+ ).GetSelectedThread().GetSelectedFrame()
+ if is_struct_pointer_in_register(frame, 'b', self.TraceOn()):
+ register_variables_count += 1
+ self.expect("expr b->m2", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=[re_expr_equals('int', 5)])
+
+ if is_variable_in_register(frame, 'c'):
+ register_variables_count += 1
+ self.expect("expr c", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=[re_expr_equals('int', 5)])
+
+ #####################
+ # Third breakpoint
+
+ self.runCmd("continue")
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # Try some variables that should be visible
+ frame = self.dbg.GetSelectedTarget().GetProcess(
+ ).GetSelectedThread().GetSelectedFrame()
+ if is_variable_in_register(frame, 'f'):
+ register_variables_count += 1
+ self.expect("expr f", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=[re_expr_equals('float', '3.1')])
+
+ # Validate that we verified at least one register variable
+ self.assertTrue(
+ register_variables_count > 0,
+ "expected to verify at least one variable in a register")
+ # print("executed {} expressions with values in registers".format(register_variables_count))
+
+ self.runCmd("kill")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/test.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/test.c
new file mode 100644
index 00000000000..2c69039d40a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/register_variables/test.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+
+#if defined(__arm__) || defined(__aarch64__) || defined (__mips__) || defined(__powerpc64__)
+// Clang does not accept regparm attribute on these platforms.
+// Fortunately, the default calling convention passes arguments in registers
+// anyway.
+#define REGPARM(N)
+#else
+#define REGPARM(N) __attribute__((regparm(N)))
+#endif
+
+struct bar {
+ int m1;
+ int m2;
+};
+
+void f1(int a, struct bar *b) __attribute__((noinline)) REGPARM(2);
+void f1(int a, struct bar *b)
+{
+ b->m2 = b->m1 + a; // set breakpoint here
+}
+
+void f2(struct bar *b) __attribute__((noinline)) REGPARM(1);
+void f2(struct bar *b)
+{
+ int c = b->m2;
+ printf("%d\n", c); // set breakpoint here
+}
+
+float f3() __attribute__((noinline));
+float f3() {
+ return 3.14f;
+}
+
+int main()
+{
+ struct bar myBar = { 3, 4 };
+ f1(2, &myBar);
+ f2(&myBar);
+
+ float f = f3();
+ printf("%f\n", f); // set breakpoint here
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py
new file mode 100644
index 00000000000..f16d554b815
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py
@@ -0,0 +1,139 @@
+"""Test settings and readings of program variables."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class SetValuesTestCase(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.line1 = line_number('main.c', '// Set break point #1.')
+ self.line2 = line_number('main.c', '// Set break point #2.')
+ self.line3 = line_number('main.c', '// Set break point #3.')
+ self.line4 = line_number('main.c', '// Set break point #4.')
+ self.line5 = line_number('main.c', '// Set break point #5.')
+
+ def test(self):
+ """Test settings and readings of program variables."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Set breakpoints on several places to set program variables.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line1, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line2, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line3, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line4, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line5, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
+
+ # main.c:15
+ # Check that 'frame variable --show-types' displays the correct data
+ # type and value.
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(char) i = 'a'")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 'b'")
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(char) i = 'b'")
+
+ self.runCmd("continue")
+
+ # main.c:36
+ # Check that 'frame variable --show-types' displays the correct data
+ # type and value.
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=["\((short unsigned int|unsigned short)\) i = 33"])
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 333")
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=["\((short unsigned int|unsigned short)\) i = 333"])
+
+ self.runCmd("continue")
+
+ # main.c:57
+ # Check that 'frame variable --show-types' displays the correct data
+ # type and value.
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(long) i = 33")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 33333")
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(long) i = 33333")
+
+ self.runCmd("continue")
+
+ # main.c:78
+ # Check that 'frame variable --show-types' displays the correct data
+ # type and value.
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(double) i = 2.25")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 1.5")
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(double) i = 1.5")
+
+ self.runCmd("continue")
+
+ # main.c:85
+ # Check that 'frame variable --show-types' displays the correct data
+ # type and value.
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(long double) i = 2.25")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 1.5")
+ self.expect(
+ "frame variable --show-types",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr="(long double) i = 1.5")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/main.c
new file mode 100644
index 00000000000..64bc95fb5a8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/set_values/main.c
@@ -0,0 +1,115 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+void set_char(void)
+{
+ char i = 'a';
+ printf("before (char) i = %c\n", i);
+ printf("after (char) i = %c\n", i); // Set break point #1. //// break $source:$line
+}
+
+void set_uchar(void)
+{
+ unsigned char i = 'a';
+ printf("before (unsigned char) i = %c\n", i);
+ printf("after (unsigned char) i = %c\n", i); //// break $source:$line
+}
+
+void set_short(void)
+{
+ short i = 33;
+ printf("before (short) i = %i\n", i);
+ printf("after (short) i = %i\n", i); //// break $source:$line
+}
+
+void set_ushort(void)
+{
+ unsigned short i = 33;
+ printf("before (unsigned short) i = %i\n", i);
+ printf("after (unsigned short) i = %i\n", i); // Set break point #2. //// break $source:$line
+}
+
+void set_int(void)
+{
+ int i = 33;
+ printf("before (int) i = %i\n", i);
+ printf("after (int) i = %i\n", i); //// break $source:$line
+}
+
+void set_uint(void)
+{
+ unsigned int i = 33;
+ printf("before (unsigned int) i = %u\n", i);
+ printf("after (unsigned int) i = %u\n", i); //// break $source:$line
+}
+
+void set_long(void)
+{
+ long i = 33;
+ printf("before (long) i = %li\n", i);
+ printf("after (long) i = %li\n", i); // Set break point #3. //// break $source:$line
+}
+
+void set_ulong(void)
+{
+ unsigned long i = 33;
+ printf("before (unsigned long) i = %lu\n", i);
+ printf("after (unsigned long) i = %lu\n", i); //// break $source:$line
+}
+
+void set_float(void)
+{
+ float i = 2.25;
+ printf("before (float) i = %g\n", i);
+ printf("after (float) i = %g\n", i); //// break $source:$line
+}
+
+void set_double(void)
+{
+ double i = 2.25;
+ printf("before (double) i = %g\n", i);
+ printf("after (double) i = %g\n", i); // Set break point #4. //// break $source:$line
+}
+
+void set_long_double(void)
+{
+ long double i = 2.25;
+ printf("before (long double) i = %Lg\n", i);
+ printf("after (long double) i = %Lg\n", i); // Set break point #5. //// break $source:$line
+}
+
+void set_point (void)
+{
+ struct point_tag {
+ int x;
+ int y;
+ };
+ struct point_tag points_2[2] = {
+ {1,2},
+ {3,4}
+ };
+}
+
+int main (int argc, char const *argv[])
+{
+ // Continue to the breakpoint in set_char()
+ set_char(); //// continue; var i; val -set 99 1
+ set_uchar(); //// continue; var i; val -set 99 2
+ set_short(); //// continue; var i; val -set -42 3
+ set_ushort(); //// continue; var i; val -set 42 4
+ set_int(); //// continue; var i; val -set -42 5
+ set_uint(); //// continue; var i; val -set 42 6
+ set_long(); //// continue; var i; val -set -42 7
+ set_ulong(); //// continue; var i; val -set 42 8
+ set_float(); //// continue; var i; val -set 123.456 9
+ set_double(); //// continue; var i; val -set 123.456 10
+ set_long_double(); //// continue; var i; val -set 123.456 11
+ set_point (); //// continue
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile
new file mode 100644
index 00000000000..5e26f2748c0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile
@@ -0,0 +1,5 @@
+DYLIB_NAME := foo
+DYLIB_C_SOURCES := foo.c
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py
new file mode 100644
index 00000000000..789939b29e7
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py
@@ -0,0 +1,101 @@
+"""Test that types defined in shared libraries work correctly."""
+
+
+
+import unittest2
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class SharedLibTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def common_test_expr(self, preload_symbols):
+ if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
+ self.skipTest(
+ "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
+
+ self.build()
+ self.common_setup(preload_symbols)
+
+ # This should display correctly.
+ self.expect(
+ "expression --show-types -- *my_foo_ptr",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "(foo)",
+ "(sub_foo)",
+ "other_element = 3"])
+
+ self.expect(
+ "expression GetMeASubFoo(my_foo_ptr)",
+ startstr="(sub_foo *) $")
+
+ @expectedFailureNetBSD
+ def test_expr(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.common_test_expr(True)
+
+ @expectedFailureNetBSD
+ def test_expr_no_preload(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled"""
+ self.common_test_expr(False)
+
+ @unittest2.expectedFailure("llvm.org/PR36712")
+ def test_frame_variable(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.build()
+ self.common_setup()
+
+ # This should display correctly.
+ self.expect(
+ "frame variable --show-types -- *my_foo_ptr",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "(foo)",
+ "(sub_foo)",
+ "other_element = 3"])
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.source = 'main.c'
+ self.line = line_number(self.source, '// Set breakpoint 0 here.')
+ self.shlib_names = ["foo"]
+
+ def common_setup(self, preload_symbols = True):
+ # Run in synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ self.runCmd("settings set target.preload-symbols " + str(preload_symbols).lower())
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line(
+ self, self.source, self.line, num_expected_locations=1, loc_exact=True)
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ environment = self.registerSharedLibrariesWithTarget(
+ target, self.shlib_names)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.c
new file mode 100644
index 00000000000..6431bc496c3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.c
@@ -0,0 +1,22 @@
+#include "foo.h"
+#include <stdlib.h>
+
+struct foo
+{
+ struct sub_foo sub_element;
+ int other_element;
+};
+
+struct foo *
+GetMeAFoo()
+{
+ struct foo *ret_val = (struct foo *) malloc (sizeof (struct foo));
+ ret_val->other_element = 3;
+ return ret_val;
+}
+
+struct sub_foo *
+GetMeASubFoo (struct foo *in_foo)
+{
+ return &(in_foo->sub_element);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.h
new file mode 100644
index 00000000000..78b9e3f9c0d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/foo.h
@@ -0,0 +1,10 @@
+struct foo;
+
+struct sub_foo
+{
+ int sub_1;
+ char *sub_2;
+};
+
+LLDB_TEST_API struct foo *GetMeAFoo();
+LLDB_TEST_API struct sub_foo *GetMeASubFoo(struct foo *in_foo);
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/main.c
new file mode 100644
index 00000000000..b4377de18c1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib/main.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include "foo.h"
+
+int
+main ()
+{
+ struct foo *my_foo_ptr;
+ my_foo_ptr = GetMeAFoo();
+
+ printf ("My sub foo has: %d.\n", GetMeASubFoo(my_foo_ptr)->sub_1); // Set breakpoint 0 here.
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile
new file mode 100644
index 00000000000..f3285de39e0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile
@@ -0,0 +1,7 @@
+DYLIB_NAME := foo
+DYLIB_C_SOURCES := foo.c
+C_SOURCES := main.c
+
+SPLIT_DEBUG_SYMBOLS = YES
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
new file mode 100644
index 00000000000..8858f67cd18
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
@@ -0,0 +1,88 @@
+"""Test that types defined in shared libraries with stripped symbols work correctly."""
+
+
+
+import unittest2
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class SharedLibStrippedTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureAll(oslist=["windows"])
+ def test_expr(self):
+ """Test that types work when defined in a shared library and forwa/d-declared in the main executable"""
+ if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
+ self.skipTest(
+ "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
+
+ self.build()
+ self.common_setup()
+
+ # This should display correctly.
+ self.expect(
+ "expression --show-types -- *my_foo_ptr",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "(foo)",
+ "(sub_foo)",
+ "other_element = 3"])
+
+ @expectedFailureAll(oslist=["windows"])
+ @unittest2.expectedFailure("llvm.org/PR36712")
+ def test_frame_variable(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.build()
+ self.common_setup()
+
+ # This should display correctly.
+ self.expect(
+ "frame variable --show-types -- *my_foo_ptr",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ "(foo)",
+ "(sub_foo)",
+ "other_element = 3"])
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.source = 'main.c'
+ self.line = line_number(self.source, '// Set breakpoint 0 here.')
+ self.shlib_names = ["foo"]
+
+ def common_setup(self):
+ # Run in synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line(
+ self, self.source, self.line, num_expected_locations=1, loc_exact=True)
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ environment = self.registerSharedLibrariesWithTarget(
+ target, self.shlib_names)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs=[' resolved, hit count = 1'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.c
new file mode 100644
index 00000000000..6431bc496c3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.c
@@ -0,0 +1,22 @@
+#include "foo.h"
+#include <stdlib.h>
+
+struct foo
+{
+ struct sub_foo sub_element;
+ int other_element;
+};
+
+struct foo *
+GetMeAFoo()
+{
+ struct foo *ret_val = (struct foo *) malloc (sizeof (struct foo));
+ ret_val->other_element = 3;
+ return ret_val;
+}
+
+struct sub_foo *
+GetMeASubFoo (struct foo *in_foo)
+{
+ return &(in_foo->sub_element);
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.h b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.h
new file mode 100644
index 00000000000..78b3c124538
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/foo.h
@@ -0,0 +1,12 @@
+struct foo;
+
+struct sub_foo
+{
+ int sub_1;
+ char *sub_2;
+};
+
+struct foo *GetMeAFoo();
+struct sub_foo *GetMeASubFoo (struct foo *in_foo);
+
+
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/main.c
new file mode 100644
index 00000000000..b4377de18c1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/main.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include "foo.h"
+
+int
+main ()
+{
+ struct foo *my_foo_ptr;
+ my_foo_ptr = GetMeAFoo();
+
+ printf ("My sub foo has: %d.\n", GetMeASubFoo(my_foo_ptr)->sub_1); // Set breakpoint 0 here.
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories
new file mode 100644
index 00000000000..c00c25822e4
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories
@@ -0,0 +1 @@
+basic_process
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py
new file mode 100644
index 00000000000..7665b2f73b6
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py
@@ -0,0 +1,122 @@
+"""Test the 'step target' feature."""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestStepTarget(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers that we will step to in main:
+ self.main_source = "main.c"
+ self.end_line = line_number(self.main_source, "All done")
+
+ @add_test_categories(['pyapi'])
+ def get_to_start(self):
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ self.main_source_spec = lldb.SBFileSpec(self.main_source)
+
+ break_in_main = target.BreakpointCreateBySourceRegex(
+ 'Break here to try targetted stepping', self.main_source_spec)
+ self.assertTrue(break_in_main, VALID_BREAKPOINT)
+ self.assertGreater(break_in_main.GetNumLocations(), 0, "Has locations.")
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, break_in_main)
+
+ if len(threads) != 1:
+ self.fail("Failed to stop at first breakpoint in main.")
+
+ thread = threads[0]
+ return thread
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
+ def test_with_end_line(self):
+ """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+
+ thread = self.get_to_start()
+
+ error = lldb.SBError()
+ thread.StepInto("lotsOfArgs", self.end_line, error)
+ frame = thread.frames[0]
+
+ self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.")
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
+ def test_with_end_line_bad_name(self):
+ """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+
+ thread = self.get_to_start()
+
+ error = lldb.SBError()
+ thread.StepInto("lotsOfArgssss", self.end_line, error)
+ frame = thread.frames[0]
+ self.assertEqual(frame.line_entry.line, self.end_line,
+ "Stepped to the block end.")
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
+ def test_with_end_line_deeper(self):
+ """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+
+ thread = self.get_to_start()
+
+ error = lldb.SBError()
+ thread.StepInto("modifyInt", self.end_line, error)
+ frame = thread.frames[0]
+ self.assertEqual(frame.name, "modifyInt", "Stepped to modifyInt.")
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
+ def test_with_command_and_block(self):
+ """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+
+ thread = self.get_to_start()
+
+ result = lldb.SBCommandReturnObject()
+ self.dbg.GetCommandInterpreter().HandleCommand(
+ 'thread step-in -t "lotsOfArgs" -e block', result)
+ self.assertTrue(
+ result.Succeeded(),
+ "thread step-in command succeeded.")
+
+ frame = thread.frames[0]
+ self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.")
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
+ def test_with_command_and_block_and_bad_name(self):
+ """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+
+ thread = self.get_to_start()
+
+ result = lldb.SBCommandReturnObject()
+ self.dbg.GetCommandInterpreter().HandleCommand(
+ 'thread step-in -t "lotsOfArgsssss" -e block', result)
+ self.assertTrue(
+ result.Succeeded(),
+ "thread step-in command succeeded.")
+
+ frame = thread.frames[0]
+
+ self.assertEqual(frame.name, "main", "Stepped back out to main.")
+ # end_line is set to the line after the containing block. Check that
+ # we got there:
+ self.assertEqual(frame.line_entry.line, self.end_line,
+ "Got out of the block")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/main.c
new file mode 100644
index 00000000000..86a26c4d47a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/main.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+
+void
+lotsOfArgs
+(
+ int firstArg,
+ int secondArg,
+ int thirdArg,
+ int fourthArg
+)
+{
+ printf ("First: %d Second: %d Third: %d Fourth: %d.\n",
+ firstArg,
+ secondArg,
+ thirdArg,
+ fourthArg);
+}
+
+int
+modifyInt(int incoming)
+{
+ return incoming % 2;
+}
+
+int
+main (int argc, char **argv)
+{
+ if (argc > 0)
+ {
+ int var_makes_block = argc + 1;
+ printf ("Break here to try targetted stepping.\n");
+ lotsOfArgs(var_makes_block,
+ modifyInt(20),
+ 30,
+ modifyInt(40));
+ printf ("Done calling lotsOfArgs.");
+ }
+ printf ("All done.\n");
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/Makefile
new file mode 100644
index 00000000000..4b3467bc4e8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := locking.cpp
+CXXFLAGS_EXTRAS := -std=c++11
+ENABLE_THREADS := YES
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/TestStepOverDoesntBlock.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/TestStepOverDoesntBlock.py
new file mode 100644
index 00000000000..988d90a7bb3
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/TestStepOverDoesntBlock.py
@@ -0,0 +1,30 @@
+"""
+Test that step over will let other threads run when necessary
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class StepOverDoesntDeadlockTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_step_over(self):
+ """Test that when step over steps over a function it lets other threads run."""
+ self.build()
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+ "without running the first thread at least somewhat",
+ lldb.SBFileSpec("locking.cpp"))
+ # This is just testing that the step over actually completes.
+ # If the test fails this step never return, so failure is really
+ # signaled by the test timing out.
+
+ thread.StepOver()
+ state = process.GetState()
+ self.assertEqual(state, lldb.eStateStopped)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/locking.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/locking.cpp
new file mode 100644
index 00000000000..8288a668fe8
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step_over_no_deadlock/locking.cpp
@@ -0,0 +1,78 @@
+#include <stdio.h>
+#include <thread>
+#include <mutex>
+#include <condition_variable>
+
+std::mutex contended_mutex;
+
+std::mutex control_mutex;
+std::condition_variable control_condition;
+
+std::mutex thread_started_mutex;
+std::condition_variable thread_started_condition;
+
+// This function runs in a thread. The locking dance is to make sure that
+// by the time the main thread reaches the pthread_join below, this thread
+// has for sure acquired the contended_mutex. So then the call_me_to_get_lock
+// function will block trying to get the mutex, and only succeed once it
+// signals this thread, then lets it run to wake up from the cond_wait and
+// release the mutex.
+
+void
+lock_acquirer_1 (void)
+{
+ std::unique_lock<std::mutex> contended_lock(contended_mutex);
+
+ // Grab this mutex, that will ensure that the main thread
+ // is in its cond_wait for it (since that's when it drops the mutex.
+
+ thread_started_mutex.lock();
+ thread_started_mutex.unlock();
+
+ // Now signal the main thread that it can continue, we have the contended lock
+ // so the call to call_me_to_get_lock won't make any progress till this
+ // thread gets a chance to run.
+
+ std::unique_lock<std::mutex> control_lock(control_mutex);
+
+ thread_started_condition.notify_all();
+
+ control_condition.wait(control_lock);
+
+}
+
+int
+call_me_to_get_lock (int ret_val)
+{
+ control_condition.notify_all();
+ contended_mutex.lock();
+ return ret_val;
+}
+
+int
+get_int() {
+ return 567;
+}
+
+int main ()
+{
+ std::unique_lock<std::mutex> thread_started_lock(thread_started_mutex);
+
+ std::thread thread_1(lock_acquirer_1);
+
+ thread_started_condition.wait(thread_started_lock);
+
+ control_mutex.lock();
+ control_mutex.unlock();
+
+ // Break here. At this point the other thread will have the contended_mutex,
+ // and be sitting in its cond_wait for the control condition. So there is
+ // no way that our by-hand calling of call_me_to_get_lock will proceed
+ // without running the first thread at least somewhat.
+
+ int result = call_me_to_get_lock(get_int());
+ thread_1.join();
+
+ return 0;
+
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py
new file mode 100644
index 00000000000..c20e443b683
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py
@@ -0,0 +1,296 @@
+"""Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCStepping(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers that we will step to in main:
+ self.main_source = "main.c"
+
+ @add_test_categories(['pyapi', 'basic_process'])
+ @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17932')
+ @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr14437")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24777")
+ @expectedFailureNetBSD
+ def test_and_python_api(self):
+ """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ self.main_source_spec = lldb.SBFileSpec(self.main_source)
+
+ breakpoints_to_disable = []
+
+ break_1_in_main = target.BreakpointCreateBySourceRegex(
+ '// frame select 2, thread step-out while stopped at .c.1..',
+ self.main_source_spec)
+ self.assertTrue(break_1_in_main, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break_1_in_main)
+
+ break_in_a = target.BreakpointCreateBySourceRegex(
+ '// break here to stop in a before calling b', self.main_source_spec)
+ self.assertTrue(break_in_a, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break_in_a)
+
+ break_in_b = target.BreakpointCreateBySourceRegex(
+ '// thread step-out while stopped at .c.2..', self.main_source_spec)
+ self.assertTrue(break_in_b, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break_in_b)
+
+ break_in_c = target.BreakpointCreateBySourceRegex(
+ '// Find the line number of function .c. here.', self.main_source_spec)
+ self.assertTrue(break_in_c, VALID_BREAKPOINT)
+ breakpoints_to_disable.append(break_in_c)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, break_1_in_main)
+
+ if len(threads) != 1:
+ self.fail("Failed to stop at first breakpoint in main.")
+
+ thread = threads[0]
+
+ # Get the stop id and for fun make sure it increases:
+ old_stop_id = process.GetStopID()
+
+ # Now step over, which should cause us to hit the breakpoint in "a"
+ thread.StepOver()
+
+ # The stop reason of the thread should be breakpoint.
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, break_in_a)
+ if len(threads) != 1:
+ self.fail("Failed to stop at breakpoint in a.")
+
+ # Check that the stop ID increases:
+ new_stop_id = process.GetStopID()
+ self.assertTrue(
+ new_stop_id > old_stop_id,
+ "Stop ID increases monotonically.")
+
+ thread = threads[0]
+
+ # Step over, and we should hit the breakpoint in b:
+ thread.StepOver()
+
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, break_in_b)
+ if len(threads) != 1:
+ self.fail("Failed to stop at breakpoint in b.")
+ thread = threads[0]
+
+ # Now try running some function, and make sure that we still end up in the same place
+ # and with the same stop reason.
+ frame = thread.GetFrameAtIndex(0)
+ current_line = frame.GetLineEntry().GetLine()
+ current_file = frame.GetLineEntry().GetFileSpec()
+ current_bp = []
+ current_bp.append(thread.GetStopReasonDataAtIndex(0))
+ current_bp.append(thread.GetStopReasonDataAtIndex(1))
+
+ stop_id_before_expression = process.GetStopID()
+ stop_id_before_including_expressions = process.GetStopID(True)
+
+ frame.EvaluateExpression("(int) printf (print_string)")
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(
+ current_line == frame.GetLineEntry().GetLine(),
+ "The line stayed the same after expression.")
+ self.assertTrue(
+ current_file == frame.GetLineEntry().GetFileSpec(),
+ "The file stayed the same after expression.")
+ self.assertTrue(
+ thread.GetStopReason() == lldb.eStopReasonBreakpoint,
+ "We still say we stopped for a breakpoint.")
+ self.assertTrue(thread.GetStopReasonDataAtIndex(0) == current_bp[
+ 0] and thread.GetStopReasonDataAtIndex(1) == current_bp[1], "And it is the same breakpoint.")
+
+ # Also make sure running the expression didn't change the public stop id
+ # but did change if we are asking for expression stops as well.
+ stop_id_after_expression = process.GetStopID()
+ stop_id_after_including_expressions = process.GetStopID(True)
+
+ self.assertTrue(
+ stop_id_before_expression == stop_id_after_expression,
+ "Expression calling doesn't change stop ID")
+
+ self.assertTrue(
+ stop_id_after_including_expressions > stop_id_before_including_expressions,
+ "Stop ID including expressions increments over expression call.")
+
+ # Do the same thing with an expression that's going to crash, and make
+ # sure we are still unchanged.
+
+ frame.EvaluateExpression("((char *) 0)[0] = 'a'")
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(
+ current_line == frame.GetLineEntry().GetLine(),
+ "The line stayed the same after expression.")
+ self.assertTrue(
+ current_file == frame.GetLineEntry().GetFileSpec(),
+ "The file stayed the same after expression.")
+ self.assertTrue(
+ thread.GetStopReason() == lldb.eStopReasonBreakpoint,
+ "We still say we stopped for a breakpoint.")
+ self.assertTrue(thread.GetStopReasonDataAtIndex(0) == current_bp[
+ 0] and thread.GetStopReasonDataAtIndex(1) == current_bp[1], "And it is the same breakpoint.")
+
+ # Now continue and make sure we just complete the step:
+ # Disable all our breakpoints first - sometimes the compiler puts two line table entries in for the
+ # breakpoint a "b" and we don't want to hit that.
+ for bkpt in breakpoints_to_disable:
+ bkpt.SetEnabled(False)
+
+ process.Continue()
+
+ self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "a")
+ self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete)
+
+ # And one more time should get us back to main:
+ process.Continue()
+
+ self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "main")
+ self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete)
+
+ # Now make sure we can call a function, break in the called function,
+ # then have "continue" get us back out again:
+ frame = thread.GetFrameAtIndex(0)
+ frame = thread.GetFrameAtIndex(0)
+ current_line = frame.GetLineEntry().GetLine()
+ current_file = frame.GetLineEntry().GetFileSpec()
+
+ break_in_b.SetEnabled(True)
+ options = lldb.SBExpressionOptions()
+ options.SetIgnoreBreakpoints(False)
+ options.SetFetchDynamicValue(False)
+ options.SetUnwindOnError(False)
+ frame.EvaluateExpression("b (4)", options)
+
+ threads = lldbutil.get_threads_stopped_at_breakpoint(
+ process, break_in_b)
+
+ if len(threads) != 1:
+ self.fail("Failed to stop at breakpoint in b when calling b.")
+ thread = threads[0]
+
+ # So do a step over here to make sure we can still do that:
+
+ thread.StepOver()
+
+ # See that we are still in b:
+ func_name = thread.GetFrameAtIndex(0).GetFunctionName()
+ self.assertTrue(
+ func_name == "b",
+ "Should be in 'b', were in %s" %
+ (func_name))
+
+ # Okay, now if we continue, we will finish off our function call and we
+ # should end up back in "a" as if nothing had happened:
+ process.Continue()
+
+ self.assertTrue(thread.GetFrameAtIndex(
+ 0).GetLineEntry().GetLine() == current_line)
+ self.assertTrue(thread.GetFrameAtIndex(
+ 0).GetLineEntry().GetFileSpec() == current_file)
+
+ # Now we are going to test step in targeting a function:
+
+ break_in_b.SetEnabled(False)
+
+ break_before_complex_1 = target.BreakpointCreateBySourceRegex(
+ '// Stop here to try step in targeting b.', self.main_source_spec)
+ self.assertTrue(break_before_complex_1, VALID_BREAKPOINT)
+
+ break_before_complex_2 = target.BreakpointCreateBySourceRegex(
+ '// Stop here to try step in targeting complex.', self.main_source_spec)
+ self.assertTrue(break_before_complex_2, VALID_BREAKPOINT)
+
+ break_before_complex_3 = target.BreakpointCreateBySourceRegex(
+ '// Stop here to step targeting b and hitting breakpoint.', self.main_source_spec)
+ self.assertTrue(break_before_complex_3, VALID_BREAKPOINT)
+
+ break_before_complex_4 = target.BreakpointCreateBySourceRegex(
+ '// Stop here to make sure bogus target steps over.', self.main_source_spec)
+ self.assertTrue(break_before_complex_4, VALID_BREAKPOINT)
+
+ threads = lldbutil.continue_to_breakpoint(
+ process, break_before_complex_1)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+ break_before_complex_1.SetEnabled(False)
+
+ thread.StepInto("b")
+ self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "b")
+
+ # Now continue out and stop at the next call to complex. This time
+ # step all the way into complex:
+ threads = lldbutil.continue_to_breakpoint(
+ process, break_before_complex_2)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+ break_before_complex_2.SetEnabled(False)
+
+ thread.StepInto("complex")
+ self.assertTrue(thread.GetFrameAtIndex(
+ 0).GetFunctionName() == "complex")
+
+ # Now continue out and stop at the next call to complex. This time
+ # enable breakpoints in a and c and then step targeting b:
+ threads = lldbutil.continue_to_breakpoint(
+ process, break_before_complex_3)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+ break_before_complex_3.SetEnabled(False)
+
+ break_at_start_of_a = target.BreakpointCreateByName('a')
+ break_at_start_of_c = target.BreakpointCreateByName('c')
+
+ thread.StepInto("b")
+ threads = lldbutil.get_stopped_threads(
+ process, lldb.eStopReasonBreakpoint)
+
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+ stop_break_id = thread.GetStopReasonDataAtIndex(0)
+ self.assertTrue(stop_break_id == break_at_start_of_a.GetID()
+ or stop_break_id == break_at_start_of_c.GetID())
+
+ break_at_start_of_a.SetEnabled(False)
+ break_at_start_of_c.SetEnabled(False)
+
+ process.Continue()
+ self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "b")
+
+ # Now continue out and stop at the next call to complex. This time
+ # enable breakpoints in a and c and then step targeting b:
+ threads = lldbutil.continue_to_breakpoint(
+ process, break_before_complex_4)
+ self.assertTrue(len(threads) == 1)
+ thread = threads[0]
+ break_before_complex_4.SetEnabled(False)
+
+ thread.StepInto("NoSuchFunction")
+ self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "main")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py
new file mode 100644
index 00000000000..43ed10d8b1a
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py
@@ -0,0 +1,83 @@
+"""
+Test thread stepping features in combination with frame select.
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadSteppingTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to of function 'c'.
+ self.line1 = line_number(
+ 'main.c', '// Find the line number of function "c" here.')
+ self.line2 = line_number(
+ 'main.c', '// frame select 2, thread step-out while stopped at "c(1)"')
+ self.line3 = line_number(
+ 'main.c', '// thread step-out while stopped at "c(2)"')
+ self.line4 = line_number(
+ 'main.c', '// frame select 1, thread step-out while stopped at "c(3)"')
+
+ def test_step_out_with_run_command(self):
+ """Exercise thread step-out and frame select followed by thread step-out."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Create a breakpoint inside function 'c'.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line1, num_expected_locations=1, loc_exact=True)
+
+ # Now run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The process should be stopped at this point.
+ self.expect("process status", PROCESS_STOPPED,
+ patterns=['Process .* stopped'])
+
+ # The frame #0 should correspond to main.c:32, the executable statement
+ # in function name 'c'. And frame #3 should point to main.c:37.
+ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=["stop reason = breakpoint"],
+ patterns=["frame #0.*main.c:%d" % self.line1,
+ "frame #3.*main.c:%d" % self.line2])
+
+ # We want to move the pc to frame #3. This can be accomplished by
+ # 'frame select 2', followed by 'thread step-out'.
+ self.runCmd("frame select 2")
+ self.runCmd("thread step-out")
+ self.expect("thread backtrace", STEP_OUT_SUCCEEDED,
+ substrs=["stop reason = step out"],
+ patterns=["frame #0.*main.c:%d" % self.line2])
+
+ # Let's move on to a single step-out case.
+ self.runCmd("process continue")
+
+ # The process should be stopped at this point.
+ self.expect("process status", PROCESS_STOPPED,
+ patterns=['Process .* stopped'])
+ self.runCmd("thread step-out")
+ self.expect("thread backtrace", STEP_OUT_SUCCEEDED,
+ substrs=["stop reason = step out"],
+ patterns=["frame #0.*main.c:%d" % self.line3])
+
+ # Do another frame selct, followed by thread step-out.
+ self.runCmd("process continue")
+
+ # The process should be stopped at this point.
+ self.expect("process status", PROCESS_STOPPED,
+ patterns=['Process .* stopped'])
+ self.runCmd("frame select 1")
+ self.runCmd("thread step-out")
+ self.expect("thread backtrace", STEP_OUT_SUCCEEDED,
+ substrs=["stop reason = step out"],
+ patterns=["frame #0.*main.c:%d" % self.line4])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/main.c
new file mode 100644
index 00000000000..fce61bfd93e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/stepping/main.c
@@ -0,0 +1,68 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+int a(int);
+int b(int);
+int c(int);
+const char *print_string = "aaaaaaaaaa\n";
+
+int a(int val)
+{
+ int return_value = val; // basic break at the start of b
+
+ if (val <= 1)
+ {
+ return_value = b(val); // break here to stop in a before calling b
+ }
+ else if (val >= 3)
+ {
+ return_value = c(val);
+ }
+
+ return return_value;
+}
+
+int b(int val)
+{
+ int rc = c(val); // thread step-out while stopped at "c(2)"
+ return rc;
+}
+
+int c(int val)
+{
+ return val + 3; // Find the line number of function "c" here.
+}
+
+int complex (int first, int second, int third)
+{
+ return first + second + third; // Step in targeting complex should stop here
+}
+
+int main (int argc, char const *argv[])
+{
+ int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
+ printf("a(1) returns %d\n", A1);
+
+ int B2 = b(2);
+ printf("b(2) returns %d\n", B2);
+
+ int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
+ printf("a(3) returns %d\n", A3);
+
+ int A4 = complex (a(1), b(2), c(3)); // Stop here to try step in targeting b.
+
+ int A5 = complex (a(2), b(3), c(4)); // Stop here to try step in targeting complex.
+
+ int A6 = complex (a(4), b(5), c(6)); // Stop here to step targeting b and hitting breakpoint.
+
+ int A7 = complex (a(5), b(6), c(7)); // Stop here to make sure bogus target steps over.
+
+ printf ("I am using print_string: %s.\n", print_string);
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
new file mode 100644
index 00000000000..597a247178e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
@@ -0,0 +1,56 @@
+"""
+Tests that C strings work as expected in expressions
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CStringsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_with_run_command(self):
+ """Tests that C strings work as expected in expressions"""
+ self.build()
+ self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+
+ line = line_number('main.c', '// breakpoint 1')
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("process launch", RUN_SUCCEEDED)
+
+ self.expect("expression -- a[2]",
+ patterns=["\((const )?char\) \$0 = 'c'"])
+
+ self.expect("expression -- z[2]",
+ startstr="(const char) $1 = 'x'")
+
+ # On Linux, the expression below will test GNU indirect function calls.
+ self.expect("expression -- (int)strlen(\"hello\")",
+ startstr="(int) $2 = 5")
+
+ self.expect("expression -- \"world\"[2]",
+ startstr="(const char) $3 = 'r'")
+
+ self.expect("expression -- \"\"[0]",
+ startstr="(const char) $4 = '\\0'")
+
+ self.expect("expr --raw -- \"hello\"",
+ substrs=['[0] = \'h\'',
+ '[5] = \'\\0\''])
+
+ self.expect("p \"hello\"",
+ substrs=['[6]) $', 'hello'])
+
+ self.expect("p (char*)\"hello\"",
+ substrs=['(char *) $', ' = 0x',
+ 'hello'])
+
+ self.expect("p (int)strlen(\"\")",
+ substrs=['(int) $', ' = 0'])
+
+ self.expect("expression !z",
+ substrs=['false'])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/main.c
new file mode 100644
index 00000000000..3e7ead08478
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/strings/main.c
@@ -0,0 +1,17 @@
+//===-- main.c ----------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+int main()
+{
+ const char a[] = "abcde";
+ const char *z = "vwxyz";
+
+ printf("%s %s", a, z); // breakpoint 1
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py
new file mode 100644
index 00000000000..c8308c16011
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals())
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/main.c
new file mode 100644
index 00000000000..356f139c0b2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/struct_types/main.c
@@ -0,0 +1,46 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+struct things_to_sum {
+ int a;
+ int b;
+ int c;
+};
+
+int sum_things(struct things_to_sum tts)
+{
+ return tts.a + tts.b + tts.c;
+}
+
+int main (int argc, char const *argv[])
+{
+ struct point_tag {
+ int x;
+ int y;
+ char padding[0];
+ }; //% self.expect("frame variable pt.padding[0]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[0] = "])
+ //% self.expect("frame variable pt.padding[1]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[1] = "])
+ //% self.expect("expression -- (pt.padding[0])", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["(char)", " = "])
+ //% self.expect("image lookup -t point_tag", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['padding[]'])
+
+ struct {} empty;
+ //% self.expect("frame variable empty", substrs = ["empty = {}"])
+ //% self.expect("expression -- sizeof(empty)", substrs = ["= 0"])
+
+ struct rect_tag {
+ struct point_tag bottom_left;
+ struct point_tag top_right;
+ };
+ struct point_tag pt = { 2, 3, {} };
+ struct rect_tag rect = {{1, 2, {}}, {3, 4, {}}};
+ struct things_to_sum tts = { 2, 3, 4 };
+
+ int sum = sum_things(tts); //% self.expect("expression -- &pt == (struct point_tag*)0", substrs = ['false'])
+ //% self.expect("expression -- sum_things(tts)", substrs = ['9'])
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile
new file mode 100644
index 00000000000..b26ce5c8b14
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile
@@ -0,0 +1,8 @@
+C_SOURCES := main.c
+
+DYLIB_NAME := a
+DYLIB_C_SOURCES := a.c
+
+ENABLE_THREADS := YES
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py
new file mode 100644
index 00000000000..b1fd2b8d031
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py
@@ -0,0 +1,95 @@
+"""Test that thread-local storage can be read correctly."""
+
+
+
+import unittest2
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TlsGlobalTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ if self.getPlatform() == "freebsd" or self.getPlatform() == "linux":
+ # LD_LIBRARY_PATH must be set so the shared libraries are found on
+ # startup
+ if "LD_LIBRARY_PATH" in os.environ:
+ self.runCmd(
+ "settings set target.env-vars " +
+ self.dylibPath +
+ "=" +
+ os.environ["LD_LIBRARY_PATH"] +
+ ":" +
+ self.getBuildDir())
+ else:
+ self.runCmd("settings set target.env-vars " +
+ self.dylibPath + "=" + self.getBuildDir())
+ self.addTearDownHook(
+ lambda: self.runCmd(
+ "settings remove target.env-vars " +
+ self.dylibPath))
+
+ # TLS works differently on Windows, this would need to be implemented
+ # separately.
+ @skipIfWindows
+ @expectedFailureAll(
+ bugnumber="llvm.org/pr28392",
+ oslist=no_match(
+ lldbplatformutil.getDarwinOSTriples()))
+ def test(self):
+ """Test thread-local storage."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ target = self.dbg.CreateTarget(exe)
+ if self.platformIsDarwin():
+ self.registerSharedLibrariesWithTarget(target, ['liba.dylib'])
+
+ line1 = line_number('main.c', '// thread breakpoint')
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", line1, num_expected_locations=1, loc_exact=True)
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.runCmd("process status", "Get process status")
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # BUG: sometimes lldb doesn't change threads to the stopped thread.
+ # (unrelated to this test).
+ self.runCmd("thread select 2", "Change thread")
+
+ # Check that TLS evaluates correctly within the thread.
+ self.expect("expr var_static", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=["\(int\) \$.* = 88"])
+ self.expect("expr var_shared", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=["\(int\) \$.* = 66"])
+
+ # Continue on the main thread
+ line2 = line_number('main.c', '// main breakpoint')
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", line2, num_expected_locations=1, loc_exact=True)
+ self.runCmd("continue", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.runCmd("process status", "Get process status")
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # BUG: sometimes lldb doesn't change threads to the stopped thread.
+ # (unrelated to this test).
+ self.runCmd("thread select 1", "Change thread")
+
+ # Check that TLS evaluates correctly within the main thread.
+ self.expect("expr var_static", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=["\(int\) \$.* = 44"])
+ self.expect("expr var_shared", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns=["\(int\) \$.* = 33"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c
new file mode 100644
index 00000000000..00803964e61
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c
@@ -0,0 +1,23 @@
+//===-- a.c -----------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <unistd.h>
+
+__thread int var_shared = 33;
+
+int
+touch_shared()
+{
+ return var_shared;
+}
+
+void shared_check()
+{
+ var_shared *= 2;
+ usleep(1); // shared thread breakpoint
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c
new file mode 100644
index 00000000000..c9c1e681dc0
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c
@@ -0,0 +1,41 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+#include <pthread.h>
+#include <unistd.h>
+
+void shared_check();
+// On some OS's (darwin) you must actually access a thread local variable
+// before you can read it
+int
+touch_shared();
+
+// Create some TLS storage within the static executable.
+__thread int var_static = 44;
+
+void *fn_static(void *param)
+{
+ var_static *= 2;
+ shared_check();
+ usleep(1); // thread breakpoint
+ for(;;)
+ usleep(1);
+}
+
+int main (int argc, char const *argv[])
+{
+ pthread_t handle;
+ pthread_create(&handle, NULL, &fn_static, NULL);
+ touch_shared();
+ for (; var_static;)
+ {
+ usleep(1); // main breakpoint
+ }
+
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py
new file mode 100644
index 00000000000..cbbb6362381
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py
@@ -0,0 +1,52 @@
+"""Look up type information for typedefs of same name at different lexical scope and check for correct display."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TypedefTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureAll(compiler="clang", bugnumber="llvm.org/pr19238")
+ @expectedFailureAll(
+ oslist=["freebsd"],
+ bugnumber="llvm.org/pr25626 expectedFailureClang fails on FreeBSD")
+ def test_typedef(self):
+ """Test 'image lookup -t a' and check for correct display at different scopes."""
+ self.build()
+ self.image_lookup_for_multiple_typedefs()
+
+ def image_lookup_for_multiple_typedefs(self):
+ """Test 'image lookup -t a' at different scopes and check for correct display."""
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+ typearray = (
+ "float",
+ "float",
+ "char",
+ "double *",
+ "float",
+ "int",
+ "double",
+ "float",
+ "float")
+ arraylen = len(typearray) + 1
+ for i in range(1, arraylen):
+ loc_line = line_number(
+ 'main.c', '// Set break point ' + str(i) + '.')
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", loc_line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ for t in typearray:
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+ self.expect("image lookup -t a", DATA_TYPES_DISPLAYED_CORRECTLY,
+ substrs=['name = "' + t + '"'])
+ self.runCmd("continue")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/main.c
new file mode 100644
index 00000000000..467612e9b37
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/typedef/main.c
@@ -0,0 +1,45 @@
+//===-- main.c --------------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+void test()
+{
+ typedef double * a;
+ a b = 0; // Set break point 4.
+}
+int main (int argc, char const *argv[])
+{
+ typedef float a;
+ int i = 0; // Set break point 1.
+ i++;
+ a floatvariable = 2.7; // Set break point 2.
+ {
+ typedef char a;
+ i++;
+ a charvariable = 'a'; // Set break point 3.
+ test();
+ }
+ {
+ int c = 0;
+ c++; // Set break point 5.
+ for(i = 0 ; i < 1 ; i++)
+ {
+ typedef int a;
+ a b;
+ b = 7; // Set break point 6.
+ }
+ for(i = 0 ; i < 1 ; i++)
+ {
+ typedef double a;
+ a b;
+ b = 3.14; // Set break point 7.
+ }
+ c = 1; // Set break point 8.
+ }
+ floatvariable = 2.5;
+ floatvariable = 2.8; // Set break point 9.
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/Makefile
new file mode 100644
index 00000000000..a40a666476c
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/Makefile
@@ -0,0 +1,4 @@
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -finput-charset=UTF-8 -fextended-identifiers -std=c99
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py
new file mode 100644
index 00000000000..9eb25e4d105
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py
@@ -0,0 +1,21 @@
+# coding=utf8
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+
+
+class TestUnicodeSymbols(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIf(compiler="clang", compiler_version=['<', '7.0'])
+ def test_union_members(self):
+ self.build()
+ spec = lldb.SBModuleSpec()
+ spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact("a.out")))
+ module = lldb.SBModule(spec)
+ self.assertTrue(module.IsValid())
+ mytype = module.FindFirstType("foobár")
+ self.assertTrue(mytype.IsValid())
+ self.assertTrue(mytype.IsPointerType())
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/main.c
new file mode 100644
index 00000000000..ae44dd0edfa
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unicode/main.c
@@ -0,0 +1,5 @@
+typedef void *foob\u00E1r;
+foob\u00E1r X = 0;
+int main() {
+ return (long)X;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/Makefile
new file mode 100644
index 00000000000..10495940055
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py
new file mode 100644
index 00000000000..4965df2d809
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py
@@ -0,0 +1,52 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestUnionMembers(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_union_members(self):
+ self._load_exe()
+
+ # Set breakpoints
+ bp = self.target.BreakpointCreateBySourceRegex(
+ "Break here", self.src_file_spec)
+ self.assertTrue(
+ bp.IsValid() and bp.GetNumLocations() >= 1,
+ VALID_BREAKPOINT)
+
+ # Launch the process
+ self.process = self.target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(
+ self.process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ thread = lldbutil.get_stopped_thread(
+ self.process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(thread.IsValid())
+ frame = thread.GetSelectedFrame()
+ self.assertTrue(frame.IsValid())
+
+ val = frame.EvaluateExpression("u")
+ self.assertTrue(val.IsValid())
+ val = frame.EvaluateExpression("u.s")
+ self.assertTrue(val.IsValid())
+ self.assertEqual(val.GetNumChildren(), 2)
+
+ def _load_exe(self):
+ self.build()
+
+ src_file = os.path.join(self.getSourceDir(), "main.c")
+ self.src_file_spec = lldb.SBFileSpec(src_file)
+ self.assertTrue(self.src_file_spec.IsValid(), "breakpoint file")
+
+ # Get the path of the executable
+ exe_path = self.getBuildArtifact("a.out")
+
+ # Load the executable
+ self.target = self.dbg.CreateTarget(exe_path)
+ self.assertTrue(self.target.IsValid(), VALID_TARGET)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/main.c
new file mode 100644
index 00000000000..2c6a7d1e782
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/unions/main.c
@@ -0,0 +1,18 @@
+#include <stdint.h>
+
+union S
+{
+ int32_t n; // occupies 4 bytes
+ uint16_t s[2]; // occupies 4 bytes
+ uint8_t c; // occupies 1 byte
+}; // the whole union occupies 4 bytes
+
+int main()
+{
+ union S u;
+
+ u.s[0] = 1234;
+ u.s[1] = 4321;
+
+ return 0; // Break here
+}
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);
+}