diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/cpp')
79 files changed, 776 insertions, 183 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py b/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py index 1fb7a5217495c..b10b4986d3789 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py +++ b/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py @@ -18,7 +18,7 @@ class CPPAutoTestCase(TestBase): def test_with_run_command(self): """Test that auto types work in the expression parser""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) line = line_number('main.cpp', '// break here') lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp index 76fb95e0a34c1..6aee25c216087 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp @@ -12,5 +12,10 @@ int main() { std::string helloworld("hello world"); + + // Ensure std::string copy constructor is present in the binary, as we will + // use it in an expression. + std::string other = helloworld; + return 0; // break here } diff --git a/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py b/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py index 01f8cbacc3601..27ea773c5dbfa 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py +++ b/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py @@ -13,7 +13,7 @@ class CPPBoolTestCase(TestBase): def test_with_run_command(self): """Test that bool types work in the expression parser""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) line = line_number('main.cpp', '// breakpoint 1') lldbutil.run_break_set_by_file_and_line( 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 81787e1e22607..a12051014dab3 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py +++ b/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py @@ -35,7 +35,7 @@ class CPPBreakpointCommandsTestCase(TestBase): """Test a sequence of breakpoint command add, list, and delete.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. 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 b86cd2ac9c773..9b227bc8d3c87 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py +++ b/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py @@ -22,7 +22,7 @@ class CallCPPFunctionTestCase(TestBase): def test_with_run_command(self): """Test calling a function by basename""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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 0145bee3fc5cd..a344c4f7d18a0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py +++ b/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py @@ -18,9 +18,7 @@ class TestCppChainedCalls(TestBase): self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) 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 bf8605106adb9..e37e76ae9c0df 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py +++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py @@ -32,7 +32,7 @@ class Char1632TestCase(TestBase): def test(self): """Test that the C++11 support for char16_t and char32_t works correctly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) 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 d167f0a5591d0..97b0bfd8aee06 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py @@ -27,7 +27,7 @@ class StaticVariableTestCase(TestBase): def test_with_run_command(self): """Test that file and class static variables display correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) @@ -39,7 +39,7 @@ class StaticVariableTestCase(TestBase): substrs=['stopped', 'stop reason = breakpoint']) - # global variables are no longer displayed with the "frame variable" + # Global variables are no longer displayed with the "frame variable" # command. self.expect( 'target variable A::g_points', @@ -63,11 +63,57 @@ class StaticVariableTestCase(TestBase): compiler=["clang"], compiler_version=["<", "3.9"], bugnumber='llvm.org/pr20550') + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") + def test_with_run_command_complete(self): + """ + Test that file and class static variables display correctly with + complete debug information. + """ + self.build() + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.assertTrue(target, VALID_TARGET) + + # Global variables are no longer displayed with the "frame variable" + # command. + self.expect( + 'target variable A::g_points', + VARIABLES_DISPLAYED_CORRECTLY, + patterns=[ + '\(PointType \[[1-9]*\]\) A::g_points = {', '(x = 1, y = 2)', + '(x = 11, y = 22)' + ]) + + # Ensure that we take the context into account and only print + # A::g_points. + self.expect( + 'target variable A::g_points', + VARIABLES_DISPLAYED_CORRECTLY, + matching=False, + patterns=['(x = 3, y = 4)', '(x = 33, y = 44)']) + + # Finally, ensure that we print both points when not specifying a + # context. + self.expect( + 'target variable g_points', + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + '(PointType [2]) g_points', '(x = 1, y = 2)', + '(x = 11, y = 22)', '(x = 3, y = 4)', '(x = 33, y = 44)' + ]) + + @expectedFailureAll( + compiler=["gcc"], + bugnumber="Compiler emits incomplete debug info") + @expectedFailureAll( + compiler=["clang"], + compiler_version=["<", "3.9"], + bugnumber='llvm.org/pr20550') @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_with_python_api(self): """Test Python APIs on file and class static variables.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) 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 c915e4b32fad9..759da716b1872 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py @@ -24,7 +24,7 @@ class ClassTypesTestCase(TestBase): def test_with_run_command(self): """Test 'frame variable this' when stopped on a class constructor.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on the ctor function of class C. @@ -61,7 +61,7 @@ class ClassTypesTestCase(TestBase): def test_with_python_api(self): """Use Python APIs to create a breakpoint by (filespec, line).""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -72,7 +72,8 @@ class ClassTypesTestCase(TestBase): fsDir = os.path.normpath(filespec.GetDirectory()) fsFile = filespec.GetFilename() - self.assertTrue(fsDir == os.getcwd() and fsFile == "a.out", + self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact()) + and fsFile == "a.out", "FileSpec matches the executable") bpfilespec = lldb.SBFileSpec("main.cpp", False) @@ -119,7 +120,7 @@ class ClassTypesTestCase(TestBase): def test_with_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # rdar://problem/8516141 @@ -176,7 +177,7 @@ class ClassTypesTestCase(TestBase): def test_with_constructor_name(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -187,7 +188,8 @@ class ClassTypesTestCase(TestBase): fsDir = os.path.normpath(filespec.GetDirectory()) fsFile = filespec.GetFilename() - self.assertTrue(fsDir == os.getcwd() and fsFile == "a.out", + self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact()) + and fsFile == "a.out", "FileSpec matches the executable") bpfilespec = lldb.SBFileSpec("main.cpp", False) 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 bc85ba5181e52..c838178747533 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py @@ -78,7 +78,7 @@ class IterateFrameAndDisassembleTestCase(TestBase): def breakOnCtor(self): """Setup/run the program so it stops on C's constructor.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on the ctor function of class C. diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp index 251e66c3c9f7b..2d02cbe0f0558 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp @@ -90,7 +90,7 @@ public: B(ai, bi), m_c_int(ci) { - printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. + std::printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. } //virtual diff --git a/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py b/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py index c6f9d85cd2c8c..c1d0d23626840 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py +++ b/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py @@ -13,7 +13,7 @@ class CPPTestDiamondInheritance(TestBase): def test_with_run_command(self): """Test that virtual base classes work in when SBValue objects are used to explore the variable value""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile new file mode 100644 index 0000000000000..314f1cb2f077b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py new file mode 100644 index 0000000000000..358b3b2d93ae8 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py @@ -0,0 +1,66 @@ +""" +Make sure if we have two classes with the same base name the +dynamic value calculator doesn't confuse them +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +class DynamicValueSameBaseTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # If your test case doesn't stress debug info, the + # set this to true. That way it won't be run once for + # each debug info format. + NO_DEBUG_INFO_TESTCASE = True + + def test_same_basename_this(self): + """Test that the we use the full name to resolve dynamic types.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + self.sample_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def sample_test(self): + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "Break here to get started", self.main_source_file) + + # Set breakpoints in the two class methods and run to them: + namesp_bkpt = target.BreakpointCreateBySourceRegex("namesp function did something.", self.main_source_file) + self.assertEqual(namesp_bkpt.GetNumLocations(), 1, "Namespace breakpoint invalid") + + virtual_bkpt = target.BreakpointCreateBySourceRegex("Virtual function did something.", self.main_source_file) + self.assertEqual(virtual_bkpt.GetNumLocations(), 1, "Virtual breakpoint invalid") + + threads = lldbutil.continue_to_breakpoint(process, namesp_bkpt) + self.assertEqual(len(threads), 1, "Didn't stop at namespace breakpoint") + + frame = threads[0].frame[0] + namesp_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget) + # Clang specifies the type of this as "T *", gcc as "T * const". This + # erases the difference. + namesp_type = namesp_this.GetType().GetUnqualifiedType() + self.assertEqual(namesp_type.GetName(), "namesp::Virtual *", "Didn't get the right dynamic type") + + threads = lldbutil.continue_to_breakpoint(process, virtual_bkpt) + self.assertEqual(len(threads), 1, "Didn't stop at virtual breakpoint") + + frame = threads[0].frame[0] + virtual_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget) + virtual_type = virtual_this.GetType().GetUnqualifiedType() + self.assertEqual(virtual_type.GetName(), "Virtual *", "Didn't get the right dynamic type") + + + diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/main.cpp new file mode 100644 index 0000000000000..38e46c03f41ed --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/main.cpp @@ -0,0 +1,32 @@ +#include <stdio.h> + +namespace namesp +{ + class Virtual { + public: + virtual void doSomething() { + printf ("namesp function did something.\n"); + } + }; +} + +class Virtual { + public: + virtual void doSomething() { + printf("Virtual function did something.\n"); + } +}; + +int +main() +{ + namesp::Virtual my_outer; + Virtual my_virtual; + + // Break here to get started + my_outer.doSomething(); + my_virtual.doSomething(); + + return 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 74b94517fa0f1..497f17f4454c5 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py @@ -19,8 +19,7 @@ class CppValueCastTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @unittest2.expectedFailure( - "rdar://problem/10808472 SBValue::Cast test case is failing (virtual inheritance)") + @skipIf(bugnumber="llvm.org/PR36714") @add_test_categories(['pyapi']) def test_value_cast_with_virtual_inheritance(self): """Test SBValue::Cast(SBType) API for C++ types with virtual inheritance.""" @@ -51,7 +50,7 @@ class CppValueCastTestCase(TestBase): def do_sbvalue_cast(self, exe_name): """Test SBValue::Cast(SBType) API for C++ types.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Create a target from the debugger. 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 42db14f21e0c3..acda4261b1135 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py @@ -37,7 +37,7 @@ class DynamicValueTestCase(TestBase): def test_get_dynamic_vals(self): """Test fetching C++ dynamic values from pointers & references.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py b/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py index 82e44fb1759fc..b6bb2e8f30911 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py @@ -6,6 +6,7 @@ from __future__ import print_function import os import time import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil @@ -14,6 +15,7 @@ class CPP11EnumTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int8_t(self): """Test C++11 enumeration class types as int8_t types.""" self.build( @@ -21,6 +23,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int8_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int16_t(self): """Test C++11 enumeration class types as int16_t types.""" self.build( @@ -28,6 +31,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int16_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int32_t(self): """Test C++11 enumeration class types as int32_t types.""" self.build( @@ -35,6 +39,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int32_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int64_t(self): """Test C++11 enumeration class types as int64_t types.""" self.build( @@ -42,6 +47,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int64_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint8_t(self): """Test C++11 enumeration class types as uint8_t types.""" self.build( @@ -49,6 +55,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint8_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint16_t(self): """Test C++11 enumeration class types as uint16_t types.""" self.build( @@ -56,6 +63,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint16_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint32_t(self): """Test C++11 enumeration class types as uint32_t types.""" self.build( @@ -63,6 +71,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint32_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint64_t(self): """Test C++11 enumeration class types as uint64_t types.""" self.build( @@ -78,7 +87,7 @@ class CPP11EnumTypesTestCase(TestBase): def image_lookup_for_enum_type(self): """Test C++11 enumeration class types.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. diff --git a/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py b/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py index 4bc33205319cf..d1aea00b0e8f5 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py +++ b/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py @@ -30,7 +30,7 @@ class CPPBreakpointTestCase(TestBase): def test(self): """Test lldb exception breakpoint command for CPP.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. 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 c37107e898c23..6352b68e7d753 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 @@ -13,7 +13,7 @@ class FrameVariableAnonymousUnionsTestCase(TestBase): def test_with_run_command(self): """Tests that frame variable looks into anonymous unions""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) line = line_number('main.cpp', '// break here') lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py index 810aefee0f07d..b90f74656cdf0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py +++ b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py @@ -1,6 +1,12 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators +# https://bugs.llvm.org/show_bug.cgi?id=35920 +# This test stresses expression evaluation support for template functions. +# Currently the support is rudimentary, and running this test causes assertion +# failures in clang. This test cannot be XFAIL'ed because the test harness +# treats assertion failures as unexpected events. For now, the test must be +# skipped. lldbinline.MakeInlineTest( __file__, globals(), [ - decorators.expectedFailureAll(bugnumber="rdar://problem/32096064")]) + decorators.skipIf]) 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 21d86f973a357..fa68d0a15021a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py +++ b/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py @@ -20,9 +20,7 @@ class TestCppGlobalOperators(TestBase): self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/Makefile b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/Makefile new file mode 100644 index 0000000000000..0497d78fec3cd --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +CXX_SOURCES = main.cpp +# CFLAGS_EXTRAS += $(MODULE_DEBUG_INFO_FLAGS) + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py new file mode 100644 index 0000000000000..69d04636d86b6 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py @@ -0,0 +1,6 @@ +import lldbsuite.test.lldbinline as lldbinline +from lldbsuite.test.decorators import * + +lldbinline.MakeInlineTest(__file__, globals(), [ + expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr36107", + debug_info="gmodules")]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/a.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/a.h new file mode 100644 index 0000000000000..7384f230801a7 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/a.h @@ -0,0 +1,7 @@ +#include "memory.h" + +class MemoryBuffer { int buffer = 42; }; + +struct SrcBuffer { + my_std::unique_ptr<MemoryBuffer> Buffer; +}; diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/b.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/b.h new file mode 100644 index 0000000000000..b777e8e34739a --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/b.h @@ -0,0 +1,6 @@ +#include "a.h" +#include "memory.h" + +class Module { + my_std::unique_ptr<MemoryBuffer> MBptr; +}; diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/main.cpp new file mode 100644 index 0000000000000..df75261657006 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/main.cpp @@ -0,0 +1,9 @@ +#include "b.h" + +int main(int argc, const char * argv[]) +{ + Module m; + // Test that the type Module which contains a field that is a + // template instantiation can be fully resolved. + return 0; //% self.assertTrue(self.frame().FindVariable('m').GetChildAtIndex(0).GetChildAtIndex(0).GetChildAtIndex(0).GetName() == 'buffer', 'find template specializations in imported modules') +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/memory.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/memory.h new file mode 100644 index 0000000000000..1d59dc0bbf0b2 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/memory.h @@ -0,0 +1,8 @@ +#ifndef MEMORY_H +#define MEMORY_H +namespace my_std { + template<class T> class unique_ptr { + T t; + }; +} +#endif diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/module.modulemap b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/module.modulemap new file mode 100644 index 0000000000000..2f05073a0b857 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/module.modulemap @@ -0,0 +1,11 @@ +module A { + header "a.h" +} + +module B { + header "b.h" +} + +module std { + header "memory.h" +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py b/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py index dcc9206867b3c..20207c54db903 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py @@ -9,17 +9,17 @@ class TestWithGmodulesDebugInfo(TestBase): mydir = TestBase.compute_mydir(__file__) + @skipIf(bugnumber="llvm.org/pr36146", oslist=["linux"], archs=["i386"]) @add_test_categories(["gmodules"]) def test_specialized_typedef_from_pch(self): self.build() - cwd = os.getcwd() - src_file = os.path.join(cwd, "main.cpp") + src_file = os.path.join(self.getSourceDir(), "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') + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) @@ -69,3 +69,26 @@ class TestWithGmodulesDebugInfo(TestBase): 42, memberValue.GetValueAsSigned(), "Member value incorrect") + + testValue = frame.EvaluateExpression("bar") + self.assertTrue( + testValue.GetError().Success(), + "Test expression value invalid: %s" % + (testValue.GetError().GetCString())) + self.assertTrue( + testValue.GetTypeName() == "Foo::Bar", + "Test expression type incorrect") + + memberValue = testValue.GetChildMemberWithName("i") + self.assertTrue( + memberValue.GetError().Success(), + "Member value missing or invalid: %s" % + (testValue.GetError().GetCString())) + self.assertTrue( + memberValue.GetTypeName() == "int", + "Member type incorrect") + self.assertEqual( + 123, + 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 index aa4013685171c..588a3a8e01fea 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp @@ -1,5 +1,8 @@ +class Foo::Bar { int i = 123; }; + int main(int argc, const char * argv[]) { IntContainer test(42); + Foo::Bar bar; 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 index a6c59b94c896f..dba4fee9a8c21 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h @@ -10,3 +10,8 @@ class GenericContainer { }; typedef GenericContainer<int> IntContainer; + +struct Foo { + class Bar; + Bar *bar; +}; diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile index bea4bf96e601e..2ce96e90d2d8e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile @@ -19,16 +19,16 @@ nolimit: main.o length_nolimit.o a.o $(CXX) main.o length_nolimit.o a.o -o nolimit $(LDFLAGS) main.o: main.cpp - $(CXX) $(CFLAGS_LIMIT) main.cpp -o main.o + $(CXX) $(CFLAGS_LIMIT) $(SRCDIR)/main.cpp -o main.o length_limit.o: length.cpp - $(CXX) $(CFLAGS_LIMIT) length.cpp -o length_limit.o + $(CXX) $(CFLAGS_LIMIT) $(SRCDIR)/length.cpp -o length_limit.o length_nolimit.o: length.cpp - $(CXX) $(CFLAGS_NO_LIMIT) length.cpp -o length_nolimit.o + $(CXX) $(CFLAGS_NO_LIMIT) $(SRCDIR)/length.cpp -o length_nolimit.o a.o: a.cpp - $(CXX) $(CFLAGS_NO_DEBUG) -c a.cpp -o a.o + $(CXX) $(CFLAGS_NO_DEBUG) -c $(SRCDIR)/a.cpp -o a.o clean: OBJECTS += limit nolimit length_limit.o length_nolimit.o length_limit.dwo length_nolimit.dwo 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 505a27a0a67ac..92b58ce11d773 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py @@ -48,36 +48,8 @@ class TestCppIncompleteTypes(TestBase): # Get main source file src_file = "main.cpp" src_file_spec = lldb.SBFileSpec(src_file) - self.assertTrue(src_file_spec.IsValid(), "Main source file") - - # Get the path of the executable - cwd = os.getcwd() - exe_path = os.path.join(cwd, exe) - - # Load the executable - target = self.dbg.CreateTarget(exe_path) - self.assertTrue(target.IsValid(), VALID_TARGET) - - # Break on main function - main_breakpoint = target.BreakpointCreateBySourceRegex( - "break here", src_file_spec) - self.assertTrue( - main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, - VALID_BREAKPOINT) - - # Launch the process - args = None - env = None - process = target.LaunchSimple( - args, env, self.get_process_working_directory()) - self.assertTrue(process.IsValid(), 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) + (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", src_file_spec, exe_name = exe) # Get frame for current thread return thread.GetSelectedFrame() diff --git a/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py b/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py index 2dc72981c14f4..f7b92e8328e8f 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py +++ b/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py @@ -39,7 +39,7 @@ class InlinesTestCase(TestBase): startstr='(int) $0 =') def runToBreakpoint(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. 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 89086e7a64bc4..ae50d3d396606 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 @@ -12,14 +12,12 @@ class TestWithLimitDebugInfo(TestBase): def test_limit_debug_info(self): self.build() - cwd = os.getcwd() - - src_file = os.path.join(cwd, "main.cpp") + src_file = os.path.join(self.getSourceDir(), "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') + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) 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 index 977ad7ddea110..011cf4992915b 100644 --- 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 @@ -221,7 +221,7 @@ class TestMembersAndLocalsWithSameName(TestBase): self.assertTrue(self.src_file_spec.IsValid(), "breakpoint file") # Get the path of the executable - exe_path = os.path.join(cwd, 'a.out') + exe_path = self.getBuildArtifact("a.out") # Load the executable self.target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py index f0bc12ce98326..593911b15dd2d 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py @@ -31,7 +31,7 @@ class NamespaceBreakpointTestCase(TestBase): "A::func(int)"] # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) module_list = lldb.SBFileSpecList() @@ -48,6 +48,7 @@ class NamespaceBreakpointTestCase(TestBase): "make sure breakpoint locations are correct for 'func' with eFunctionNameTypeAuto") @expectedFailureAll(bugnumber="llvm.org/pr28548", compiler="gcc") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") 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).""" @@ -56,7 +57,7 @@ class NamespaceBreakpointTestCase(TestBase): names = ["func()", "func(int)"] # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) module_list = lldb.SBFileSpecList() @@ -81,7 +82,7 @@ class NamespaceBreakpointTestCase(TestBase): names = ["A::func()", "A::func(int)"] # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) module_list = lldb.SBFileSpecList() @@ -132,7 +133,7 @@ class NamespaceTestCase(TestBase): def test_with_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py index 18e45d9798aec..2837cfd9244e0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py @@ -50,7 +50,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_lookup_with_run_command(self): """Test scope lookup of functions in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -151,7 +151,7 @@ class NamespaceLookupTestCase(TestBase): def test_function_scope_lookup_with_run_command(self): """Test scope lookup of functions in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -188,7 +188,7 @@ class NamespaceLookupTestCase(TestBase): def test_file_scope_lookup_with_run_command(self): """Test file scope lookup in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -208,7 +208,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_lookup_before_using_with_run_command(self): """Test scope lookup before using in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -238,7 +238,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_after_using_directive_lookup_with_run_command(self): """Test scope lookup after using directive in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -260,7 +260,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_after_using_declaration_lookup_with_run_command(self): """Test scope lookup after using declaration in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -279,7 +279,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_ambiguity_after_using_lookup_with_run_command(self): """Test scope lookup ambiguity after using in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -305,7 +305,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_lookup_shadowed_by_using_with_run_command(self): """Test scope lookup shadowed by using in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp index 560ec40f4733b..9f5eb06cccd43 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include <cstdarg> +#include <cstdlib> #include "ns.h" namespace { @@ -23,7 +24,7 @@ namespace { variadic_sum (int arg_count...) { int sum = 0; - va_list args; + std::va_list args; va_start(args, arg_count); for (int i = 0; i < arg_count; i++) diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp index 9e5637d02b4b1..bb7731cf87b81 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp @@ -11,22 +11,22 @@ int foo() { - printf("global foo()\n"); - return 42; + std::printf("global foo()\n"); + return 42; } int func() { - printf("global func()\n"); - return 1; + std::printf("global func()\n"); + return 1; } int func(int a) { - printf("global func(int)\n"); - return a + 1; + std::printf("global func(int)\n"); + return a + 1; } void test_lookup_at_global_scope() { - // BP_global_scope - printf("at global scope: foo() = %d\n", foo()); // eval foo(), exp: 42 - printf("at global scope: func() = %d\n", func()); // eval func(), exp: 1 + // BP_global_scope + std::printf("at global scope: foo() = %d\n", foo()); // eval foo(), exp: 42 + std::printf("at global scope: func() = %d\n", func()); // eval func(), exp: 1 } diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h index a07b600efa306..a0f9be88216a2 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include <stdio.h> +#include <cstdio> void test_lookup_at_global_scope(); void test_lookup_at_file_scope(); @@ -15,22 +15,20 @@ void test_lookup_before_using_directive(); void test_lookup_after_using_directive(); int func(int a); namespace A { - int foo(); - int func(int a); - inline int func() - { - printf("A::func()\n"); - return 3; - } - inline int func2() - { - printf("A::func2()\n"); - return 3; - } - void test_lookup_at_ns_scope(); - namespace B { - int func(); - void test_lookup_at_nested_ns_scope(); - void test_lookup_at_nested_ns_scope_after_using(); - } +int foo(); +int func(int a); +inline int func() { + std::printf("A::func()\n"); + return 3; +} +inline int func2() { + std::printf("A::func2()\n"); + return 3; } +void test_lookup_at_ns_scope(); +namespace B { +int func(); +void test_lookup_at_nested_ns_scope(); +void test_lookup_at_nested_ns_scope_after_using(); +} // namespace B +} // namespace A diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp index 04046ad9b7f4d..0051d478395db 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp @@ -11,26 +11,26 @@ static int func() { - printf("static m2.cpp func()\n"); - return 2; + std::printf("static m2.cpp func()\n"); + return 2; } void test_lookup_at_file_scope() { - // BP_file_scope - printf("at file scope: func() = %d\n", func()); // eval func(), exp: 2 - printf("at file scope: func(10) = %d\n", func(10)); // eval func(10), exp: 11 + // BP_file_scope + std::printf("at file scope: func() = %d\n", func()); // eval func(), exp: 2 + std::printf("at file scope: func(10) = %d\n", func(10)); // eval func(10), exp: 11 } namespace A { namespace B { int func() { - printf("A::B::func()\n"); - return 4; + std::printf("A::B::func()\n"); + return 4; } void test_lookup_at_nested_ns_scope() { // BP_nested_ns_scope - printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 4 + std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 4 //printf("func(10) = %d\n", func(10)); // eval func(10), exp: 13 // NOTE: Under the rules of C++, this test would normally get an error @@ -42,24 +42,24 @@ namespace A { { // BP_nested_ns_scope_after_using using A::func; - printf("at nested ns scope after using: func() = %d\n", func()); // eval func(), exp: 3 + std::printf("at nested ns scope after using: func() = %d\n", func()); // eval func(), exp: 3 } } } int A::foo() { - printf("A::foo()\n"); - return 42; + std::printf("A::foo()\n"); + return 42; } int A::func(int a) { - printf("A::func(int)\n"); - return a + 3; + std::printf("A::func(int)\n"); + return a + 3; } void A::test_lookup_at_ns_scope() { - // BP_ns_scope - printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 3 - printf("at nested ns scope: func(10) = %d\n", func(10)); // eval func(10), exp: 13 - printf("at nested ns scope: foo() = %d\n", foo()); // eval foo(), exp: 42 + // BP_ns_scope + std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 3 + std::printf("at nested ns scope: func(10) = %d\n", func(10)); // eval func(10), exp: 13 + std::printf("at nested ns scope: foo() = %d\n", foo()); // eval foo(), exp: 42 } diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp index 10b0df784225b..205e1931f3e05 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp @@ -13,15 +13,15 @@ extern int func(); // Note: the following function must be before the using. void test_lookup_before_using_directive() { - // BP_before_using_directive - printf("before using directive: func() = %d\n", func()); // eval func(), exp: 1 + // BP_before_using_directive + std::printf("before using directive: func() = %d\n", func()); // eval func(), exp: 1 } using namespace A; void test_lookup_after_using_directive() { - // BP_after_using_directive - //printf("func() = %d\n", func()); // eval func(), exp: error, amiguous - printf("after using directive: func2() = %d\n", func2()); // eval func2(), exp: 3 - printf("after using directive: ::func() = %d\n", ::func()); // eval ::func(), exp: 1 - printf("after using directive: B::func() = %d\n", B::func()); // eval B::func(), exp: 4 + // BP_after_using_directive + //printf("func() = %d\n", func()); // eval func(), exp: error, amiguous + std::printf("after using directive: func2() = %d\n", func2()); // eval func2(), exp: 3 + std::printf("after using directive: ::func() = %d\n", ::func()); // eval ::func(), exp: 1 + std::printf("after using directive: B::func() = %d\n", B::func()); // eval B::func(), exp: 4 } diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile index 0041add935a61..9e52bacd5fc9c 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile @@ -9,11 +9,11 @@ include $(LEVEL)/Makefile.rules a.out: lib_a lib_b lib_%: - $(MAKE) -f $*.mk + $(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/$*.mk hidden_lib_d: $(MAKE) -C hidden clean:: - $(MAKE) -f a.mk clean - $(MAKE) -f b.mk clean + $(MAKE) -f $(SRCDIR)/a.mk clean + $(MAKE) -f $(SRCDIR)/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 index 7160dddf45489..1f3fbd8b7f73e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py @@ -46,7 +46,7 @@ class NamespaceDefinitionsTestCase(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk index 5943e5077c54d..e53570873a3ad 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk @@ -4,6 +4,4 @@ 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.mk b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk index 8ee2a13b1291b..54a1d8dea5a65 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk @@ -4,6 +4,4 @@ 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/nsimport/TestCppNsImport.py b/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py index fd19de7086dab..f42d194cd6207 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py +++ b/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py @@ -16,14 +16,12 @@ class TestCppNsImport(TestBase): self.build() # Get main source file - src_file = "main.cpp" + src_file = os.path.join(self.getSourceDir(), "main.cpp") src_file_spec = lldb.SBFileSpec(src_file) self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile new file mode 100644 index 0000000000000..bd8116b91c3c4 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../../make + +CXX_SOURCES = a.cpp b.cpp + +include $(LEVEL)/Makefile.rules + +a.o: a.cpp + $(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@ diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py new file mode 100644 index 0000000000000..f541a6617e3a4 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py @@ -0,0 +1,22 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestOperatorOverload(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def test_overload(self): + self.build() + (target, process, thread, + main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", lldb.SBFileSpec("b.cpp")) + frame = thread.GetSelectedFrame() + value = frame.EvaluateExpression("x == nil") + self.assertTrue(str(value.GetError()) + .find("comparison between NULL and non-pointer ('Tinky' and NULL)") + != -1) + self.assertTrue(str(value.GetError()) + .find("invalid operands to binary expression ('Tinky' and") + != -1) + self.assertFalse(value.GetError().Success()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp new file mode 100644 index 0000000000000..77b2f6ace82ea --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp @@ -0,0 +1,9 @@ +class Patatino { +public: + double _blah; + Patatino(int blah) : _blah(blah) {} +}; + +bool operator==(const Patatino& a, const Patatino& b) { + return a._blah < b._blah; +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp new file mode 100644 index 0000000000000..c0eb29bb79f8e --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp @@ -0,0 +1,10 @@ +class Tinky { +public: + int _meh; + Tinky(int meh) : _meh(meh) {} +}; + +int main(void) { + Tinky x(12); + return 0; // break here +} 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 3d8788fa79073..7f68eb8923eba 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py @@ -8,7 +8,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class CPPStaticMethodsTestCase(TestBase): +class OverloadedFunctionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,7 +22,7 @@ class CPPStaticMethodsTestCase(TestBase): def test_with_run_command(self): """Test that functions with the same name are resolved correctly""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py b/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py index 38ebe1a9a9c46..3dfe4f29d18c3 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py +++ b/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py @@ -4,4 +4,4 @@ from lldbsuite.test import decorators lldbinline.MakeInlineTest( __file__, globals(), [ decorators.expectedFailureAll( - bugnumber="rdar://problem/24599697")]) + bugnumber="llvm.org/PR36715")]) 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 11d221e171a92..cc79366c71492 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py +++ b/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py @@ -22,7 +22,7 @@ class RvalueReferencesTestCase(TestBase): def test_with_run_command(self): """Test that rvalues are supported in the C++ expression parser""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) diff --git a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py index d5ff93f0cc1f5..5cd9e4ed1b4f0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py +++ b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py @@ -23,14 +23,12 @@ class TestCppScopes(TestBase): self.build() # Get main source file - src_file = "main.cpp" + src_file = os.path.join(self.getSourceDir(), "main.cpp") src_file_spec = lldb.SBFileSpec(src_file) self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) 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 5925b10143e07..2b67bb4c35e59 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py @@ -9,6 +9,7 @@ import os import time import re import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil @@ -25,6 +26,7 @@ class SignedTypesTestCase(TestBase): self.line = line_number( self.source, '// Set break point at this line.') + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") def test(self): """Test that variables with signed types display correctly.""" self.build() @@ -33,7 +35,7 @@ class SignedTypesTestCase(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) lldbutil.run_break_set_by_file_and_line( 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 16b5675881612..b8c777f417a9a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py +++ b/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py @@ -21,7 +21,7 @@ class CPPStaticMembersTestCase(TestBase): 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() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) 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 9c263053879e5..404ef22a0b8cb 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py +++ b/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py @@ -20,7 +20,7 @@ class CPPStaticMethodsTestCase(TestBase): def test_with_run_command(self): """Test that static methods are properly distinguished from regular methods""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py index ce5869742f47f..42c372489c631 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py @@ -26,11 +26,11 @@ class STLTestCase(TestBase): self.line = line_number( self.source, '// Set break point at this line.') - @expectedFailureAll(bugnumber="rdar://problem/10400981") + @expectedFailureAll(bugnumber="llvm.org/PR36713") def test(self): """Test some expressions involving STL data types.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # The following two lines, if uncommented, will enable loggings. #self.ci.HandleCommand("log enable -f /tmp/lldb.log lldb default", res) @@ -38,9 +38,6 @@ class STLTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # rdar://problem/8543077 - # test/stl: clang built binaries results in the breakpoint locations = 3, - # is this a problem with clang generated debug info? lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) @@ -60,8 +57,6 @@ class STLTestCase(TestBase): self.runCmd( 'expr for (int i = 0; i < hello_world.length(); ++i) { (void)printf("%c\\n", hello_world[i]); }') - # rdar://problem/10373783 - # rdar://problem/10400981 self.expect('expr associative_array.size()', substrs=[' = 3']) self.expect('expr associative_array.count(hello_world)', @@ -78,7 +73,7 @@ class STLTestCase(TestBase): def test_SBType_template_aspects(self): """Test APIs for getting template arguments from an SBType.""" self.build() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py index 47fdf59a27ee7..23e94e9addc03 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py @@ -31,7 +31,7 @@ class StdCXXDisassembleTestCase(TestBase): def test_stdcxx_disasm(self): """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # rdar://problem/8543077 diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py index b59f966236bb0..054bc93c31899 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py +++ b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py @@ -19,7 +19,7 @@ class TemplateArgsTestCase(TestBase): self.build() # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -83,6 +83,35 @@ class TemplateArgsTestCase(TestBase): expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"') + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") + def test_template_template_args(self): + frame = self.prepareProcess() + + c1 = frame.FindVariable('c1') + self.assertTrue( + c1.IsValid(), + 'make sure we find a local variabble named "c1"') + self.assertTrue(c1.GetType().GetName() == 'C<float, T1>') + f1 = c1.GetChildMemberWithName("V").GetChildAtIndex(0).GetChildMemberWithName("f") + self.assertTrue(f1.GetType().GetName() == 'float') + self.assertTrue(f1.GetValue() == '1.5') + + c2 = frame.FindVariable('c2') + self.assertTrue( + c2.IsValid(), + 'make sure we find a local variabble named "c2"') + self.assertTrue(c2.GetType().GetName() == 'C<double, T1, T2>') + f2 = c2.GetChildMemberWithName("V").GetChildAtIndex(0).GetChildMemberWithName("f") + self.assertTrue(f2.GetType().GetName() == 'double') + self.assertTrue(f2.GetValue() == '1.5') + f3 = c2.GetChildMemberWithName("V").GetChildAtIndex(1).GetChildMemberWithName("f") + self.assertTrue(f3.GetType().GetName() == 'double') + self.assertTrue(f3.GetValue() == '2.5') + f4 = c2.GetChildMemberWithName("V").GetChildAtIndex(1).GetChildMemberWithName("i") + self.assertTrue(f4.GetType().GetName() == 'int') + self.assertTrue(f4.GetValue() == '42') + + # Gcc does not generate the necessary DWARF attribute for enum template # parameters. @expectedFailureAll(bugnumber="llvm.org/pr28354", compiler="gcc") diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp index 9c33a64209126..40825cd7c1a69 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp @@ -6,6 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#include <tuple> template <int Arg> class TestObj @@ -62,11 +63,17 @@ public: } }; +template <typename FLOAT> struct T1 { FLOAT f = 1.5; }; +template <typename FLOAT> struct T2 { FLOAT f = 2.5; int i = 42; }; +template <typename FLOAT, template <typename> class ...Args> class C { std::tuple<Args<FLOAT>...> V; }; + int main(int argc, char **argv) { TestObj<1> testpos; TestObj<-1> testneg; EnumTemplate<EnumType::Member> member(123); EnumTemplate<EnumType::Subclass> subclass(123*2); + C<float, T1> c1; + C<double, T1, T2> c2; 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 ed2e257dc3105..43b00f97d8fef 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py +++ b/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py @@ -24,7 +24,7 @@ class CPPThisTestCase(TestBase): 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() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) diff --git a/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile new file mode 100644 index 0000000000000..314f1cb2f077b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py new file mode 100644 index 0000000000000..2aae7dc89d346 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py @@ -0,0 +1,74 @@ +""" +Test that we work properly with classes with the trivial_abi attribute +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTrivialABI(TestBase): + + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + @skipUnlessSupportedTypeAttribute("trivial_abi") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995") + def test_call_trivial(self): + """Test that we can print a variable & call a function with a trivial ABI class.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + self.expr_test(True) + + @skipUnlessSupportedTypeAttribute("trivial_abi") + @expectedFailureAll(bugnumber="llvm.org/pr36870") + def test_call_nontrivial(self): + """Test that we can print a variable & call a function on the same class w/o the trivial ABI marker.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + self.expr_test(False) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def check_value(self, test_var, ivar_value): + self.assertTrue(test_var.GetError().Success(), "Invalid valobj: %s"%(test_var.GetError().GetCString())) + ivar = test_var.GetChildMemberWithName("ivar") + self.assertTrue(test_var.GetError().Success(), "Failed to fetch ivar") + self.assertEqual(ivar_value, ivar.GetValueAsSigned(), "Got the right value for ivar") + + def check_frame(self, thread): + frame = thread.frames[0] + inVal_var = frame.FindVariable("inVal") + self.check_value(inVal_var, 10) + + options = lldb.SBExpressionOptions() + inVal_expr = frame.EvaluateExpression("inVal", options) + self.check_value(inVal_expr, 10) + + thread.StepOut() + outVal_ret = thread.GetStopReturnValue() + self.check_value(outVal_ret, 30) + + def expr_test(self, trivial): + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "Set a breakpoint here", self.main_source_file) + + # Stop in a function that takes a trivial value, and try both frame var & expr to get its value: + if trivial: + self.check_frame(thread) + return + + # Now continue to the same thing without the trivial_abi and see if we get that right: + threads = lldbutil.continue_to_breakpoint(process, bkpt) + self.assertEqual(len(threads), 1, "Hit my breakpoint the second time.") + + self.check_frame(threads[0]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/main.cpp new file mode 100644 index 0000000000000..cdf593e8b4036 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/main.cpp @@ -0,0 +1,35 @@ +struct __attribute__((trivial_abi)) S_Trivial { + ~S_Trivial() {} + int ivar = 10; +}; + +S_Trivial takeTrivial(S_Trivial inVal) +{ + S_Trivial ret_val = inVal; + ret_val.ivar = 30; + return ret_val; // Set a breakpoint here +} + +struct S_NotTrivial { + ~S_NotTrivial() {} + int ivar = 10; +}; + +S_NotTrivial takeNotTrivial(S_NotTrivial inVal) +{ + S_NotTrivial ret_val = inVal; + ret_val.ivar = 30; + return ret_val; // Set a breakpoint here +} + +int +main() +{ + S_Trivial inVal, outVal; + outVal = takeTrivial(inVal); + + S_NotTrivial inNotVal, outNotVal; + outNotVal = takeNotTrivial(outNotVal); + + return 0; // Set another for return value +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile new file mode 100644 index 0000000000000..99bfa7e03b479 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py new file mode 100644 index 0000000000000..94d52e368e8cc --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py @@ -0,0 +1,94 @@ +""" +Test that we can lookup types correctly in the expression parser +""" + +from __future__ import print_function + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test import decorators + +class TestCppTypeLookup(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def check_value(self, value, ivar_name, ivar_value): + self.assertTrue(value.GetError().Success(), + "Invalid valobj: %s" % ( + value.GetError().GetCString())) + ivar = value.GetChildMemberWithName(ivar_name) + self.assertTrue(ivar.GetError().Success(), + "Failed to fetch ivar named '%s'" % (ivar_name)) + self.assertEqual(ivar_value, + ivar.GetValueAsSigned(), + "Got the right value for ivar") + + def test_namespace_only(self): + """ + Test that we fail to lookup a struct type that exists only in a + namespace. + """ + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Set a breakpoint here", self.main_source_file) + + # Get frame for current thread + frame = thread.GetSelectedFrame() + + # We are testing LLDB's type lookup machinery, but if we inject local + # variables, the types for those will be found because they have been + # imported through the variable, not because the type lookup worked. + self.runCmd("settings set target.experimental.inject-local-vars false") + + # Make sure we don't accidentally accept structures that exist only + # in namespaces when evaluating expressions with top level types. + # Prior to the revision that added this test, we would accidentally + # accept types from namespaces, so this will ensure we don't regress + # to that behavior again + expr_result = frame.EvaluateExpression("*((namespace_only *)&i)") + self.assertTrue(expr_result.GetError().Fail(), + "'namespace_only' exists in namespace only") + + # Make sure we can find the correct type in a namespace "a" + expr_result = frame.EvaluateExpression("*((a::namespace_only *)&i)") + self.check_value(expr_result, "a", 123) + # Make sure we can find the correct type in a namespace "b" + expr_result = frame.EvaluateExpression("*((b::namespace_only *)&i)") + self.check_value(expr_result, "b", 123) + + # Make sure we can find the correct type in the root namespace + expr_result = frame.EvaluateExpression("*((namespace_and_file *)&i)") + self.check_value(expr_result, "ff", 123) + # Make sure we can find the correct type in a namespace "a" + expr_result = frame.EvaluateExpression( + "*((a::namespace_and_file *)&i)") + self.check_value(expr_result, "aa", 123) + # Make sure we can find the correct type in a namespace "b" + expr_result = frame.EvaluateExpression( + "*((b::namespace_and_file *)&i)") + self.check_value(expr_result, "bb", 123) + + # Make sure we don't accidentally accept structures that exist only + # in namespaces when evaluating expressions with top level types. + # Prior to the revision that added this test, we would accidentally + # accept types from namespaces, so this will ensure we don't regress + # to that behavior again + expr_result = frame.EvaluateExpression("*((in_contains_type *)&i)") + self.assertTrue(expr_result.GetError().Fail(), + "'in_contains_type' exists in struct only") + + # Make sure we can find the correct type in the root namespace + expr_result = frame.EvaluateExpression( + "*((contains_type::in_contains_type *)&i)") + self.check_value(expr_result, "fff", 123) + # Make sure we can find the correct type in a namespace "a" + expr_result = frame.EvaluateExpression( + "*((a::contains_type::in_contains_type *)&i)") + self.check_value(expr_result, "aaa", 123) + # Make sure we can find the correct type in a namespace "b" + expr_result = frame.EvaluateExpression( + "*((b::contains_type::in_contains_type *)&i)") + self.check_value(expr_result, "bbb", 123) diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp new file mode 100644 index 0000000000000..b244e80962c8f --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp @@ -0,0 +1,67 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// In this test, we define struct that exist might exist at the different +// levels in the code and test that we can properly locate these types with +// a varienty of different expressions. + +namespace a { + struct namespace_only { + int a; + }; + struct namespace_and_file { + int aa; + }; + struct contains_type { + struct in_contains_type { + int aaa; + }; + }; +}; +namespace b { + struct namespace_only { + int b; + }; + struct namespace_and_file { + int bb; + }; + struct contains_type { + struct in_contains_type { + int bbb; + }; + }; +}; + +struct namespace_and_file { + int ff; +}; + +struct contains_type { + struct in_contains_type { + int fff; + }; +}; + + +int main (int argc, char const *argv[]) { + a::namespace_only a_namespace_only = { 1 }; + a::namespace_and_file a_namespace_and_file = { 2 }; + a::contains_type::in_contains_type a_in_contains_type = { 3 }; + b::namespace_only b_namespace_only = { 11 }; + b::namespace_and_file b_namespace_and_file = { 22 }; + b::contains_type::in_contains_type b_in_contains_type = { 33 }; + namespace_and_file file_namespace_and_file = { 44 }; + contains_type::in_contains_type file_in_contains_type = { 55 }; + int i = 123; // Provide an integer that can be used for casting + // Take address of "i" to ensure it is in memory + if (&i == &argc) { + i = -1; + } + return i == -1; // Set a breakpoint here +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py index 842d03ae51974..216f86064dcac 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py @@ -69,7 +69,7 @@ class UnicodeLiteralsTestCase(TestBase): self.skipTest( "Skipping because this test is known to crash on i386") - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py b/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py index 3afac33ab39fb..3e4fee0b49bc0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py @@ -28,12 +28,8 @@ class UniqueTypesTestCase(TestBase): compiler = self.getCompiler() compiler_basename = os.path.basename(compiler) - if "clang" in compiler_basename and int( - self.getCompilerVersion().split('.')[0]) < 3: - self.skipTest( - "rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) 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 0189a65bec39d..27b2a0b357af4 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py @@ -27,13 +27,13 @@ class UnsignedTypesTestCase(TestBase): def test(self): """Test that variables with unsigned types display correctly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # GCC puts a breakpoint on the last line of a multi-line expression, so # if GCC is the target compiler, we cannot rely on an exact line match. need_exact = "gcc" not in self.getCompiler() - # Break on line 19 in main() aftre the variables are assigned values. + # Break on line 19 in main() after the variables are assigned values. lldbutil.run_break_set_by_file_and_line( self, "main.cpp", diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/Makefile b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/Makefile new file mode 100644 index 0000000000000..314f1cb2f077b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/TestVirtualOverload.py b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/TestVirtualOverload.py new file mode 100644 index 0000000000000..1311a14932621 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/TestVirtualOverload.py @@ -0,0 +1,3 @@ +from lldbsuite.test import lldbinline + +lldbinline.MakeInlineTest(__file__, globals()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/main.cpp new file mode 100644 index 0000000000000..79c482352f93b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/main.cpp @@ -0,0 +1,17 @@ +// Test that lldb doesn't get confused by an overload of a virtual +// function of the same name. +struct Base { + virtual void f(int i) {} + virtual ~Base() {} +}; + +struct Derived : Base { + virtual void f(int i, int j) {} +}; + +int main(int argc, char **argv) { + Derived obj; + obj.f(1, 2); //% self.expect("fr var", "not crashing", substrs = ["obj"]) + return 0; +} + diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py index 7356484e69a42..b3fe9c40c1983 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py @@ -45,7 +45,7 @@ class CppVirtualMadness(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Create the breakpoint inside function 'main'. diff --git a/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py b/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py index f17ba6f4a229c..f31ba9b5c8b4f 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py +++ b/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py @@ -28,7 +28,7 @@ class CxxWCharTTestCase(TestBase): def test(self): """Test that C++ supports wchar_t correctly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) |