summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
commitf3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch)
tree48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /packages/Python/lldbsuite/test/lang/c
parent2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/c')
-rw-r--r--packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py20
-rw-r--r--packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py12
-rw-r--r--packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py21
-rw-r--r--packages/Python/lldbsuite/test/lang/c/bitfields/main.c14
-rw-r--r--packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py18
-rw-r--r--packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py7
-rw-r--r--packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py17
-rw-r--r--packages/Python/lldbsuite/test/lang/c/enum_types/main.c11
-rw-r--r--packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py7
-rw-r--r--packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/inlines/inlines.c53
-rw-r--r--packages/Python/lldbsuite/test/lang/c/inlines/inlines.h4
-rw-r--r--packages/Python/lldbsuite/test/lang/c/inlines/main.c19
-rw-r--r--packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py17
-rw-r--r--packages/Python/lldbsuite/test/lang/c/register_variables/Makefile2
-rw-r--r--packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py150
-rw-r--r--packages/Python/lldbsuite/test/lang/c/register_variables/test.c12
-rw-r--r--packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py4
-rw-r--r--packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py7
-rw-r--r--packages/Python/lldbsuite/test/lang/c/step-target/Makefile (renamed from packages/Python/lldbsuite/test/lang/c/inlines/Makefile)2
-rw-r--r--packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py113
-rw-r--r--packages/Python/lldbsuite/test/lang/c/step-target/main.c40
-rw-r--r--packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py16
-rw-r--r--packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py6
-rw-r--r--packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/tls_globals/a.c6
-rw-r--r--packages/Python/lldbsuite/test/lang/c/tls_globals/main.c14
-rw-r--r--packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py7
-rw-r--r--packages/Python/lldbsuite/test/lang/c/unions/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py46
-rw-r--r--packages/Python/lldbsuite/test/lang/c/unions/main.c18
33 files changed, 546 insertions, 142 deletions
diff --git a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
index 7cb66ba8238bd..e6f1092c702a0 100644
--- a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
+++ b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py
@@ -6,14 +6,15 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class AnonymousTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfIcc # llvm.org/pr15036: LLDB generates an incorrect AST layout for an anonymous struct when DWARF is generated by ICC
+ @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)
@@ -36,7 +37,7 @@ class AnonymousTestCase(TestBase):
self.expect("expression c->grandchild.b", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["= 2"])
- @skipIfIcc # llvm.org/pr15036: This particular regression was introduced by r181498
+ @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)
@@ -61,7 +62,7 @@ class AnonymousTestCase(TestBase):
self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["(type_y) $", "dummy = 2"])
- @expectedFailureWindows('llvm.org/pr21550')
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21550")
def test_expr_null(self):
self.build()
self.common_setup(self.line2)
@@ -111,6 +112,17 @@ class AnonymousTestCase(TestBase):
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)
diff --git a/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py b/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py
index e835fb0964968..5a4907465682d 100644
--- a/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py
+++ b/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py
@@ -6,8 +6,9 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class ArrayTypesTestCase(TestBase):
@@ -100,11 +101,8 @@ class ArrayTypesTestCase(TestBase):
"executable = a.out"])
# The stop reason of the thread should be breakpoint.
- thread = process.GetThreadAtIndex(0)
- if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
- from lldbsuite.test.lldbutil import stop_reason_to_str
- self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %
- stop_reason_to_str(thread.GetStopReason()))
+ thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertIsNotNone(thread)
# Sanity check the print representation of thread.
thr = str(thread)
@@ -120,7 +118,7 @@ class ArrayTypesTestCase(TestBase):
substrs = [tidstr])
# The breakpoint should have a hit count of 1.
- self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
+ self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
# The breakpoint should be resolved by now.
bp = str(breakpoint)
diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
index de7a333a18fab..30175c5e1c157 100644
--- a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
+++ b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
@@ -6,8 +6,9 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class BitfieldsTestCase(TestBase):
@@ -95,8 +96,17 @@ class BitfieldsTestCase(TestBase):
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"])
+
+
@add_test_categories(['pyapi'])
@skipIfWindows # BitFields exhibit crashes in record layout on Windows (http://llvm.org/pr21800)
+ @expectedFailureAll("llvm.org/pr27510", oslist=["linux"], compiler="clang", compiler_version=[">=", "3.9"])
def test_and_python_api(self):
"""Use Python APIs to inspect a bitfields variable."""
self.build()
@@ -112,14 +122,11 @@ class BitfieldsTestCase(TestBase):
self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
- thread = target.GetProcess().GetThreadAtIndex(0)
- if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
- from lldbsuite.test.lldbutil import stop_reason_to_str
- self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %
- stop_reason_to_str(thread.GetStopReason()))
+ thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertIsNotNone(thread)
# The breakpoint should have a hit count of 1.
- self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
+ self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
# Lookup the "bits" variable which contains 8 bitfields.
frame = thread.GetFrameAtIndex(0)
diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/main.c b/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
index 26c0176d759c5..236c926d81bd2 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>
+
int main (int argc, char const *argv[])
{
struct Bits
@@ -62,6 +63,19 @@ int main (int argc, char const *argv[])
more_bits.c = 1;
more_bits.d = 0;
+#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;
+
return 0; //// Set break point at this line.
}
diff --git a/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py b/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py
index 8f1c3be228363..0cc9456af32e0 100644
--- a/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py
+++ b/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py
@@ -8,6 +8,7 @@ import unittest2
import os, time
import lldb
from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
class BlocksTestCase(TestBase):
@@ -21,9 +22,8 @@ class BlocksTestCase(TestBase):
# 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.'))
-
- @unittest2.expectedFailure("rdar://problem/10413887 - Call blocks in expressions")
- def test_expr(self):
+
+ def launch_common(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -35,6 +35,10 @@ class BlocksTestCase(TestBase):
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"])
@@ -47,6 +51,14 @@ class BlocksTestCase(TestBase):
# 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"])
def wait_for_breakpoint(self):
if self.is_started == False:
diff --git a/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py b/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
index a112b2a1777cb..99544c7bd80e5 100644
--- a/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
+++ b/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
@@ -6,8 +6,9 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class ConstVariableTestCase(TestBase):
@@ -24,8 +25,8 @@ class ConstVariableTestCase(TestBase):
compiler="clang", compiler_version=["=", "3.8"])
@expectedFailureAll(oslist=["freebsd", "linux"], compiler="icc")
@expectedFailureAll(archs=['mips', 'mipsel', 'mips64', 'mips64el'])
- @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows")
- @expectedFailureWindows("llvm.org/pr24490: We shouldn't be using platform-specific names like `getpid` in tests")
+ @expectedFailureAll(oslist=["linux"], archs=['arm', 'aarch64'], bugnumber="llvm.org/pr27883")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
def test_and_run_command(self):
"""Test interpreted and JITted expressions on constant values."""
self.build()
diff --git a/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py b/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
index b0c5c882f6a9d..044accf14f65d 100644
--- a/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
+++ b/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
@@ -8,6 +8,7 @@ import os, time
import lldb
from lldbsuite.test.lldbtest import *
import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
class EnumTypesTestCase(TestBase):
@@ -19,6 +20,7 @@ class EnumTypesTestCase(TestBase):
# Find the line number to break inside main().
self.line = line_number('main.c', '// Set break point at this line.')
+ @expectedFailureAll(oslist=['windows']) # derefing the null pointer "works" on Windows
def test(self):
"""Test 'image lookup -t days' and check for correct display and enum value printing."""
self.build()
@@ -53,10 +55,10 @@ class EnumTypesTestCase(TestBase):
'kNumDays',
'}'])
- enum_values = [ '-4',
- 'Monday',
- 'Tuesday',
- 'Wednesday',
+ enum_values = [ '-4',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
'Thursday',
'Friday',
'Saturday',
@@ -64,6 +66,13 @@ class EnumTypesTestCase(TestBase):
'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',
diff --git a/packages/Python/lldbsuite/test/lang/c/enum_types/main.c b/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
index 3d59654eff69d..59ea213006932 100644
--- a/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
+++ b/packages/Python/lldbsuite/test/lang/c/enum_types/main.c
@@ -8,6 +8,15 @@
//===----------------------------------------------------------------------===//
#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 days {
@@ -21,6 +30,8 @@ int main (int argc, char const *argv[])
kNumDays
};
enum days day;
+ struct foo f;
+ f.op = NULL;
for (day = Monday - 1; day <= kNumDays + 1; day++)
{
printf("day as int is %i\n", (int)day); // Set break point at this line.
diff --git a/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py b/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py
index 2f9f1d10b58c7..67ccb1aa3fa4e 100644
--- a/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py
+++ b/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py
@@ -6,8 +6,9 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class FunctionTypesTestCase(TestBase):
@@ -37,7 +38,7 @@ class FunctionTypesTestCase(TestBase):
substrs = ['a.out`string_not_empty',
'stop reason = breakpoint'])
- @expectedFailureWindows("llvm.org/pr21765")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
def test_pointers(self):
"""Test that a function pointer to 'printf' works and can be called."""
self.build()
diff --git a/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py b/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
index 1f91cd1660c33..87160f5252be8 100644
--- a/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
+++ b/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
@@ -3,8 +3,9 @@
from __future__ import print_function
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class GlobalVariablesTestCase(TestBase):
@@ -18,8 +19,8 @@ class GlobalVariablesTestCase(TestBase):
self.line = line_number(self.source, '// Set break point at this line.')
self.shlib_names = ["a"]
- @expectedFailureWindows("llvm.org/pr24764")
- @expectedFailureAll("llvm.org/pr25872", oslist=["macosx"], debug_info="dwarf")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+ @expectedFailureAll("llvm.org/pr25872", oslist=["macosx"], debug_info=["dwarf", "gmodules"])
def test_c_global_variables(self):
"""Test 'frame variable --scope --no-args' which omits args and shows scopes."""
self.build()
diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py b/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
new file mode 100644
index 0000000000000..d6fbf42b75702
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
@@ -0,0 +1,5 @@
+from lldbsuite.test import lldbinline
+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")])
diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/inlines.c b/packages/Python/lldbsuite/test/lang/c/inlines/inlines.c
deleted file mode 100644
index 1e920f1ef2f67..0000000000000
--- a/packages/Python/lldbsuite/test/lang/c/inlines/inlines.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdio.h>
-#include "inlines.h"
-
-#define INLINE_ME __inline__ __attribute__((always_inline))
-
-int
-not_inlined_2 (int input)
-{
- printf ("Called in not_inlined_2 with : %d.\n", input);
- return input;
-}
-
-int
-not_inlined_1 (int input)
-{
- printf ("Called in not_inlined_1 with %d.\n", input);
- return not_inlined_2(input);
-}
-
-INLINE_ME int
-inner_inline (int inner_input, int mod_value)
-{
- int inner_result;
- inner_result = inner_input % mod_value;
- printf ("Returning: %d.\n", inner_result);
- return not_inlined_1 (inner_result);
-}
-
-INLINE_ME int
-outer_inline (int outer_input)
-{
- int outer_result;
-
- outer_result = inner_inline (outer_input, outer_input % 3);
- return outer_result;
-}
-
-int
-main (int argc, char **argv)
-{
- printf ("Starting...\n");
-
- int (*func_ptr) (int);
- func_ptr = outer_inline;
-
- outer_inline (argc);
-
- func_ptr (argc);
-
- return 0;
-}
-
-
diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/inlines.h b/packages/Python/lldbsuite/test/lang/c/inlines/inlines.h
deleted file mode 100644
index 265d7b4966ed3..0000000000000
--- a/packages/Python/lldbsuite/test/lang/c/inlines/inlines.h
+++ /dev/null
@@ -1,4 +0,0 @@
-int inner_inline (int inner_input, int mod_value);
-int outer_inline (int outer_input);
-int not_inlined_2 (int input);
-int not_inlined_1 (int input);
diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/main.c b/packages/Python/lldbsuite/test/lang/c/inlines/main.c
new file mode 100644
index 0000000000000..e9bd894bf7264
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/inlines/main.c
@@ -0,0 +1,19 @@
+#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"])
+}
+
+void test1(int a) {
+ printf("test1(%d)\n", a);
+ test2(a+1);//% self.dbg.HandleCommand("step")
+ //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["24"])
+}
+
+int main() {
+ test2(42);
+ test1(23);
+}
diff --git a/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py b/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
index cd31f9dbacfe3..5a940e2e5efff 100644
--- a/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
+++ b/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
@@ -4,23 +4,22 @@ from __future__ import print_function
+from distutils.version import StrictVersion
import os, time
-import lldb
import platform
-import lldbsuite.test.lldbutil as lldbutil
-
-from distutils.version import StrictVersion
+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
- @expectedFailureDarwin('http://llvm.org/pr24302')
- @expectedFailureLinux('http://llvm.org/pr23456') # 'fopen' has unknown return type
- @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows")
+ @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")
def test_expr(self):
if platform.system() == "Darwin" and platform.release() < StrictVersion('12.0.0'):
self.skipTest()
@@ -43,11 +42,11 @@ class CModulesTestCase(TestBase):
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
substrs = [' resolved, hit count = 1'])
- self.expect("expr @import Darwin; 3", VARIABLES_DISPLAYED_CORRECTLY,
+ self.expect("expr -l objc++ -- @import Darwin; 3", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["int", "3"])
self.expect("expr *fopen(\"/dev/zero\", \"w\")", VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ["FILE", "_close", "__sclose"])
+ substrs = ["FILE", "_close"])
self.expect("expr *myFile", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["a", "5", "b", "9"])
diff --git a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
index 12e55616b5403..a09f73fb3fa74 100644
--- a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
+++ b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
@@ -2,6 +2,6 @@ LEVEL = ../../../make
C_SOURCES := test.c
-CFLAGS ?= -g -O1
+CFLAGS_EXTRAS += -O1
include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py b/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py
index 7ef1f246bfd38..6b2dc6a9b126d 100644
--- a/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py
+++ b/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py
@@ -2,28 +2,113 @@
from __future__ import print_function
-
-
import os, time
+import re
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+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):
+ # 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))
+
+ var_loc = var.GetLocation()
+ # 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(oslist=['macosx'], compiler='clang', compiler_version=['<', '7.0.0'], debug_info="dsym")
- @expectedFailureClang(None, ['<', '3.5'])
- @expectedFailureGcc(None, ['is', '4.8.2'])
+
+ @expectedFailureAll(compiler="clang", compiler_version=['<', '3.5'])
+ @expectedFailureAll(compiler="gcc", compiler_version=['>=', '4.8.2'], archs=["i386", "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 = os.path.join(os.getcwd(), "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=2)
+ lldbutil.run_break_set_by_source_regexp(self, "break", num_expected_locations=3)
####################
# First breakpoint
@@ -40,11 +125,16 @@ class RegisterVariableTestCase(TestBase):
substrs = [' resolved, hit count = 1'])
# Try some variables that should be visible
- self.expect("expr a", VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['(int) $0 = 2'])
+ 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)])
- self.expect("expr b->m1", VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['(int) $1 = 3'])
+ if is_struct_pointer_in_register(frame, 'b'):
+ register_variables_count += 1
+ self.expect("expr b->m1", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns = [re_expr_equals('int', 3)])
#####################
# Second breakpoint
@@ -61,10 +151,40 @@ class RegisterVariableTestCase(TestBase):
substrs = [' resolved, hit count = 1'])
# Try some variables that should be visible
- self.expect("expr b->m2", VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['(int) $2 = 5'])
+ frame = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
+ if is_struct_pointer_in_register(frame, 'b'):
+ 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")
- self.expect("expr c", VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['(int) $3 = 5'])
+ # 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/packages/Python/lldbsuite/test/lang/c/register_variables/test.c b/packages/Python/lldbsuite/test/lang/c/register_variables/test.c
index e467ac48f7452..476c32899edc6 100644
--- a/packages/Python/lldbsuite/test/lang/c/register_variables/test.c
+++ b/packages/Python/lldbsuite/test/lang/c/register_variables/test.c
@@ -5,23 +5,31 @@ struct bar {
int m2;
};
-void f1(int a, struct bar *b) __attribute__ ((noinline));
+void f1(int a, struct bar *b) __attribute__((noinline)) __attribute__((regparm(2)));
void f1(int a, struct bar *b)
{
b->m2 = b->m1 + a; // set breakpoint here
}
-void f2(struct bar *b) __attribute__ ((noinline));
+void f2(struct bar *b) __attribute__((noinline)) __attribute__((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/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py b/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py
index ab8102496091f..12e20dd42d444 100644
--- a/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py
+++ b/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py
@@ -6,8 +6,9 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class SetValuesTestCase(TestBase):
@@ -23,7 +24,6 @@ class SetValuesTestCase(TestBase):
self.line4 = line_number('main.c', '// Set break point #4.')
self.line5 = line_number('main.c', '// Set break point #5.')
- @expectedFailureWindows("llvm.org/pr21765")
def test(self):
"""Test settings and readings of program variables."""
self.build()
diff --git a/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
index a9cb46ca137bb..011e4d1f22a43 100644
--- a/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
+++ b/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
@@ -6,14 +6,15 @@ from __future__ import print_function
import unittest2
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class SharedLibStrippedTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailureWindows # Test crashes
+ @expectedFailureAll(oslist=["windows"])
def test_expr(self):
"""Test that types work when defined in a shared library and forward-declared in the main executable"""
if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
@@ -26,7 +27,7 @@ class SharedLibStrippedTestCase(TestBase):
self.expect("expression --show-types -- *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["(foo)", "(sub_foo)", "other_element = 3"])
- @expectedFailureWindows # Test crashes
+ @expectedFailureAll(oslist=["windows"])
@unittest2.expectedFailure("rdar://problem/10381325")
def test_frame_variable(self):
"""Test that types work when defined in a shared library and forward-declared in the main executable"""
diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/Makefile b/packages/Python/lldbsuite/test/lang/c/step-target/Makefile
index c5b0d18f995dc..b09a579159d48 100644
--- a/packages/Python/lldbsuite/test/lang/c/inlines/Makefile
+++ b/packages/Python/lldbsuite/test/lang/c/step-target/Makefile
@@ -1,5 +1,5 @@
LEVEL = ../../../make
-C_SOURCES := inlines.c
+C_SOURCES := main.c
include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py b/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py
new file mode 100644
index 0000000000000..2bd72434d3907
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py
@@ -0,0 +1,113 @@
+"""Test the 'step target' feature."""
+
+from __future__ import print_function
+
+import os, time
+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 getCategories(self):
+ return ['basic_process']
+
+ 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 = os.path.join(os.getcwd(), "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.assertTrue(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
+
+ 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.assertTrue (frame.name == "lotsOfArgs", "Stepped to lotsOfArgs.")
+
+ 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.assertTrue (frame.line_entry.line == self.end_line, "Stepped to the block end.")
+
+ 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.assertTrue (frame.name == "modifyInt", "Stepped to modifyInt.")
+
+ 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.assertTrue (frame.name == "lotsOfArgs", "Stepped to lotsOfArgs.")
+
+ 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.assertTrue (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.assertTrue(frame.line_entry.line == self.end_line, "Got out of the block")
+
+
+
diff --git a/packages/Python/lldbsuite/test/lang/c/step-target/main.c b/packages/Python/lldbsuite/test/lang/c/step-target/main.c
new file mode 100644
index 0000000000000..86a26c4d47a41
--- /dev/null
+++ b/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/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py b/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py
index c7a3de4b68467..cfaff91daa45f 100644
--- a/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py
+++ b/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py
@@ -6,8 +6,9 @@ from __future__ import print_function
import os, time
import lldb
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
class TestCStepping(TestBase):
@@ -22,10 +23,10 @@ class TestCStepping(TestBase):
# Find the line numbers that we will step to in main:
self.main_source = "main.c"
- @expectedFailureFreeBSD('llvm.org/pr17932')
- @expectedFailureLinux # llvm.org/pr14437
- @expectedFailureWindows("llvm.org/pr24777")
@add_test_categories(['pyapi'])
+ @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17932')
+ @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr14437")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24777")
def test_and_python_api(self):
"""Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
self.build()
@@ -155,9 +156,14 @@ class TestCStepping(TestBase):
current_file = frame.GetLineEntry().GetFileSpec()
break_in_b.SetEnabled(True)
- frame.EvaluateExpression ("b (4)", lldb.eNoDynamicValues, False)
+ 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]
diff --git a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
index 6f2a9ff03be04..a9f49c30d1017 100644
--- a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
+++ b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py
@@ -2,14 +2,15 @@
Tests that C strings work as expected in expressions
"""
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class CStringsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailureWindows("llvm.org/pr21765")
+ @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 87ad326f31811..2249a8c9b16af 100644
--- a/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py
+++ b/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py
@@ -1,4 +1,4 @@
-import lldbsuite.test.lldbinline as lldbinline
-import lldbsuite.test.lldbtest as lldbtest
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
-lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.expectedFailureWindows("llvm.org/pr24764")] )
+lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")] )
diff --git a/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py b/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py
index 0d9e22ec3adfc..0ca9923c89a66 100644
--- a/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py
+++ b/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py
@@ -7,8 +7,9 @@ from __future__ import print_function
import unittest2
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class TlsGlobalTestCase(TestBase):
@@ -25,8 +26,8 @@ class TlsGlobalTestCase(TestBase):
self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.getcwd())
self.addTearDownHook(lambda: self.runCmd("settings remove target.env-vars " + self.dylibPath))
- @unittest2.expectedFailure("rdar://7796742")
@skipIfWindows # TLS works differently on Windows, this would need to be implemented separately.
+ @expectedFailureAll(bugnumber="llvm.org/pr28392", oslist=no_match(lldbplatformutil.getDarwinOSTriples()))
def test(self):
"""Test thread-local storage."""
self.build()
diff --git a/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c b/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c
index b9a85902d1179..ab1022514d1ec 100644
--- a/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c
+++ b/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c
@@ -11,6 +11,12 @@
__thread int var_shared = 33;
+int
+touch_shared()
+{
+ return var_shared;
+}
+
void shared_check()
{
var_shared *= 2;
diff --git a/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c b/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c
index cbe01b89b7ef3..73e32ca39a584 100644
--- a/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c
+++ b/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c
@@ -11,6 +11,10 @@
#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;
@@ -28,9 +32,11 @@ 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
+ }
- for(;;)
- usleep(1); // main breakpoint
-
- return 0;
+ return 0;
}
diff --git a/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py b/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py
index a4870de1d177d..232a86a2cde33 100644
--- a/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py
+++ b/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py
@@ -6,15 +6,16 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class TypedefTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailureAll(bugnumber="llvm.org/pr19238", compiler="clang")
- @expectedFailureAll(bugnumber="llvm.org/pr25626 expectedFailureClang fails on FreeBSD", oslist=["freebsd"])
+ @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()
diff --git a/packages/Python/lldbsuite/test/lang/c/unions/Makefile b/packages/Python/lldbsuite/test/lang/c/unions/Makefile
new file mode 100644
index 0000000000000..b09a579159d48
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/unions/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py b/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py
new file mode 100644
index 0000000000000..114be3ade01a2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py
@@ -0,0 +1,46 @@
+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()
+
+ cwd = os.getcwd()
+
+ src_file = os.path.join(cwd, "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 = os.path.join(cwd, 'a.out')
+
+ # Load the executable
+ self.target = self.dbg.CreateTarget(exe_path)
+ self.assertTrue(self.target.IsValid(), VALID_TARGET)
diff --git a/packages/Python/lldbsuite/test/lang/c/unions/main.c b/packages/Python/lldbsuite/test/lang/c/unions/main.c
new file mode 100644
index 0000000000000..2c6a7d1e78211
--- /dev/null
+++ b/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
+}