diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /packages/Python/lldbsuite/test/expression_command | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/expression_command')
38 files changed, 300 insertions, 54 deletions
diff --git a/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py b/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py index 2d4504f7ba423..6a8fb5db5439c 100644 --- a/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py +++ b/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py @@ -32,7 +32,8 @@ class TestExprLookupAnonStructTypedef(TestBase): """Test typedeffed untagged struct arguments for function call expressions""" 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", diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py index 16736f798528a..079ab6d608884 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py @@ -30,7 +30,8 @@ class ExprCommandCallFunctionTestCase(TestBase): def test_with(self): """Test calling std::String member function.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), + CURRENT_EXECUTABLE_SET) # Some versions of GCC encode two locations for the 'return' statement # in main.cpp diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py index a48a38aaf92cb..63511779a9275 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py @@ -31,7 +31,7 @@ class ExprCommandCallStopContinueTestCase(TestBase): def test(self): """Test gathering result from interrupted function call.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) # Some versions of GCC encode two locations for the 'return' statement # in main.cpp diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py index fda81ae8c3659..ff3bd99ced99c 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py @@ -37,7 +37,7 @@ class ExprCommandCallUserDefinedFunction(TestBase): self.build() # Set breakpoint in main and run exe - 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/expression_command/call-overridden-method/Makefile b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/Makefile new file mode 100644 index 0000000000000..9d4f3b7f14124 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules + +clean:: + rm -rf $(wildcard *.o *.d *.dSYM) diff --git a/packages/Python/lldbsuite/test/expression_command/call-overridden-method/TestCallOverriddenMethod.py b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/TestCallOverriddenMethod.py new file mode 100644 index 0000000000000..1e61aa9f46e01 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/TestCallOverriddenMethod.py @@ -0,0 +1,49 @@ +""" +Test calling an overriden method. + +Note: + This verifies that LLDB is correctly building the method overrides table. + If this table is not built correctly then calls to overridden methods in + derived classes may generate references to non-existant vtable entries, + as the compiler treats the overridden method as a totally new virtual + method definition. + <rdar://problem/14205774> + +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class ExprCommandCallOverriddenMethod(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.c. + self.line = line_number('main.cpp', '// Set breakpoint here') + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") + def test(self): + """Test calls to overridden methods in derived classes.""" + self.build() + + # Set breakpoint in main and run exe + 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) + + self.runCmd("run", RUN_SUCCEEDED) + + # Test call to method in base class (this should always work as the base + # class method is never an override). + self.expect("expr b->foo()") + + # Test call to overridden method in derived class (this will fail if the + # overrides table is not correctly set up, as Derived::foo will be assigned + # a vtable entry that does not exist in the compiled program). + self.expect("expr d.foo()") diff --git a/packages/Python/lldbsuite/test/expression_command/call-overridden-method/main.cpp b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/main.cpp new file mode 100644 index 0000000000000..54ae705d29785 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/main.cpp @@ -0,0 +1,16 @@ +class Base { +public: + virtual ~Base() {} + virtual void foo() {} +}; + +class Derived : public Base { +public: + virtual void foo() {} +}; + +int main() { + Derived d; + Base *b = &d; + return 0; // Set breakpoint here +} diff --git a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py index 445979f5c701d..2f14068747655 100644 --- a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py +++ b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py @@ -49,6 +49,7 @@ class ExprCharTestCase(TestBase): archs=[ "arm", "aarch64", + "powerpc64le", "s390x"], bugnumber="llvm.org/pr23069") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") diff --git a/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py b/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py index dcfb648ada500..dd31424dbbdc4 100644 --- a/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py +++ b/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py @@ -22,7 +22,7 @@ class ExprSyscallTestCase(TestBase): self.expr_syscall() def expr_syscall(self): - 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/expression_command/formatters/TestFormatters.py b/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py index c4126a329686d..f14b02bbd7c41 100644 --- a/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py +++ b/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py @@ -43,7 +43,7 @@ class ExprFormattersTestCase(TestBase): self.addTearDownHook(cleanup) """Test expr + formatters for good interoperability.""" - 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, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py b/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py index 894d0bfaa86ea..a5607f1950525 100644 --- a/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py +++ b/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py @@ -17,7 +17,7 @@ class IRInterpreterPHINodesTestCase(TestBase): """Test support for PHI nodes in the IR interpreter.""" 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 first assignment to i diff --git a/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py b/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py index 5c5110b69945b..d8a8038c84541 100644 --- a/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py +++ b/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py @@ -17,6 +17,7 @@ from lldbsuite.test import lldbutil class IRInterpreterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -34,7 +35,7 @@ class IRInterpreterTestCase(TestBase): """Test the IR interpreter""" 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.c", self.line, num_expected_locations=1, loc_exact=False) @@ -85,3 +86,10 @@ class IRInterpreterTestCase(TestBase): jit_result, "While evaluating " + expression) + + def test_type_conversions(self): + target = self.dbg.GetDummyTarget() + short_val = target.EvaluateExpression("(short)-1") + self.assertEqual(short_val.GetValueAsSigned(), -1) + long_val = target.EvaluateExpression("(long) "+ short_val.GetName()) + self.assertEqual(long_val.GetValueAsSigned(), -1) diff --git a/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py b/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py index aa369ebeff878..7f639a4622018 100644 --- a/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py +++ b/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py @@ -28,7 +28,7 @@ class MultilineExpressionsTestCase(TestBase): """Test that multiline expressions work correctly""" self.build() import pexpect - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") prompt = "(lldb) " # So that the child gets torn down after the test. diff --git a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py index b4e9a8bfeab8b..1dbafc36a82a5 100644 --- a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py +++ b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py @@ -28,7 +28,7 @@ class ExprOptionsTestCase(TestBase): self.main_source = "main.cpp" self.main_source_spec = lldb.SBFileSpec(self.main_source) self.line = line_number('main.cpp', '// breakpoint_in_main') - self.exe = os.path.join(os.getcwd(), "a.out") + self.exe = self.getBuildArtifact("a.out") def test_expr_options(self): """These expression command options should work as expected.""" diff --git a/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py b/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py index e6c9d43adf04c..b6471d0f89722 100644 --- a/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py +++ b/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py @@ -34,7 +34,7 @@ class PersistObjCPointeeType(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - 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.m", self.line, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py b/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py index 118b9f32c4bd4..7b963b5bfcd27 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py @@ -28,7 +28,7 @@ class PersistentPtrUpdateTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd('break set -p here') diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py index 12452a9637720..f4ee1b0fb625d 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py @@ -22,7 +22,7 @@ class NestedPersistentTypesTestCase(TestBase): """Test that nested persistent types work.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --name main") diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py index 3d4df307d1b0c..f56cb11a80d84 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py @@ -22,7 +22,7 @@ class PersistenttypesTestCase(TestBase): """Test that lldb persistent types works correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --name main") diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py b/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py index b6f027964bab0..441a60b5a4636 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py @@ -19,7 +19,7 @@ class PersistentVariablesTestCase(TestBase): """Test that lldb persistent variables works correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --source-pattern-regexp break") diff --git a/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py b/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py index 13f8f58564e8b..4530342ea52d6 100644 --- a/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py +++ b/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py @@ -37,7 +37,7 @@ class PoVerbosityTestCase(TestBase): self.addTearDownHook(cleanup) """Test expr + formatters for good interoperability.""" - 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.m", self.line, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/pr35310/Makefile b/packages/Python/lldbsuite/test/expression_command/pr35310/Makefile new file mode 100644 index 0000000000000..8a7102e347af2 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/pr35310/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py b/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py new file mode 100644 index 0000000000000..9cc9df2b22be6 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py @@ -0,0 +1,40 @@ +from __future__ import print_function + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class ExprBug35310(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + self.main_source = "main.cpp" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") + def test_issue35310(self): + """Test invoking functions with non-standard linkage names. + + The GNU abi_tag extension used by libstdc++ is a common source + of these, but they could originate from other reasons as well. + """ + self.build() + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) + frame = thread.GetFrameAtIndex(0) + + value = frame.EvaluateExpression("a.test_abi_tag()") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsSigned(0), 1) + + value = frame.EvaluateExpression("a.test_asm_name()") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsSigned(0), 2) diff --git a/packages/Python/lldbsuite/test/expression_command/pr35310/main.cpp b/packages/Python/lldbsuite/test/expression_command/pr35310/main.cpp new file mode 100644 index 0000000000000..a8e8a5c737a01 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/pr35310/main.cpp @@ -0,0 +1,19 @@ +#include <stdio.h> + +class A { +public: + int __attribute__((abi_tag("cxx11"))) test_abi_tag() { + return 1; + } + int test_asm_name() asm("A_test_asm") { + return 2; + } +}; + +int main(int argc, char **argv) { + A a; + // Break here + a.test_abi_tag(); + a.test_asm_name(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py b/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py index ca43585616e50..0027fc226e377 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py @@ -19,7 +19,7 @@ class Radar8638051TestCase(TestBase): """The following expression commands should not crash.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set -n c") diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py b/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py index c4d899cfc1e03..c44cb6fc39dac 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py @@ -23,7 +23,7 @@ class Radar9531204TestCase(TestBase): """The evaluating printf(...) after break stop and then up a stack frame.""" 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_symbol( self, 'foo', sym_exact=True, num_expected_locations=1) diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py index 4fc2463b25a8b..dfef8735071b9 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py @@ -29,7 +29,7 @@ class Radar9673644TestCase(TestBase): """The following expression commands should just work.""" 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/expression_command/rdar42038760/Makefile b/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile new file mode 100644 index 0000000000000..f5a47fcc46ccf --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py b/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py new file mode 100644 index 0000000000000..03424658f3ed3 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), None) diff --git a/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c b/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c new file mode 100644 index 0000000000000..98a957faf8bda --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c @@ -0,0 +1,19 @@ +// Make sure we IR-interpret the expression correctly. + +typedef unsigned int uint32_t; +struct S0 { + signed f2; +}; +static g_463 = 0x1561983AL; +void func_1(void) +{ + struct S0 l_19; + l_19.f2 = 419; + uint32_t l_4037 = 4294967295UL; + l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883']) +} +int main() +{ + func_1(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py index f6938b1ea98b0..c1a1b375e155a 100644 --- a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py +++ b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py @@ -11,23 +11,24 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -def enumerateJITFiles(): - return [f for f in os.listdir(os.getcwd()) if f.startswith("jit")] - -def countJITFiles(): - return len(enumerateJITFiles()) - -def cleanJITFiles(): - for j in enumerateJITFiles(): - os.remove(j) - return - class SaveJITObjectsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + def enumerateJITFiles(self): + return [f for f in os.listdir(self.getBuildDir()) if f.startswith("jit")] + + def countJITFiles(self): + return len(self.enumerateJITFiles()) + + def cleanJITFiles(self): + for j in self.enumerateJITFiles(): + os.remove(j) + return + @expectedFailureAll(oslist=["windows"]) def test_save_jit_objects(self): self.build() + os.chdir(self.getBuildDir()) src_file = "main.c" src_file_spec = lldb.SBFileSpec(src_file) @@ -36,16 +37,17 @@ class SaveJITObjectsTestCase(TestBase): frame = thread.frames[0] - cleanJITFiles() + self.cleanJITFiles() frame.EvaluateExpression("(void*)malloc(0x1)") - self.assertTrue(countJITFiles() == 0, + self.assertTrue(self.countJITFiles() == 0, "No files emitted with save-jit-objects=false") self.runCmd("settings set target.save-jit-objects true") frame.EvaluateExpression("(void*)malloc(0x1)") - jit_files_count = countJITFiles() - cleanJITFiles() + jit_files_count = self.countJITFiles() + self.cleanJITFiles() self.assertTrue(jit_files_count != 0, "At least one file emitted with save-jit-objects=true") process.Kill() + os.chdir(self.getSourceDir()) diff --git a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py index 1cd11a8c2759f..3af7d808e1286 100644 --- a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py +++ b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py @@ -45,7 +45,7 @@ class BasicExprCommandsTestCase(TestBase): """These basic expression commands should work as expected.""" 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=False) @@ -107,7 +107,7 @@ class BasicExprCommandsTestCase(TestBase): """Test SBFrame.EvaluateExpression() API for evaluating an expression.""" 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) @@ -208,7 +208,7 @@ class BasicExprCommandsTestCase(TestBase): """Throw some expression commands with quotes at 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, "main.cpp", self.line, num_expected_locations=1, loc_exact=False) diff --git a/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py b/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py index 35ac151a3908c..f5ec4f027866a 100644 --- a/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py +++ b/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py @@ -31,7 +31,7 @@ class ExprCommands2TestCase(TestBase): """Test some more expression commands.""" 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=False) @@ -43,23 +43,38 @@ class ExprCommands2TestCase(TestBase): startstr="(int *) $0 = 0x") # (int *) $0 = 0x00007fff5fbff258 - # Do anonymous symbols work? - self.expect("expression ((char**)environ)[0]", - startstr="(char *) $1 = 0x") - # (char *) $1 = 0x00007fff5fbff298 "Apple_PubSub_Socket_Render=/tmp/launch-7AEsUD/Render" - # Do return values containing the contents of expression locals work? self.expect("expression int i = 5; i", - startstr="(int) $2 = 5") + startstr="(int) $1 = 5") # (int) $2 = 5 - self.expect("expression $2 + 1", - startstr="(int) $3 = 6") + self.expect("expression $1 + 1", + startstr="(int) $2 = 6") # (int) $3 = 6 # Do return values containing the results of static expressions work? self.expect("expression 20 + 3", - startstr="(int) $4 = 23") + startstr="(int) $3 = 23") # (int) $4 = 5 - self.expect("expression $4 + 1", - startstr="(int) $5 = 24") + self.expect("expression $3 + 1", + startstr="(int) $4 = 24") # (int) $5 = 6 + + @skipIfLinux + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") + def test_expr_symbols(self): + """Test symbols.""" + self.build() + + 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=False) + + self.runCmd("run", RUN_SUCCEEDED) + + # Do anonymous symbols work? + self.expect("expression ((char**)environ)[0]", + startstr="(char *) $0 = 0x") + # (char *) $1 = 0x00007fff5fbff298 "Apple_PubSub_Socket_Render=/tmp/launch-7AEsUD/Render" diff --git a/packages/Python/lldbsuite/test/expression_command/top-level/Makefile b/packages/Python/lldbsuite/test/expression_command/top-level/Makefile index 48eec5c5d2683..9e35242c72fad 100644 --- a/packages/Python/lldbsuite/test/expression_command/top-level/Makefile +++ b/packages/Python/lldbsuite/test/expression_command/top-level/Makefile @@ -7,7 +7,7 @@ include $(LEVEL)/Makefile.rules a.out: dummy dummy: - $(MAKE) -f dummy.mk + $(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk clean:: - $(MAKE) -f dummy.mk clean + $(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk clean diff --git a/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py b/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py index dfe95a1a9fa7a..1a8a619b0ed22 100644 --- a/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py +++ b/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py @@ -37,7 +37,7 @@ class TopLevelExpressionsTestCase(TestBase): """Test top-level expressions.""" 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=False) @@ -45,7 +45,8 @@ class TopLevelExpressionsTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) def run_dummy(self): - self.runCmd("file dummy", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("dummy"), + CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, diff --git a/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py b/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py index 1ce75144017e5..bac8e5453e4a8 100644 --- a/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py +++ b/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py @@ -28,7 +28,7 @@ class ObjCTypeQueryTestCase(TestBase): def test(self): """The expression parser's type search should be wider than the current compilation unit.""" 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile b/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile new file mode 100644 index 0000000000000..8a7102e347af2 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py b/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py new file mode 100644 index 0000000000000..4ad4225a5fe41 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py @@ -0,0 +1,37 @@ +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ExprXValuePrintingTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + self.main_source = "main.cpp" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + + def do_test(self, dictionary=None): + """Printing an xvalue should work.""" + self.build(dictionary=dictionary) + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) + frame = thread.GetFrameAtIndex(0) + + value = frame.EvaluateExpression("foo().data") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsSigned(), 1234) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") + def test(self): + self.do_test() + diff --git a/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp b/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp new file mode 100644 index 0000000000000..556c63f2b4499 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp @@ -0,0 +1,12 @@ +struct Tmp +{ + int data = 1234; +}; + +Tmp foo() { return Tmp(); } + +int main(int argc, char const *argv[]) +{ + int something = foo().data; + return 0; // Break here +} |