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/commands/target/stop-hooks | |
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/commands/target/stop-hooks')
3 files changed, 58 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/Makefile new file mode 100644 index 00000000000..695335e068c --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/Makefile @@ -0,0 +1,4 @@ +C_SOURCES := main.c +CFLAGS_EXTRAS := -std=c99 + +include Makefile.rules diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/TestStopHooks.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/TestStopHooks.py new file mode 100644 index 00000000000..64686afe627 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/TestStopHooks.py @@ -0,0 +1,40 @@ +""" +Test that stop hooks trigger on "step-out" +""" + + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +class TestStopHooks(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_stop_hooks_step_out(self): + """Test that stop hooks fire on step-out.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.c") + self.step_out_test() + + def step_out_test(self): + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "Set a breakpoint here", self.main_source_file) + + interp = self.dbg.GetCommandInterpreter() + result = lldb.SBCommandReturnObject() + interp.HandleCommand("target stop-hook add -o 'expr g_var++'", result) + self.assertTrue(result.Succeeded, "Set the target stop hook") + thread.StepOut() + var = target.FindFirstGlobalVariable("g_var") + self.assertTrue(var.IsValid()) + self.assertEqual(var.GetValueAsUnsigned(), 1, "Updated g_var") + + diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/main.c new file mode 100644 index 00000000000..d08ad14776b --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/main.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +static int g_var = 0; + +int step_out_of_me() +{ + return g_var; // Set a breakpoint here and step out. +} + +int +main() +{ + return step_out_of_me(); +} |