diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
commit | f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch) | |
tree | 48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /packages/Python/lldbsuite/test/lang | |
parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/lang')
155 files changed, 1929 insertions, 289 deletions
diff --git a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py index 7cb66ba8238b..e6f1092c702a 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 e835fb096496..5a4907465682 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 de7a333a18fa..30175c5e1c15 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 26c0176d759c..236c926d81bd 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 8f1c3be22836..0cc9456af32e 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 a112b2a1777c..99544c7bd80e 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 b0c5c882f6a9..044accf14f65 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 3d59654eff69..59ea21300693 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 2f9f1d10b58c..67ccb1aa3fa4 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 1f91cd1660c3..87160f5252be 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 000000000000..d6fbf42b7570 --- /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/main.c b/packages/Python/lldbsuite/test/lang/c/inlines/main.c new file mode 100644 index 000000000000..e9bd894bf726 --- /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 cd31f9dbacfe..5a940e2e5eff 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 12e55616b540..a09f73fb3fa7 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 7ef1f246bfd3..6b2dc6a9b126 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 e467ac48f745..476c32899edc 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 ab8102496091..12e20dd42d44 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 a9cb46ca137b..011e4d1f22a4 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 c5b0d18f995d..b09a579159d4 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 000000000000..2bd72434d390 --- /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 000000000000..86a26c4d47a4 --- /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 c7a3de4b6846..cfaff91daa45 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 6f2a9ff03be0..a9f49c30d101 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 87ad326f3181..2249a8c9b16a 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 0d9e22ec3adf..0ca9923c89a6 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 b9a85902d117..ab1022514d1e 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 cbe01b89b7ef..73e32ca39a58 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 a4870de1d177..232a86a2cde3 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 000000000000..b09a579159d4 --- /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 000000000000..114be3ade01a --- /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 000000000000..2c6a7d1e7821 --- /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 +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py b/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py index 9746dec2fa3d..ea210a1e9ea2 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py +++ b/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py @@ -2,14 +2,16 @@ Tests that auto types work """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class CPPAutoTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureGcc("GCC does not generate complete debug info") + @expectedFailureAll(compiler="gcc", bugnumber="GCC generates incomplete debug info") + @expectedFailureAll(oslist=['windows'], bugnumber="llvm.org/pr26339") def test_with_run_command(self): """Test that auto types work in the expression parser""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py b/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py index 6c06f3750d13..0a1ac11adcea 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py +++ b/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py @@ -8,13 +8,15 @@ 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 CPPBreakpointCommandsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureWindows + @expectedFailureAll(oslist=["windows"]) def test(self): """Test a sequence of breakpoint command add, list, and delete.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py b/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py index 3aa97af68819..260dd763c007 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py +++ b/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py @@ -3,8 +3,9 @@ Tests calling a function by basename """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class CallCPPFunctionTestCase(TestBase): @@ -14,7 +15,7 @@ class CallCPPFunctionTestCase(TestBase): TestBase.setUp(self) self.line = line_number('main.cpp', '// breakpoint') - @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_with_run_command(self): """Test calling a function by basename""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py b/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py index 272665a78577..140c4a832fd9 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py +++ b/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py @@ -1,12 +1,13 @@ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class TestCppChainedCalls(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureWindows("llvm.org/pr21765") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_with_run_command(self): self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py index 9bb1faf4ba6d..d4400d3a488d 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py +++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py @@ -9,8 +9,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 Char1632TestCase(TestBase): @@ -24,8 +25,7 @@ class Char1632TestCase(TestBase): self.lines = [ line_number(self.source, '// breakpoint1'), line_number(self.source, '// breakpoint2') ] - @expectedFailureIcc # ICC (13.1) does not emit the DW_TAG_base_type for char16_t and char32_t. - @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(compiler="icc", bugnumber="ICC (13.1) does not emit the DW_TAG_base_type for char16_t and char32_t.") def test(self): """Test that the C++11 support for char16_t and char32_t works correctly.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py b/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py index d47d1b7dde41..acce769bf949 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py @@ -8,8 +8,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 StaticVariableTestCase(TestBase): @@ -21,7 +22,7 @@ class StaticVariableTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureWindows("llvm.org/pr24764") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_with_run_command(self): """Test that file and class static variables display correctly.""" self.build() @@ -49,9 +50,8 @@ class StaticVariableTestCase(TestBase): startstr = "(int) A::g_points[1].x = 11") @expectedFailureDarwin(9980907) - @expectedFailureClang('Clang emits incomplete debug info.') - @expectedFailureFreeBSD('llvm.org/pr20550 failing on FreeBSD-11') - @expectedFailureGcc('GCC emits incomplete debug info.') + @expectedFailureAll(compiler=["clang", "gcc"], bugnumber="Compiler emits incomplete debug info") + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr20550 failing on FreeBSD-11') @add_test_categories(['pyapi']) def test_with_python_api(self): """Test Python APIs on file and class static variables.""" @@ -69,11 +69,8 @@ class StaticVariableTestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # 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) # Get the SBValue of 'A::g_points' and 'g_points'. frame = thread.GetFrameAtIndex(0) diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py index b67e53c30745..fe10120d497e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py @@ -6,9 +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 * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class ClassTypesTestCase(TestBase): @@ -92,11 +92,8 @@ class ClassTypesTestCase(TestBase): lldbutil.state_type_to_str(process.GetState())) # 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) # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. @@ -203,11 +200,8 @@ class ClassTypesTestCase(TestBase): lldbutil.state_type_to_str(process.GetState())) # 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) frame = thread.frames[0] self.assertTrue (frame.IsValid(), "Got a valid frame.") diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py index 595d075d5180..6413b3e056ff 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py @@ -8,8 +8,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 IterateFrameAndDisassembleTestCase(TestBase): @@ -46,7 +47,8 @@ class IterateFrameAndDisassembleTestCase(TestBase): # disassemble it. target = self.dbg.GetSelectedTarget() process = target.GetProcess() - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) depth = thread.GetNumFrames() for i in range(depth - 1): frame = thread.GetFrameAtIndex(i) diff --git a/packages/Python/lldbsuite/test/lang/cpp/const_this/Makefile b/packages/Python/lldbsuite/test/lang/cpp/const_this/Makefile new file mode 100644 index 000000000000..52a92c0b61ae --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/const_this/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp +CXXFLAGS += -std=c++11 +include $(LEVEL)/Makefile.rules + +cleanup: + rm -f Makefile *.d + diff --git a/packages/Python/lldbsuite/test/lang/cpp/const_this/TestConstThis.py b/packages/Python/lldbsuite/test/lang/cpp/const_this/TestConstThis.py new file mode 100644 index 000000000000..a08af5d091e1 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/const_this/TestConstThis.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), [] ) diff --git a/packages/Python/lldbsuite/test/lang/cpp/const_this/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/const_this/main.cpp new file mode 100644 index 000000000000..7614977b245f --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/const_this/main.cpp @@ -0,0 +1,23 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> + +class foo { +public: + template <class T> T func(T x) const { + return x+2; //% self.expect("expr 2+3", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["5"]) + } +}; + +int i; + +int main() { + return foo().func(i); +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py b/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py index 67de03b54b20..d525e12b31ee 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py +++ b/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py @@ -20,7 +20,8 @@ class CPPTestDiamondInheritance(TestBase): self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) process = target.LaunchSimple (None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) frame = thread.GetFrameAtIndex(0) j1 = frame.FindVariable("j1") j1_Derived1 = j1.GetChildAtIndex(0) diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py index 4e23cd899285..b456de450a82 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py @@ -10,8 +10,9 @@ import unittest2 import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class CppValueCastTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py index 56e81c56cfa6..98e6ef92665d 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class DynamicValueTestCase(TestBase): @@ -28,9 +29,8 @@ class DynamicValueTestCase(TestBase): self.main_second_call_line = line_number('pass-to-base.cpp', '// Break here and get real address of reallyA.') - @expectedFailureFreeBSD # FIXME: This needs to be root-caused. - @expectedFailureWindows("llvm.org/pr24663") @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663") def test_get_dynamic_vals(self): """Test fetching C++ dynamic values from pointers & references.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py b/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py index 65cf0b361d84..4ca4cb8b79ef 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py +++ b/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py @@ -8,8 +8,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 CPPBreakpointTestCase(TestBase): @@ -21,7 +22,7 @@ class CPPBreakpointTestCase(TestBase): self.source = 'exceptions.cpp' self.catch_line = line_number(self.source, '// This is the line you should stop at for catch') - @expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support throw or catch + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538, clang-cl does not support throw or catch") def test(self): """Test lldb exception breakpoint command for CPP.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile b/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile new file mode 100644 index 000000000000..99bfa7e03b47 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py b/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py new file mode 100644 index 000000000000..f08c0dcbda98 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), []) diff --git a/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp new file mode 100644 index 000000000000..a4006c2f7ed1 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp @@ -0,0 +1,29 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> +#include <stdint.h> + +extern "C" +{ + int foo(); +}; + +int foo() +{ + puts("foo"); + return 2; +} + +int main (int argc, char const *argv[], char const *envp[]) +{ + foo(); + return 0; //% self.expect("expression -- foo()", substrs = ['2']) +} + diff --git a/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py b/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py index 396a637041cb..d5d536388222 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py @@ -19,7 +19,13 @@ class FrameVariableAnonymousUnionsTestCase(TestBase): self.runCmd("process launch", RUN_SUCCEEDED) - self.expect('frame variable -f x i', substrs=['ffffff41']) + process = self.dbg.GetSelectedTarget().GetProcess() + + if process.GetByteOrder() == lldb.eByteOrderLittle: + self.expect('frame variable -f x i', substrs=['ffffff41']) + else: + self.expect('frame variable -f x i', substrs=['41ffff00']) + self.expect('frame variable c', substrs=["'A"]) self.expect('frame variable x', matching=False, substrs=['3']) diff --git a/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py b/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py index de56cd6a6c49..eac78cd29951 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py +++ b/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py @@ -2,14 +2,15 @@ Test that global operators are found and evaluated. """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class TestCppGlobalOperators(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureWindows("llvm.org/pr21765") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_with_run_command(self): self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile b/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile new file mode 100644 index 000000000000..da6f39a7488c --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +PCH_CXX_SOURCE = pch.h +CXX_SOURCES = main.cpp +CFLAGS_EXTRAS += $(MODULE_DEBUG_INFO_FLAGS) + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py b/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py new file mode 100644 index 000000000000..942149f6173b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py @@ -0,0 +1,50 @@ +import lldb, os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestWithGmodulesDebugInfo(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @add_test_categories(["gmodules"]) + @expectedFailureAll(oslist=["macosx"], bugnumber="llvm.org/pr28156") + def test_specialized_typedef_from_pch(self): + self.build() + cwd = os.getcwd() + + src_file = os.path.join(cwd, "main.cpp") + src_file_spec = lldb.SBFileSpec(src_file) + self.assertTrue(src_file_spec.IsValid(), "breakpoint file") + + # Get the path of the executable + exe_path = os.path.join(cwd, 'a.out') + + # Load the executable + target = self.dbg.CreateTarget(exe_path) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Break on interesting line + breakpoint = target.BreakpointCreateBySourceRegex("break here", src_file_spec) + self.assertTrue(breakpoint.IsValid() and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT) + + # Launch the process + process = target.LaunchSimple(None, None, self.get_process_working_directory()) + self.assertTrue(process.IsValid(), PROCESS_IS_VALID) + + # Get the thread of the process + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") + + # Get frame for current thread + frame = thread.frames[0] + + testValue = frame.EvaluateExpression("test") + self.assertTrue(testValue.GetError().Success(), "Test expression value invalid: %s" % (testValue.GetError().GetCString())) + self.assertTrue(testValue.GetTypeName() == "IntContainer", "Test expression type incorrect") + + memberValue = testValue.GetChildMemberWithName("storage") + self.assertTrue(memberValue.GetError().Success(), "Member value missing or invalid: %s" % (testValue.GetError().GetCString())) + self.assertTrue(memberValue.GetTypeName() == "int", "Member type incorrect") + self.assertEqual(42, memberValue.GetValueAsSigned(), "Member value incorrect") diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp new file mode 100644 index 000000000000..aa4013685171 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp @@ -0,0 +1,5 @@ +int main(int argc, const char * argv[]) +{ + IntContainer test(42); + return 0; // break here +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h new file mode 100644 index 000000000000..a6c59b94c896 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h @@ -0,0 +1,12 @@ +template<typename T> +class GenericContainer { + private: + T storage; + + public: + GenericContainer(T value) { + storage = value; + }; +}; + +typedef GenericContainer<int> IntContainer; diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py index 324f476efb9b..1e3359ecde49 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py @@ -1,13 +1,13 @@ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class TestCppIncompleteTypes(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureFreeBSD("llvm.org/pr25626 test executable not built correctly on FreeBSD") - @skipIfGcc + @skipIf(compiler="gcc") def test_limit_debug_info(self): self.build() frame = self.get_test_frame('limit') @@ -20,7 +20,7 @@ class TestCppIncompleteTypes(TestBase): self.assertTrue(value_a.IsValid(), "'expr a' results in a valid SBValue object") self.assertTrue(value_a.GetError().Success(), "'expr a' is successful") - @skipIfGcc + @skipIf(compiler="gcc") @skipIfWindows # Clang on Windows asserts in external record layout in this case. def test_partial_limit_debug_info(self): self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/inlines/Makefile b/packages/Python/lldbsuite/test/lang/cpp/inlines/Makefile new file mode 100644 index 000000000000..8f67abdf2b34 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/inlines/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := inlines.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py b/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py new file mode 100644 index 000000000000..284057de9dcd --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py @@ -0,0 +1,52 @@ +"""Test variable lookup when stopped in inline functions.""" + +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 InlinesTestCase(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('inlines.cpp', '// Set break point at this line.') + + @expectedFailureAll("llvm.org/pr26710", oslist=["linux"], compiler="gcc") + def test(self): + """Test that local variables are visible in expressions.""" + self.build() + self.runToBreakpoint() + + # Check that 'frame variable' finds a variable + self.expect("frame variable inner_input", VARIABLES_DISPLAYED_CORRECTLY, + startstr = '(int) inner_input =') + + # Check that 'expr' finds a variable + self.expect("expr inner_input", VARIABLES_DISPLAYED_CORRECTLY, + startstr = '(int) $0 =') + + def runToBreakpoint(self): + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break inside the main. + lldbutil.run_break_set_by_file_and_line(self, "inlines.cpp", self.line, num_expected_locations=2, + 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/packages/Python/lldbsuite/test/lang/c/inlines/inlines.c b/packages/Python/lldbsuite/test/lang/cpp/inlines/inlines.cpp index 1e920f1ef2f6..822d88e22f9b 100644 --- a/packages/Python/lldbsuite/test/lang/c/inlines/inlines.c +++ b/packages/Python/lldbsuite/test/lang/cpp/inlines/inlines.cpp @@ -23,7 +23,7 @@ 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); + return not_inlined_1 (inner_result); // Set break point at this line. } INLINE_ME int diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/inlines.h b/packages/Python/lldbsuite/test/lang/cpp/inlines/inlines.h index 265d7b4966ed..265d7b4966ed 100644 --- a/packages/Python/lldbsuite/test/lang/c/inlines/inlines.h +++ b/packages/Python/lldbsuite/test/lang/cpp/inlines/inlines.h diff --git a/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py b/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py new file mode 100644 index 000000000000..97cc177aab70 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), [lldbinline.expectedFailureAll(oslist=["windows"])]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp new file mode 100644 index 000000000000..3cce3baf2924 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp @@ -0,0 +1,17 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> + +int main (int argc, char const *argv[]) +{ + printf("Stop here\n"); //% self.runCmd("expression auto $add = [](int a, int b) { return a + b; }") + //% self.expect("expression $add(2,3)", substrs = ['= 5']) + return 0; +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py b/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py index ec26f9efe907..9d4d1b54a9d3 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py +++ b/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py @@ -1,12 +1,13 @@ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class TestWithLimitDebugInfo(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIf(debug_info=not_in(["dwarf"])) + @skipIf(debug_info=no_match(["dwarf"])) def test_limit_debug_info(self): self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/Makefile b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/Makefile new file mode 100644 index 000000000000..35eb63f922f7 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES = main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py new file mode 100644 index 000000000000..12fc4c236376 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py @@ -0,0 +1,197 @@ +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class TestMembersAndLocalsWithSameName(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_when_stopped_in_method(self): + self._load_exe() + + # Set breakpoints + bp1 = self.target.BreakpointCreateBySourceRegex("Break 1", self.src_file_spec) + self.assertTrue(bp1.IsValid() and bp1.GetNumLocations() >= 1, VALID_BREAKPOINT) + bp2 = self.target.BreakpointCreateBySourceRegex("Break 2", self.src_file_spec) + self.assertTrue(bp2.IsValid() and bp2.GetNumLocations() >= 1, VALID_BREAKPOINT) + bp3 = self.target.BreakpointCreateBySourceRegex("Break 3", self.src_file_spec) + self.assertTrue(bp3.IsValid() and bp3.GetNumLocations() >= 1, VALID_BREAKPOINT) + bp4 = self.target.BreakpointCreateBySourceRegex("Break 4", self.src_file_spec) + self.assertTrue(bp4.IsValid() and bp4.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) + + self._test_globals() + + self.process.Continue() + 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("a"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 12345) + + val = frame.EvaluateExpression("b"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 54321) + + val = frame.EvaluateExpression("c"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 34567) + + self.process.Continue() + 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("a"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 10001) + + val = frame.EvaluateExpression("b"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 10002) + + val = frame.EvaluateExpression("c"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 10003) + + self.process.Continue() + 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("a"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 1) + + val = frame.EvaluateExpression("b"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 2) + + val = frame.EvaluateExpression("c"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 778899) + + def test_when_stopped_in_function(self): + self._load_exe() + + # Set breakpoints + bp1 = self.target.BreakpointCreateBySourceRegex("Break 1", self.src_file_spec) + self.assertTrue(bp1.IsValid() and bp1.GetNumLocations() >= 1, VALID_BREAKPOINT) + bp5 = self.target.BreakpointCreateBySourceRegex("Break 5", self.src_file_spec) + self.assertTrue(bp5.IsValid() and bp5.GetNumLocations() >= 1, VALID_BREAKPOINT) + bp6 = self.target.BreakpointCreateBySourceRegex("Break 6", self.src_file_spec) + self.assertTrue(bp6.IsValid() and bp6.GetNumLocations() >= 1, VALID_BREAKPOINT) + bp7 = self.target.BreakpointCreateBySourceRegex("Break 7", self.src_file_spec) + self.assertTrue(bp7.IsValid() and bp7.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) + + self._test_globals() + + self.process.Continue() + 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("a"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 12345) + + val = frame.EvaluateExpression("b"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 54321) + + val = frame.EvaluateExpression("c"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 34567) + + self.process.Continue() + 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("a"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 10001) + + val = frame.EvaluateExpression("b"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 10002) + + val = frame.EvaluateExpression("c"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 10003) + + self.process.Continue() + 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("a"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 1) + + val = frame.EvaluateExpression("b"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 2) + + val = frame.EvaluateExpression("c"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 778899) + + def _load_exe(self): + self.build() + + cwd = os.getcwd() + + src_file = os.path.join(cwd, "main.cpp") + 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) + + def _test_globals(self): + thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread.IsValid()) + frame = thread.GetSelectedFrame() + self.assertTrue(frame.IsValid()) + + val = frame.EvaluateExpression("a"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 112233) + + val = frame.EvaluateExpression("b"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 445566) + + val = frame.EvaluateExpression("c"); + self.assertTrue(val.IsValid()) + self.assertEqual(val.GetValueAsUnsigned(), 778899) diff --git a/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/main.cpp new file mode 100644 index 000000000000..baf08f6a9832 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/main.cpp @@ -0,0 +1,73 @@ +namespace NN +{ + int a = 778899; + int b = 665544; + int c = 445566; +} + +class A +{ +public: + A(); + int Method(int a, int b); + +private: + int a, b; +}; + +A::A() : a(10), b(100) { } + +int a = 112233; +int b = 445566; +int c = 778899; + +int +A::Method(int a, int b) +{ + { + int a = 12345; + int b = 54321; + int c = 34567; + this->a = a + b + this->b; // Break 2 + } + + { + using namespace NN; + int a = 10001; + int b = 10002; + int c = 10003; + this->a = a + b + this->b; // Break 3 + } + + return this->a + this->b + a + b; // Break 4 +} + +int +Function(int a, int b) +{ + int A; + + { + int a = 12345; + int b = 54321; + int c = 34567; + A = a + b + c; // Break 5 + } + + { + using namespace NN; + int a = 10001; + int b = 10002; + int c = 10003; + A = a + b + c; // Break 6 + } + + return A + a + b; // Break 7 +} + +int +main() +{ + A obj; + return obj.Method(1, 2) + Function(1, 2); // Break 1 +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py index a60d8252e9f0..93d53c7de712 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py @@ -8,8 +8,78 @@ 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 NamespaceBreakpointTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @expectedFailureAll(bugnumber="llvm.org/pr28548", compiler="gcc") + def test_breakpoints_func_auto(self): + """Test that we can set breakpoints correctly by basename to find all functions whose basename is "func".""" + self.build() + + names = [ "func()", "func(int)", "A::B::func()", "A::func()", "A::func(int)"] + + # Create a target by the debugger. + exe = os.path.join(os.getcwd(), "a.out") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + module_list = lldb.SBFileSpecList() + module_list.Append(lldb.SBFileSpec(exe, False)) + cu_list = lldb.SBFileSpecList() + # Set a breakpoint by name "func" which should pick up all functions whose basename is "func" + bp = target.BreakpointCreateByName ("func", lldb.eFunctionNameTypeAuto, module_list, cu_list); + for bp_loc in bp: + name = bp_loc.GetAddress().GetFunction().GetName() + self.assertTrue(name in names, "make sure breakpoint locations are correct for 'func' with eFunctionNameTypeAuto") + + @expectedFailureAll(bugnumber="llvm.org/pr28548", compiler="gcc") + def test_breakpoints_func_full(self): + """Test that we can set breakpoints correctly by fullname to find all functions whose fully qualified name is "func" + (no namespaces).""" + self.build() + + names = [ "func()", "func(int)"] + + # Create a target by the debugger. + exe = os.path.join(os.getcwd(), "a.out") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + module_list = lldb.SBFileSpecList() + module_list.Append(lldb.SBFileSpec(exe, False)) + cu_list = lldb.SBFileSpecList() + + # Set a breakpoint by name "func" whose fullly qualified named matches "func" which + # should pick up only functions whose basename is "func" and has no containing context + bp = target.BreakpointCreateByName ("func", lldb.eFunctionNameTypeFull, module_list, cu_list); + for bp_loc in bp: + name = bp_loc.GetAddress().GetFunction().GetName() + self.assertTrue(name in names, "make sure breakpoint locations are correct for 'func' with eFunctionNameTypeFull") + + def test_breakpoints_a_func_full(self): + """Test that we can set breakpoints correctly by fullname to find all functions whose fully qualified name is "A::func".""" + self.build() + + names = [ "A::func()", "A::func(int)"] + + # Create a target by the debugger. + exe = os.path.join(os.getcwd(), "a.out") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + module_list = lldb.SBFileSpecList() + module_list.Append(lldb.SBFileSpec(exe, False)) + cu_list = lldb.SBFileSpecList() + + # Set a breakpoint by name "A::func" whose fullly qualified named matches "A::func" which + # should pick up only functions whose basename is "func" and is contained in the "A" namespace + bp = target.BreakpointCreateByName ("A::func", lldb.eFunctionNameTypeFull, module_list, cu_list); + for bp_loc in bp: + name = bp_loc.GetAddress().GetFunction().GetName() + self.assertTrue(name in names, "make sure breakpoint locations are correct for 'A::func' with eFunctionNameTypeFull") + class NamespaceTestCase(TestBase): @@ -38,7 +108,7 @@ class NamespaceTestCase(TestBase): 'stop reason = breakpoint']) # rdar://problem/8668674 - @expectedFailureWindows("llvm.org/pr24764") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_with_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py index 4cad45564c87..12e8eef40cf3 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py @@ -7,8 +7,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 NamespaceLookupTestCase(TestBase): @@ -33,8 +34,7 @@ class NamespaceLookupTestCase(TestBase): substrs = ['stopped', 'stop reason = breakpoint']) - @expectedFailureFreeBSD("llvm.org/pr25819") - @expectedFailureLinux("llvm.org/pr25819") + @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr25819") def test_scope_lookup_with_run_command(self): """Test scope lookup of functions in lldb.""" self.build() @@ -144,7 +144,7 @@ class NamespaceLookupTestCase(TestBase): # finds the global ::func(). self.expect("expr -- func()", startstr = "(int) $0 = 2") - @expectedFailureLinux("llvm.org/pr25819") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr25819") def test_scope_lookup_before_using_with_run_command(self): """Test scope lookup before using in lldb.""" self.build() @@ -158,9 +158,9 @@ class NamespaceLookupTestCase(TestBase): self.expect("expr -- func()", startstr = "(int) $0 = 1") # NOTE: this test may fail on older systems that don't emit import - # emtries in DWARF - may need to add checks for compiler versions here. - @expectedFailureFreeBSD("llvm.org/pr25819") - @expectedFailureLinux("llvm.org/pr25819") + # entries in DWARF - may need to add checks for compiler versions here. + @skipIf(compiler="gcc", oslist=["linux"], debug_info=["dwo"]) # Skip to avoid crash + @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr25819") def test_scope_after_using_directive_lookup_with_run_command(self): """Test scope lookup after using directive in lldb.""" self.build() @@ -203,8 +203,7 @@ class NamespaceLookupTestCase(TestBase): # the same type. self.expect("expr -- func()", startstr = "error") - @expectedFailureFreeBSD("llvm.org/pr25819") - @expectedFailureLinux("llvm.org/pr25819") + @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr25819") def test_scope_lookup_shadowed_by_using_with_run_command(self): """Test scope lookup shadowed by using in lldb.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile new file mode 100644 index 000000000000..0041add935a6 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile @@ -0,0 +1,19 @@ +LEVEL := ../../../make + +LD_EXTRAS := -L. -l$(LIB_PREFIX)a -l$(LIB_PREFIX)b +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules + +.PHONY: +a.out: lib_a lib_b + +lib_%: + $(MAKE) -f $*.mk + +hidden_lib_d: + $(MAKE) -C hidden + +clean:: + $(MAKE) -f a.mk clean + $(MAKE) -f b.mk clean diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py new file mode 100644 index 000000000000..f45969429004 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py @@ -0,0 +1,57 @@ +"""Test that forward declarations don't cause bogus conflicts in namespaced types""" + +from __future__ import print_function + + + +import unittest2 +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class NamespaceDefinitionsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_expr(self): + self.build() + self.common_setup() + + self.expect("expression -- Foo::MyClass()", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['thing = ']) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.source = 'main.cpp' + self.line = line_number(self.source, '// Set breakpoint here') + self.shlib_names = ["a", "b"] + + def common_setup(self): + # Run in synchronous mode + self.dbg.SetAsync(False) + + # Create a target by the debugger. + target = self.dbg.CreateTarget("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/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp new file mode 100644 index 000000000000..2ea0d2df2eca --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp @@ -0,0 +1,16 @@ +//===-- a.cpp ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "foo.h" + +class ThingInside { + int a; +}; + +Foo::MyClass a_class; diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk new file mode 100644 index 000000000000..5943e5077c54 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +DYLIB_NAME := a +DYLIB_CXX_SOURCES := a.cpp +DYLIB_ONLY := YES + +CXXFLAGS += -fPIC + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp new file mode 100644 index 000000000000..6e7b41e00164 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp @@ -0,0 +1,12 @@ +//===-- b.cpp ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "foo.h" + +Foo::MyClass b_class; diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk new file mode 100644 index 000000000000..8ee2a13b1291 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +DYLIB_NAME := b +DYLIB_CXX_SOURCES := b.cpp +DYLIB_ONLY := YES + +CXXFLAGS += -fPIC + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h new file mode 100644 index 000000000000..76b8e70880ec --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h @@ -0,0 +1,18 @@ +//===-- foo.h ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +class ThingInside; + +namespace Foo { + class MyClass { + ThingInside *thing; + public: + MyClass() { } + }; +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp new file mode 100644 index 000000000000..076814eae1de --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp @@ -0,0 +1,16 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> + +int +main (int argc, char const *argv[]) +{ + return 0; // Set breakpoint here +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py b/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py index 97e9e27a6e98..d66d2ac530e5 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py +++ b/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py @@ -2,15 +2,15 @@ Tests imported namespaces in C++. """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class TestCppNsImport(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureFreeBSD("llvm.org/pr25925") - @expectedFailureGcc(None, ['>=', '4.9']) + @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25925") def test_with_run_command(self): """Tests imported namespaces in C++.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py b/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py index d485dcd0f652..ff00d99d7763 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py @@ -3,8 +3,9 @@ Tests that functions with the same name are resolved correctly. """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class CPPStaticMethodsTestCase(TestBase): @@ -14,7 +15,7 @@ class CPPStaticMethodsTestCase(TestBase): TestBase.setUp(self) self.line = line_number('main.cpp', '// breakpoint') - @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_with_run_command(self): """Test that functions with the same name are resolved correctly""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py b/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py new file mode 100644 index 000000000000..2a2c673f8675 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(bugnumber="rdar://problem/24599697")] ) diff --git a/packages/Python/lldbsuite/test/lang/cpp/printf/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/printf/main.cpp new file mode 100644 index 000000000000..badf1be0b41f --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/printf/main.cpp @@ -0,0 +1,21 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +class PrintfContainer { +public: + int printf() { + return 0; + } +}; + +int main() { + PrintfContainer().printf(); //% self.expect("expression -- printf(\"Hello\\n\")", substrs = ['6']) + return 0; +} + diff --git a/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py b/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py index d02c34ecb0fe..78a2727094a7 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py +++ b/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py @@ -3,16 +3,17 @@ Tests that rvalue references are supported in C++ """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class RvalueReferencesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) #rdar://problem/11479676 - @expectedFailureIcc("ICC (13.1, 14-beta) do not emit DW_TAG_rvalue_reference_type.") - @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(compiler="icc", bugnumber="ICC (13.1, 14-beta) do not emit DW_TAG_rvalue_reference_type.") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_with_run_command(self): """Test that rvalues are supported in the C++ expression parser""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py index 66d4a1591575..d075eb65b848 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py +++ b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py @@ -2,15 +2,16 @@ Test scopes in C++. """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class TestCppScopes(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureDarwin - @expectedFailureWindows("llvm.org/pr24764") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_with_run_command(self): self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py b/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py index 51e6d4579e28..3158c4c5bcf0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py @@ -12,7 +12,7 @@ import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil -class UnsignedTypesTestCase(TestBase): +class SignedTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -48,7 +48,7 @@ class UnsignedTypesTestCase(TestBase): self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, substrs = [' resolved, hit count = 1']) - # Execute the assignment statement. + # Execute the puts(). self.runCmd("thread step-over") # Test that signed types display correctly. diff --git a/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py b/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py index 1c41b1b6f571..dd220d905278 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py +++ b/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py @@ -8,15 +8,16 @@ 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 CPPStaticMembersTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @unittest2.expectedFailure # llvm.org/pr15401 - @expectedFailureWindows("llvm.org/pr21765") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_with_run_command(self): """Test that member variables have the correct layout, scope and qualifiers when stopped inside and outside C++ methods""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py b/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py index dba556431e39..9784be189cb4 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py +++ b/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py @@ -3,8 +3,9 @@ Tests expressions that distinguish between static and non-static methods. """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class CPPStaticMethodsTestCase(TestBase): @@ -14,7 +15,7 @@ class CPPStaticMethodsTestCase(TestBase): TestBase.setUp(self) self.line = line_number('main.cpp', '// Break at this line') - @expectedFailureWindows + @expectedFailureAll(oslist=["windows"]) def test_with_run_command(self): """Test that static methods are properly distinguished from regular methods""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py index 6dba1398947e..e25820857025 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py @@ -9,8 +9,9 @@ from __future__ import print_function import unittest2 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 STLTestCase(TestBase): @@ -23,8 +24,7 @@ class STLTestCase(TestBase): self.source = 'main.cpp' self.line = line_number(self.source, '// Set break point at this line.') - # rdar://problem/10400981 - @unittest2.expectedFailure + @expectedFailureAll(bugnumber="rdar://problem/10400981") def test(self): """Test some expressions involving STL data types.""" self.build() @@ -67,7 +67,7 @@ class STLTestCase(TestBase): self.expect('expr associative_array["hello"]', substrs = [' = 2']) - @expectedFailureIcc # icc 13.1 and 14-beta do not emit DW_TAG_template_type_parameter + @expectedFailureAll(compiler="icc", bugnumber="ICC (13.1, 14-beta) do not emit DW_TAG_template_type_parameter.") @add_test_categories(['pyapi']) def test_SBType_template_aspects(self): """Test APIs for getting template arguments from an SBType.""" diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py index d7435c467274..865516de4edc 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py @@ -51,7 +51,8 @@ class StdCXXDisassembleTestCase(TestBase): # Disassemble the functions on the call stack. self.runCmd("thread backtrace") - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) depth = thread.GetNumFrames() for i in range(depth - 1): frame = thread.GetFrameAtIndex(i) diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/Makefile b/packages/Python/lldbsuite/test/lang/cpp/template/Makefile new file mode 100644 index 000000000000..194af7b32398 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/template/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +CFLAGS_EXTRAS += $(NO_LIMIT_DEBUG_INFO_FLAGS) + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py new file mode 100644 index 000000000000..e08d3a10786c --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py @@ -0,0 +1,87 @@ +""" +Test that C++ template classes that have integer parameters work correctly. + +We must reconstruct the types correctly so the template types are correct +and display correctly, and also make sure the expression parser works and +is able the find all needed functions when evaluating expressions +""" +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TemplateArgsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def prepareProcess(self): + self.build() + + # Create a target by the debugger. + exe = os.path.join(os.getcwd(), "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. + line = line_number('main.cpp', '// Breakpoint 1') + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=True) + + arguments = None + environment = None + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple (arguments, environment, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + # Get the thread of the process + self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + + # Get frame for current thread + return thread.GetSelectedFrame() + + def test_integer_args(self): + frame = self.prepareProcess() + + testpos = frame.FindVariable('testpos') + self.assertTrue(testpos.IsValid(), 'make sure we find a local variabble named "testpos"') + self.assertTrue(testpos.GetType().GetName() == 'TestObj<1>') + + expr_result = frame.EvaluateExpression("testpos.getArg()") + self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "testpos.getArg()"'); + self.assertTrue(expr_result.GetValue() == "1", "testpos.getArg() == 1") + self.assertTrue(expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"') + + testneg = frame.FindVariable('testneg') + self.assertTrue(testneg.IsValid(), 'make sure we find a local variabble named "testneg"') + self.assertTrue(testneg.GetType().GetName() == 'TestObj<-1>') + + expr_result = frame.EvaluateExpression("testneg.getArg()") + self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "testneg.getArg()"'); + self.assertTrue(expr_result.GetValue() == "-1", "testneg.getArg() == -1") + self.assertTrue(expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"') + + # Gcc does not generate the necessary DWARF attribute for enum template parameters. + @expectedFailureAll(bugnumber="llvm.org/pr28354", compiler="gcc") + def test_enum_args(self): + frame = self.prepareProcess() + + # Make sure "member" can be displayed and also used in an expression correctly + member = frame.FindVariable('member') + self.assertTrue(member.IsValid(), 'make sure we find a local variabble named "member"') + self.assertTrue(member.GetType().GetName() == 'EnumTemplate<EnumType::Member>') + + expr_result = frame.EvaluateExpression("member.getMember()") + self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "member.getMember()"'); + self.assertTrue(expr_result.GetValue() == "123", "member.getMember() == 123") + self.assertTrue(expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"') + + # Make sure "subclass" can be displayed and also used in an expression correctly + subclass = frame.FindVariable('subclass') + self.assertTrue(subclass.IsValid(), 'make sure we find a local variabble named "subclass"') + self.assertTrue(subclass.GetType().GetName() == 'EnumTemplate<EnumType::Subclass>') + + expr_result = frame.EvaluateExpression("subclass.getMember()") + self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "subclass.getMember()"'); + self.assertTrue(expr_result.GetValue() == "246", "subclass.getMember() == 246") + self.assertTrue(expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"') diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp new file mode 100644 index 000000000000..9c33a6420912 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp @@ -0,0 +1,72 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +template <int Arg> +class TestObj +{ +public: + int getArg() + { + return Arg; + } +}; + +//---------------------------------------------------------------------- +// Define a template class that we can specialize with an enumeration +//---------------------------------------------------------------------- +enum class EnumType +{ + Member, + Subclass +}; + +template <EnumType Arg> class EnumTemplate; + +//---------------------------------------------------------------------- +// Specialization for use when "Arg" is "EnumType::Member" +//---------------------------------------------------------------------- +template <> +class EnumTemplate<EnumType::Member> +{ +public: + EnumTemplate(int m) : + m_member(m) + { + } + + int getMember() const + { + return m_member; + } + +protected: + int m_member; +}; + +//---------------------------------------------------------------------- +// Specialization for use when "Arg" is "EnumType::Subclass" +//---------------------------------------------------------------------- +template <> +class EnumTemplate<EnumType::Subclass> : + public EnumTemplate<EnumType::Member> +{ +public: + EnumTemplate(int m) : EnumTemplate<EnumType::Member>(m) + { + } +}; + +int main(int argc, char **argv) +{ + TestObj<1> testpos; + TestObj<-1> testneg; + EnumTemplate<EnumType::Member> member(123); + EnumTemplate<EnumType::Subclass> subclass(123*2); + return testpos.getArg() - testneg.getArg() + member.getMember()*2 - subclass.getMember(); // Breakpoint 1 +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py b/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py index 07cc2e8e9788..5f89371aa85b 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py +++ b/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py @@ -2,19 +2,18 @@ Tests that C++ member and static variables are available where they should be. """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class CPPThisTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) #rdar://problem/9962849 - @expectedFailureGcc # llvm.org/pr15439 The 'this' pointer isn't available during expression evaluation when stopped in an inlined member function. - @expectedFailureIcc # ICC doesn't emit correct DWARF inline debug info for inlined member functions - @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") - @expectedFlakeyClang(bugnumber='llvm.org/pr23012', compiler_version=['>=','3.6']) # failed with totclang - clang3.7 + @expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr15439 The 'this' pointer isn't available during expression evaluation when stopped in an inlined member function") + @expectedFailureAll(compiler="icc", bugnumber="ICC doesn't emit correct DWARF inline debug info for inlined member functions.") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_with_run_command(self): """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/rdar12991846/Makefile b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/Makefile index 1476447db355..1476447db355 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/rdar12991846/Makefile +++ b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/Makefile diff --git a/packages/Python/lldbsuite/test/lang/cpp/rdar12991846/TestRdar12991846.py b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py index 636a82b425da..1ae133f0b078 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/rdar12991846/TestRdar12991846.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py @@ -7,11 +7,11 @@ 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 # this test case fails because of rdar://12991846 # the expression parser does not deal correctly with Unicode expressions @@ -26,26 +26,23 @@ import lldbsuite.test.lldbutil as lldbutil # [5] = e\0\0\0 #} -class Rdar12991846TestCase(TestBase): +class UnicodeLiteralsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @unittest2.expectedFailure("rdar://18684408") - @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_expr1(self): """Test that the expression parser returns proper Unicode strings.""" self.build() self.rdar12991846(expr=1) - @unittest2.expectedFailure("rdar://18684408") - @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_expr2(self): """Test that the expression parser returns proper Unicode strings.""" self.build() self.rdar12991846(expr=2) - @unittest2.expectedFailure("rdar://18684408") - @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_expr3(self): """Test that the expression parser returns proper Unicode strings.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/rdar12991846/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/main.cpp index fda951a78991..fda951a78991 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/rdar12991846/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/main.cpp diff --git a/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py b/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py index c137592558ed..30aadb389680 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py @@ -9,6 +9,7 @@ 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 @@ -22,6 +23,7 @@ class UnsignedTypesTestCase(TestBase): # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') + @expectedFailureAll(oslist=["windows"]) def test(self): """Test that variables with unsigned types display correctly.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py index 1553a43e1a73..bee148773f03 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py @@ -7,8 +7,9 @@ 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 def Msg(expr, val): return "'expression %s' matches the output (from compiled code): %s" % (expr, val) @@ -21,9 +22,6 @@ class CppVirtualMadness(TestBase): # printf() stmts (see main.cpp). pattern = re.compile("^([^=]*) = '([^=]*)'$") - # Assert message. - PRINTF_OUTPUT_GROKKED = "The printf output from compiled code is parsed correctly" - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -31,7 +29,7 @@ class CppVirtualMadness(TestBase): self.source = 'main.cpp' self.line = line_number(self.source, '// Set first breakpoint here.') - @expectedFailureIcc('llvm.org/pr16808') # lldb does not call the correct virtual function with icc + @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr16808 lldb does not call the correct virtual function with icc.") @expectedFailureAll(oslist=['windows']) def test_virtual_madness(self): """Test that expression works correctly with virtual inheritance as well as virtual function.""" @@ -57,11 +55,13 @@ class CppVirtualMadness(TestBase): thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") - # First, capture the golden output from the program itself from the - # series of printf statements. - stdout = process.GetSTDOUT(1024) - - self.assertIsNotNone(stdout, "Encountered an error reading the process's output") + # First, capture the golden output from the program itself. + golden = thread.GetFrameAtIndex(0).FindVariable("golden") + self.assertTrue(golden.IsValid(), "Encountered an error reading the process's golden variable") + error = lldb.SBError() + golden_str = process.ReadCStringFromMemory(golden.AddressOf().GetValueAsUnsigned(), 4096, error); + self.assertTrue(error.Success()) + self.assertTrue("c_as_C" in golden_str) # This golden list contains a list of "my_expr = 'value' pairs extracted # from the golden output. @@ -71,7 +71,7 @@ class CppVirtualMadness(TestBase): # # my_expr = 'value' # - for line in stdout.split(os.linesep): + for line in golden_str.split(os.linesep): match = self.pattern.search(line) if match: my_expr, val = match.group(1), match.group(2) diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/virtual/main.cpp index bed1422dcbdd..0adf41577314 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/virtual/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual/main.cpp @@ -84,17 +84,20 @@ int main (int argc, char const *argv[], char const *envp[]) C *c_as_C = new C(); A *c_as_A = c_as_C; - printf ("a_as_A->a() = '%s'\n", a_as_A->a()); - printf ("a_as_A->b() = '%s'\n", a_as_A->b()); - printf ("a_as_A->c() = '%s'\n", a_as_A->c()); - printf ("b_as_A->a() = '%s'\n", b_as_A->a()); - printf ("b_as_A->b() = '%s'\n", b_as_A->b()); - printf ("b_as_A->c() = '%s'\n", b_as_A->c()); - printf ("b_as_B->aa() = '%s'\n", b_as_B->aa()); - printf ("c_as_A->a() = '%s'\n", c_as_A->a()); - printf ("c_as_A->b() = '%s'\n", c_as_A->b()); - printf ("c_as_A->c() = '%s'\n", c_as_A->c()); - printf ("c_as_C->aa() = '%s'\n", c_as_C->aa()); + char golden[4096]; + char *p = golden; + char *end = p + sizeof golden; + p += snprintf(p, end-p, "a_as_A->a() = '%s'\n", a_as_A->a()); + p += snprintf(p, end-p, "a_as_A->b() = '%s'\n", a_as_A->b()); + p += snprintf(p, end-p, "a_as_A->c() = '%s'\n", a_as_A->c()); + p += snprintf(p, end-p, "b_as_A->a() = '%s'\n", b_as_A->a()); + p += snprintf(p, end-p, "b_as_A->b() = '%s'\n", b_as_A->b()); + p += snprintf(p, end-p, "b_as_A->c() = '%s'\n", b_as_A->c()); + p += snprintf(p, end-p, "b_as_B->aa() = '%s'\n", b_as_B->aa()); + p += snprintf(p, end-p, "c_as_A->a() = '%s'\n", c_as_A->a()); + p += snprintf(p, end-p, "c_as_A->b() = '%s'\n", c_as_A->b()); + p += snprintf(p, end-p, "c_as_A->c() = '%s'\n", c_as_A->c()); + p += snprintf(p, end-p, "c_as_C->aa() = '%s'\n", c_as_C->aa()); puts("");// Set first breakpoint here. // then evaluate: // expression a_as_A->a() diff --git a/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py b/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py index cbd244a7e056..f2e5613ffd61 100644 --- a/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py +++ b/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py @@ -3,8 +3,9 @@ import os, time import unittest2 import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class TestGoUserExpression(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py b/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py index 8b869df4ef8f..2578742467d9 100644 --- a/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py +++ b/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py @@ -3,8 +3,9 @@ import os, time import unittest2 import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class TestGoLanguage(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.py b/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.py index 35961ebd1d92..8aff2e514bb9 100644 --- a/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.py +++ b/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.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 TestGoASTContext(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime b/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime index 44797077a641..30381ccd24c0 100644 --- a/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime +++ b/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime @@ -11,7 +11,7 @@ class TestGoLanguageRuntime(TestBase): mydir = TestBase.compute_mydir(__file__) @python_api_test - @expectedFailureFreeBSD('llvm.org/pr24895') + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24895') @skipIfRemote # Not remote test suite ready @skipUnlessGoInstalled def test_with_dsym_and_python_api(self): diff --git a/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py b/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py index 8da31e9e81f7..bf7bc93a44b4 100644 --- a/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py +++ b/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.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 TestGoASTContext(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py new file mode 100644 index 000000000000..01bf241b0381 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows, decorators.expectedFailureAll(bugnumber="rdar://problem/17990991")]) diff --git a/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m new file mode 100644 index 000000000000..9ee3bbe66770 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m @@ -0,0 +1,52 @@ +//===-- main.m -------------------------------------------*- Objective-C-*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import <Foundation/Foundation.h> + +@interface HasBitfield : NSObject { +@public + unsigned field1 : 1; + unsigned field2 : 1; +}; + +-(id)init; +@end + +@implementation HasBitfield +-(id)init { + self = [super init]; + field1 = 0; + field2 = 1; + return self; +} +@end + +@interface ContainsAHasBitfield : NSObject { +@public + HasBitfield *hb; +}; +-(id)init; +@end + +@implementation ContainsAHasBitfield +-(id)init { + self = [super init]; + hb = [[HasBitfield alloc] init]; + return self; +} + +@end + +int main(int argc, const char * argv[]) { + ContainsAHasBitfield *chb = [[ContainsAHasBitfield alloc] init]; + printf("%d\n", chb->hb->field2); //% self.expect("expression -- chb->hb->field1", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 0"]) + //% self.expect("expression -- chb->hb->field2", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 1"]) # this must happen second + return 0; +} + diff --git a/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py b/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py index 6a1cde1a3cb3..9fa03071c598 100644 --- a/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py +++ b/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.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 TestObjCIvarsInBlocks(TestBase): @@ -23,7 +24,7 @@ class TestObjCIvarsInBlocks(TestBase): @skipUnlessDarwin @add_test_categories(['pyapi']) - @expectedFailurei386 # This test requires the 2.0 runtime, so it will fail on i386. + @expectedFailureAll(archs=["i[3-6]86"], bugnumber="This test requires the 2.0 runtime, so it will fail on i386") def test_with_python_api(self): """Test printing the ivars of the self when captured in blocks""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py b/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py index 207518abc91b..c153f9856603 100644 --- a/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py +++ b/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.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 ForwardDeclTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py index a9298dd81cf8..4a62d6240d98 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py @@ -9,8 +9,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 ConstStringTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py index 88db12e95931..0867eec62ebe 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py @@ -9,8 +9,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 @skipUnlessDarwin class FoundationDisassembleTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py index 8358bd5e923f..2a8e80f6d76e 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py @@ -10,8 +10,9 @@ from __future__ import print_function import os, os.path, time import lldb import string +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil file_index = 0 @skipUnlessDarwin diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py index b61a7702f1fe..1ee01f7f35f6 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py @@ -8,8 +8,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 @skipUnlessDarwin class FoundationTestCase2(TestBase): @@ -89,6 +90,7 @@ class FoundationTestCase2(TestBase): patterns = ["\(int\) \$.* = 3"]) self.runCmd("process continue") + @expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27861") def test_NSString_expr_commands(self): """Test expression commands for NSString.""" self.build() @@ -134,7 +136,7 @@ class FoundationTestCase2(TestBase): patterns = ["\(MyString\) \$.* = ", "\(MyBase\)", "\(NSObject\)", "\(Class\)"]) self.runCmd("process continue") - @expectedFailurei386 + @expectedFailureAll(archs=["i[3-6]86"]) def test_NSError_po(self): """Test that po of the result of an unknown method doesn't require a cast.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py index a85f0fec9636..13ef44f195bb 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ObjectDescriptionAPITestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py index 8f191721d89b..8b37f9309ac6 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py @@ -8,14 +8,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 @skipUnlessDarwin class RuntimeTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + @expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27862") def test_break(self): """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" if self.getArchitecture() != 'x86_64': diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py index 72952c1878b1..b75a874c8145 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py @@ -6,9 +6,13 @@ from __future__ import print_function -import os, time +import os +import time + import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil @skipUnlessDarwin class FoundationSymtabTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py index c4c581b9240f..24ae1a8852b1 100644 --- a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py +++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.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 TestObjCGlobalVar(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py b/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py index e85dd8f48dec..ee5589cb96cb 100644 --- a/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py +++ b/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py @@ -5,11 +5,14 @@ from __future__ import print_function import unittest2 -import os, time +import os +import subprocess +import time + import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil -import subprocess +from lldbsuite.test import lldbutil class HiddenIvarsTestCase(TestBase): @@ -26,8 +29,7 @@ class HiddenIvarsTestCase(TestBase): self.shlib_names = ["InternalDefiner"] @skipUnlessDarwin - @skipIfDwarf # This test requires a stripped binary and a dSYM - @skipIfDWO # This test requires a stripped binary and a dSYM + @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") def test_expr_stripped(self): if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") @@ -44,8 +46,7 @@ class HiddenIvarsTestCase(TestBase): self.expr(False) @skipUnlessDarwin - @skipIfDwarf # This test requires a stripped binary and a dSYM - @skipIfDWO # This test requires a stripped binary and a dSYM + @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") def test_frame_variable_stripped(self): if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py index 9ed2bb98e6e1..b91725d57c60 100644 --- a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py @@ -8,10 +8,12 @@ from __future__ import print_function import os, time import re + import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.support import seven +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.support.seven as seven +from lldbsuite.test import lldbutil def execute_command (command): # print('%% %s' % (command)) diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py b/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py index 2c052aae3ba1..fece47625a84 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py @@ -4,15 +4,15 @@ from __future__ import print_function +from distutils.version import StrictVersion import unittest2 import os, time import lldb import platform -import lldbsuite.test.lldbutil as lldbutil - -from distutils.version import StrictVersion +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ObjCModulesAutoImportTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py index 8667e628d464..56fcaa050782 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py @@ -5,14 +5,12 @@ from __future__ import print_function import unittest2 -import os, time -import lldb import platform -import lldbsuite.test.lldbutil as lldbutil - from distutils.version import StrictVersion +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class IncompleteModulesTestCase(TestBase): @@ -27,6 +25,7 @@ class IncompleteModulesTestCase(TestBase): @skipUnlessDarwin @unittest2.expectedFailure("rdar://20416388") @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") + @skipIfDarwin # llvm.org/pr26267 def test_expr(self): self.build() exe = os.path.join(os.getcwd(), "a.out") diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py index d9d94a8cf321..6a9d9b518e1c 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py @@ -4,15 +4,16 @@ from __future__ import print_function +from distutils.version import StrictVersion + import unittest2 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 ModulesInlineFunctionsTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py b/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py index 04fc07281811..0efdb305584b 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py @@ -6,13 +6,13 @@ from __future__ import print_function import unittest2 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 ObjCModulesTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py b/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py index 38ef853ae112..c702eafa1f22 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py @@ -8,8 +8,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 ObjCXXTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py b/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py index 5d2414eed8f5..fa390cb0ad73 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ObjCDynamicValueTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py b/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py index f7ce2809081a..3ff76d4194d2 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.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 TestObjCBuiltinTypes(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py b/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py index 533ec2f6b7c4..901d84fb96d9 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ObjCCheckerTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py b/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py index 2a978bc9c024..a5767562c077 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.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 TestObjCClassMethod(TestBase): @@ -21,7 +22,7 @@ class TestObjCClassMethod(TestBase): self.break_line = line_number(self.main_source, '// Set breakpoint here.') @skipUnlessDarwin - @expectedFailurei386 + @expectedFailureAll(archs=["i[3-6]86"]) @add_test_categories(['pyapi']) #rdar://problem/9745789 "expression" can't call functions in class methods def test_with_python_api(self): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py b/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py index b9e84541e2df..fc8a8129fa3c 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py @@ -8,8 +8,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 @skipUnlessDarwin class ObjCDynamicSBTypeTestCase(TestBase): @@ -25,7 +26,7 @@ class ObjCDynamicSBTypeTestCase(TestBase): self.main_source = "main.m" self.line = line_number(self.main_source, '// Set breakpoint here.') - @skipIfi386 + @skipIf(archs="i[3-6]86") def test_dyn(self): """Test that we are able to properly report a usable dynamic type.""" d = {'EXE': self.exe_name} diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py b/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py index acddfb8bd647..8720ede04cbf 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ObjCDynamicValueTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py index 6be1d379c8eb..049b41e08d08 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.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 TestObjCIvarOffsets(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py index 80305e303d03..791ce27dad00 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-protocols/TestIvarProtocols.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.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py index 78c7123eefca..d9007c57bfb4 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.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 TestObjCIvarStripped(TestBase): @@ -21,8 +22,7 @@ class TestObjCIvarStripped(TestBase): self.stop_line = line_number(self.main_source, '// Set breakpoint here.') @skipUnlessDarwin - @skipIfDwarf # This test requires a stripped binary and a dSYM - @skipIfDWO # This test requires a stripped binary and a dSYM + @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") @add_test_categories(['pyapi']) def test_with_python_api(self): """Test that we can find stripped Objective-C ivars in the runtime""" diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py b/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py index ca77de261829..a0cf6a7a055d 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py @@ -6,13 +6,14 @@ from __future__ import print_function import unittest2 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 ObjCNewSyntaxTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py b/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py index a4a202e3f940..2c3ac27d418f 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py @@ -13,10 +13,12 @@ from __future__ import print_function import os, time import lldb -from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil import re +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + # rdar://problem/9087739 # test failure: objc_optimized does not work for "-C clang -A i386" @skipUnlessDarwin diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py b/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py index c22a1f1ad532..22fe3136a511 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py @@ -9,8 +9,9 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ObjCPropertyTestCase(TestBase): @@ -112,3 +113,17 @@ class ObjCPropertyTestCase(TestBase): idWithProtocol_error = idWithProtocol_value.GetError() self.assertTrue (idWithProtocol_error.Success()) self.assertTrue (idWithProtocol_value.GetTypeName() == "id") + + # Make sure that class property getter works as expected + value = frame.EvaluateExpression("BaseClass.classInt", False) + self.assertTrue (value.GetError().Success()) + self.assertTrue (value.GetValueAsUnsigned (11111) == 123) + + # Make sure that class property setter works as expected + value = frame.EvaluateExpression("BaseClass.classInt = 234", False) + self.assertTrue (value.GetError().Success()) + + # Verify that setter above actually worked + value = frame.EvaluateExpression("BaseClass.classInt", False) + self.assertTrue (value.GetError().Success()) + self.assertTrue (value.GetValueAsUnsigned (11111) == 234) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m b/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m index 2ef142be9b00..8d14759fb384 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m +++ b/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m @@ -6,6 +6,8 @@ @end +static int _class_int = 123; + @interface BaseClass : NSObject { int _backedInt; @@ -25,6 +27,7 @@ @property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt; @property int backedInt; @property (nonatomic, assign) id <MyProtocol> idWithProtocol; +@property(class) int classInt; @end @implementation BaseClass @@ -68,6 +71,16 @@ _access_count++; } ++ (int) classInt +{ + return _class_int; +} + ++ (void) setClassInt:(int) n +{ + _class_int = n; +} + - (int) getAccessCount { return _access_count; diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py b/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py index 80305e303d03..791ce27dad00 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.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.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile b/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile index 81e7f12dea2b..6c5492dade11 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile +++ b/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/Makefile @@ -7,9 +7,10 @@ default: a.out.stripped a.out.stripped: a.out.dSYM strip -o a.out.stripped a.out + ln -sf a.out.dSYM a.out.stripped.dSYM clean:: rm -f a.out.stripped - rm -rf a.out.stripped.dSYM + rm -rf $(wildcard *.dSYM) include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py b/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py index 4bcc10b8b882..7d88292a051c 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.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 TestObjCStaticMethodStripped(TestBase): @@ -22,15 +23,14 @@ class TestObjCStaticMethodStripped(TestBase): @skipUnlessDarwin @add_test_categories(['pyapi']) - @skipIfDwarf # This test requires a stripped binary and a dSYM - @skipIfDWO # This test requires a stripped binary and a dSYM + @skipIf(debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") #<rdar://problem/12042992> def test_with_python_api(self): """Test calling functions in static methods with a stripped binary.""" if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") self.build() - exe = os.path.join(os.getcwd(), "a.out.stripped") + exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py b/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py index 89ef1e7b6898..ccba42db4ebe 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.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 TestObjCStaticMethod(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py b/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py index 1df416d45133..d035287cfa00 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.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 TestObjCStepping(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py b/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py index 36cde21c9d66..b2f2af766325 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.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 TestObjCStructArgument(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py b/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py index 010de2180825..5a8722e71a45 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.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 TestObjCClassMethod(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py b/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py index 84d147f632da..39a0fb716abe 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.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 TestObjCSuperMethod(TestBase): @@ -21,7 +22,7 @@ class TestObjCSuperMethod(TestBase): self.break_line = line_number(self.main_source, '// Set breakpoint here.') @skipUnlessDarwin - @expectedFailurei386 + @expectedFailureAll(archs=["i[3-6]86"]) @add_test_categories(['pyapi']) def test_with_python_api(self): """Test calling methods on super.""" diff --git a/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py b/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py index 5c52cc0e0697..33f7a0519fa8 100644 --- a/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py +++ b/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py @@ -8,7 +8,9 @@ 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 @skipUnlessDarwin class PrintObjTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py b/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py index 38551f671a92..32f2e7c8d6dc 100644 --- a/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py +++ b/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py @@ -8,8 +8,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 @skipUnlessDarwin class MethodReturningBOOLTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py b/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py index 0902527d424c..a4654d4bd1b4 100644 --- a/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py @@ -8,8 +8,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 @skipUnlessDarwin class Rdar10967107TestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py b/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py index 42120a57834c..f1d38f8b7d32 100644 --- a/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py @@ -8,8 +8,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 @skipUnlessDarwin class Rdar10967107TestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py index b95d95106032..7bc92595ef38 100644 --- a/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py @@ -8,8 +8,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 @skipUnlessDarwin class Rdar12408181TestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py b/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py index 30fd2a5b0f6d..c8f9a9c82c61 100644 --- a/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py +++ b/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.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 TestRealDefinition(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py b/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py index 37db151f9ae3..004563c55be2 100644 --- a/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py +++ b/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py @@ -2,8 +2,9 @@ Tests that ObjC member variables are available where they should be. """ import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class ObjCSelfTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/Makefile b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/Makefile new file mode 100644 index 000000000000..ad3cb3fadcde --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation diff --git a/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py new file mode 100644 index 000000000000..7c294ef8cc64 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py @@ -0,0 +1,68 @@ +"""Test that we properly vend children for a single entry NSDictionary""" + +from __future__ import print_function + + + +import unittest2 +import os, time +import platform + +from distutils.version import StrictVersion + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class ObjCSingleEntryDictionaryTestCase(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.m', '// break here') + + @skipUnlessDarwin + def test_single_entry_dict(self): + self.build() + exe = os.path.join(os.getcwd(), "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.m", 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']) + + d1 = self.frame().FindVariable("d1") + d1.SetPreferSyntheticValue(True) + d1.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) + + self.assertTrue(d1.GetNumChildren() == 1, "dictionary has != 1 child elements") + pair = d1.GetChildAtIndex(0) + pair.SetPreferSyntheticValue(True) + pair.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) + + self.assertTrue(pair.GetNumChildren() == 2, "pair has != 2 child elements") + + key = pair.GetChildMemberWithName("key") + value = pair.GetChildMemberWithName("value") + + key.SetPreferSyntheticValue(True) + key.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) + value.SetPreferSyntheticValue(True) + value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) + + self.assertTrue(key.GetSummary() == '@"key"', "key doesn't contain key") + self.assertTrue(value.GetSummary() == '@"value"', "value doesn't contain value") diff --git a/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/main.m b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/main.m new file mode 100644 index 000000000000..be472fd43c3d --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/main.m @@ -0,0 +1,7 @@ +#import <Foundation/Foundation.h> + +int main() { + NSDictionary *d1 = @{@"key" : @"value"}; + NSLog(@"%@\n", d1); // break here + return 0; +} diff --git a/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py b/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py new file mode 100644 index 000000000000..791ce27dad00 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/variadic_methods/TestVariadicMethods.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m b/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m new file mode 100644 index 000000000000..f48710e880f3 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m @@ -0,0 +1,31 @@ +//===-- main.m -------------------------------------------*- Objective-C-*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import <Foundation/Foundation.h> + +@interface VarClass : NSObject +- (id) lottaArgs: (id) first, ...; +@end + +@implementation VarClass +- (id) lottaArgs: (id) first, ... +{ + return first; +} +@end + +int +main() +{ + VarClass *my_var = [[VarClass alloc] init]; + id something = [my_var lottaArgs: @"111", @"222", nil]; + NSLog (@"%@ - %@", my_var, something); //% self.expect("expression -O -- [my_var lottaArgs:@\"111\", @\"222\", nil]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["111"]) + return 0; +} + diff --git a/packages/Python/lldbsuite/test/lang/objcxx/objcxx-ivar-vector/TestIvarVector.py b/packages/Python/lldbsuite/test/lang/objcxx/objcxx-ivar-vector/TestIvarVector.py index 80305e303d03..49bc148dd579 100644 --- a/packages/Python/lldbsuite/test/lang/objcxx/objcxx-ivar-vector/TestIvarVector.py +++ b/packages/Python/lldbsuite/test/lang/objcxx/objcxx-ivar-vector/TestIvarVector.py @@ -1,4 +1,4 @@ -import lldbsuite.test.lldbinline as lldbinline -import lldbsuite.test.lldbtest as lldbtest +from lldbsuite.test import decorators +from lldbsuite.test import lldbinline -lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) |