1""" 2Test that stop hooks trigger on "step-out" 3""" 4 5 6 7import lldb 8import lldbsuite.test.lldbutil as lldbutil 9from lldbsuite.test.lldbtest import * 10 11 12class TestStopHooks(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 # If your test case doesn't stress debug info, the 17 # set this to true. That way it won't be run once for 18 # each debug info format. 19 NO_DEBUG_INFO_TESTCASE = True 20 21 def test_stop_hooks_step_out(self): 22 """Test that stop hooks fire on step-out.""" 23 self.build() 24 self.main_source_file = lldb.SBFileSpec("main.c") 25 self.step_out_test() 26 27 def step_out_test(self): 28 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 29 "Set a breakpoint here", self.main_source_file) 30 31 interp = self.dbg.GetCommandInterpreter() 32 result = lldb.SBCommandReturnObject() 33 interp.HandleCommand("target stop-hook add -o 'expr g_var++'", result) 34 self.assertTrue(result.Succeeded, "Set the target stop hook") 35 thread.StepOut() 36 var = target.FindFirstGlobalVariable("g_var") 37 self.assertTrue(var.IsValid()) 38 self.assertEqual(var.GetValueAsUnsigned(), 1, "Updated g_var") 39 40 41