diff options
author | 2020-08-03 14:33:06 +0000 | |
---|---|---|
committer | 2020-08-03 14:33:06 +0000 | |
commit | 061da546b983eb767bad15e67af1174fb0bcf31c (patch) | |
tree | 83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target | |
parent | Import LLVM 10.0.0 release including clang, lld and lldb. (diff) | |
download | wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip |
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom
tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target')
4 files changed, 166 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories new file mode 100644 index 00000000000..c00c25822e4 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories @@ -0,0 +1 @@ +basic_process diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/Makefile new file mode 100644 index 00000000000..10495940055 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py new file mode 100644 index 00000000000..7665b2f73b6 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py @@ -0,0 +1,122 @@ +"""Test the 'step target' feature.""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestStepTarget(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line numbers that we will step to in main: + self.main_source = "main.c" + self.end_line = line_number(self.main_source, "All done") + + @add_test_categories(['pyapi']) + def get_to_start(self): + self.build() + exe = self.getBuildArtifact("a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + self.main_source_spec = lldb.SBFileSpec(self.main_source) + + break_in_main = target.BreakpointCreateBySourceRegex( + 'Break here to try targetted stepping', self.main_source_spec) + self.assertTrue(break_in_main, VALID_BREAKPOINT) + self.assertGreater(break_in_main.GetNumLocations(), 0, "Has locations.") + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + + self.assertTrue(process, PROCESS_IS_VALID) + + # The stop reason of the thread should be breakpoint. + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, break_in_main) + + if len(threads) != 1: + self.fail("Failed to stop at first breakpoint in main.") + + thread = threads[0] + return thread + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") + def test_with_end_line(self): + """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" + + thread = self.get_to_start() + + error = lldb.SBError() + thread.StepInto("lotsOfArgs", self.end_line, error) + frame = thread.frames[0] + + self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.") + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") + def test_with_end_line_bad_name(self): + """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" + + thread = self.get_to_start() + + error = lldb.SBError() + thread.StepInto("lotsOfArgssss", self.end_line, error) + frame = thread.frames[0] + self.assertEqual(frame.line_entry.line, self.end_line, + "Stepped to the block end.") + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") + def test_with_end_line_deeper(self): + """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" + + thread = self.get_to_start() + + error = lldb.SBError() + thread.StepInto("modifyInt", self.end_line, error) + frame = thread.frames[0] + self.assertEqual(frame.name, "modifyInt", "Stepped to modifyInt.") + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") + def test_with_command_and_block(self): + """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" + + thread = self.get_to_start() + + result = lldb.SBCommandReturnObject() + self.dbg.GetCommandInterpreter().HandleCommand( + 'thread step-in -t "lotsOfArgs" -e block', result) + self.assertTrue( + result.Succeeded(), + "thread step-in command succeeded.") + + frame = thread.frames[0] + self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.") + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") + def test_with_command_and_block_and_bad_name(self): + """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" + + thread = self.get_to_start() + + result = lldb.SBCommandReturnObject() + self.dbg.GetCommandInterpreter().HandleCommand( + 'thread step-in -t "lotsOfArgsssss" -e block', result) + self.assertTrue( + result.Succeeded(), + "thread step-in command succeeded.") + + frame = thread.frames[0] + + self.assertEqual(frame.name, "main", "Stepped back out to main.") + # end_line is set to the line after the containing block. Check that + # we got there: + self.assertEqual(frame.line_entry.line, self.end_line, + "Got out of the block") diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/main.c new file mode 100644 index 00000000000..86a26c4d47a --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/c/step-target/main.c @@ -0,0 +1,40 @@ +#include <stdio.h> + +void +lotsOfArgs +( + int firstArg, + int secondArg, + int thirdArg, + int fourthArg +) +{ + printf ("First: %d Second: %d Third: %d Fourth: %d.\n", + firstArg, + secondArg, + thirdArg, + fourthArg); +} + +int +modifyInt(int incoming) +{ + return incoming % 2; +} + +int +main (int argc, char **argv) +{ + if (argc > 0) + { + int var_makes_block = argc + 1; + printf ("Break here to try targetted stepping.\n"); + lotsOfArgs(var_makes_block, + modifyInt(20), + 30, + modifyInt(40)); + printf ("Done calling lotsOfArgs."); + } + printf ("All done.\n"); + return 0; +} |