summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
commit94994d372d014ce4c8758b9605d63fae651bd8aa (patch)
tree51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /packages/Python/lldbsuite/test/lang/c
parent39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/c')
-rw-r--r--packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py1
-rw-r--r--packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py32
-rw-r--r--packages/Python/lldbsuite/test/lang/c/bitfields/main.c15
-rw-r--r--packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py1
-rw-r--r--packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py10
-rw-r--r--packages/Python/lldbsuite/test/lang/c/local_variables/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/lang/c/local_variables/TestLocalVariables.py55
-rw-r--r--packages/Python/lldbsuite/test/lang/c/local_variables/main.c19
-rw-r--r--packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py2
-rw-r--r--packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py1
-rw-r--r--packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py1
-rw-r--r--packages/Python/lldbsuite/test/lang/c/vla/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py27
-rw-r--r--packages/Python/lldbsuite/test/lang/c/vla/main.c15
15 files changed, 182 insertions, 14 deletions
diff --git a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
index 930a09412eab..e3ae93d3a5ba 100644
--- a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
+++ b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
@@ -70,7 +70,6 @@ class AnonymousTestCase(TestBase):
self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["(type_y) $", "dummy = 2"])
- @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21550")
def test_expr_null(self):
self.build()
self.common_setup(self.line2)
diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
index 22b8a2991001..ba924683ad75 100644
--- a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
+++ b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
@@ -116,6 +116,38 @@ class BitfieldsTestCase(TestBase):
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\'',
+ ])
+
+
@add_test_categories(['pyapi'])
# BitFields exhibit crashes in record layout on Windows
# (http://llvm.org/pr21800)
diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/main.c b/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
index 236c926d81bd..fe972dbbe856 100644
--- a/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
+++ b/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <stdio.h>
+#include <string.h>
int main (int argc, char const *argv[])
{
@@ -63,6 +64,20 @@ int main (int argc, char const *argv[])
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
{
diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
index fa14e5ef62e6..b0fde47a2c0b 100644
--- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
+++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
@@ -93,6 +93,7 @@ class TestConflictingSymbols(TestBase):
"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")
diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py b/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
index 576e9ecd52ad..311c5ec8e120 100644
--- a/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
+++ b/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
@@ -3,9 +3,7 @@ from lldbsuite.test import decorators
lldbinline.MakeInlineTest(__file__,
globals(),
- [decorators.expectedFailureAll(oslist=["windows"],
- bugnumber="llvm.org/pr27845"),
- decorators.expectedFailureAll(compiler="clang",
- compiler_version=["<",
- "3.5"],
- bugnumber="llvm.org/pr27845")])
+ [decorators.expectedFailureAll(compiler="clang",
+ compiler_version=["<",
+ "3.5"],
+ bugnumber="llvm.org/pr27845")])
diff --git a/packages/Python/lldbsuite/test/lang/c/local_variables/Makefile b/packages/Python/lldbsuite/test/lang/c/local_variables/Makefile
new file mode 100644
index 000000000000..fd7201886586
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/local_variables/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+CFLAGS_EXTRAS += -O1
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/local_variables/TestLocalVariables.py b/packages/Python/lldbsuite/test/lang/c/local_variables/TestLocalVariables.py
new file mode 100644
index 000000000000..7071b675f3bc
--- /dev/null
+++ b/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 __future__ import print_function
+
+
+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.')
+
+ 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/packages/Python/lldbsuite/test/lang/c/local_variables/main.c b/packages/Python/lldbsuite/test/lang/c/local_variables/main.c
new file mode 100644
index 000000000000..2ab579a71a75
--- /dev/null
+++ b/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/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py b/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py
index f53a19138356..d1595163f6e3 100644
--- a/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py
+++ b/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py
@@ -35,12 +35,10 @@ class SharedLibTestCase(TestBase):
"expression GetMeASubFoo(my_foo_ptr)",
startstr="(sub_foo *) $")
- @expectedFailureAll(oslist=["windows"])
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)
- @expectedFailureAll(oslist=["windows"])
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)
diff --git a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
index b1c8a5ecf4bf..597a247178e4 100644
--- a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
+++ b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
@@ -11,7 +11,6 @@ class CStringsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
def test_with_run_command(self):
"""Tests that C strings work as expected in expressions"""
self.build()
diff --git a/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py b/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py
index af362f5be5d7..c8308c16011e 100644
--- a/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py
+++ b/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py
@@ -1,7 +1,4 @@
from lldbsuite.test import lldbinline
from lldbsuite.test import decorators
-lldbinline.MakeInlineTest(
- __file__, globals(), [
- decorators.expectedFailureAll(
- oslist=["windows"], bugnumber="llvm.org/pr24764")])
+lldbinline.MakeInlineTest(__file__, globals())
diff --git a/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py b/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py
index b2c9bbb83c0f..9eb25e4d1050 100644
--- a/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py
+++ b/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py
@@ -9,6 +9,7 @@ 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()
diff --git a/packages/Python/lldbsuite/test/lang/c/vla/Makefile b/packages/Python/lldbsuite/test/lang/c/vla/Makefile
new file mode 100644
index 000000000000..b09a579159d4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/vla/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py b/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py
new file mode 100644
index 000000000000..f6341ec24fa6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py
@@ -0,0 +1,27 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestVLA(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @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("frame var 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/packages/Python/lldbsuite/test/lang/c/vla/main.c b/packages/Python/lldbsuite/test/lang/c/vla/main.c
new file mode 100644
index 000000000000..ba9cc1855607
--- /dev/null
+++ b/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);
+}