Author: Julian Lettner Date: 2025-04-01T15:36:35-07:00 New Revision: c8764f0c655b2edb139896ecbb9f5bfd932fbe4b
URL: https://github.com/llvm/llvm-project/commit/c8764f0c655b2edb139896ecbb9f5bfd932fbe4b DIFF: https://github.com/llvm/llvm-project/commit/c8764f0c655b2edb139896ecbb9f5bfd932fbe4b.diff LOG: Fix handling of auto_continue for stop hooks (#129622) Follow-up fix discussed here: https://github.com/llvm/llvm-project/pull/129578#issuecomment-2695838042 --------- Co-authored-by: Jim Ingham <jing...@apple.com> Added: Modified: lldb/source/Target/Target.cpp lldb/test/API/commands/target/stop-hooks/TestStopHooks.py Removed: ################################################################################ diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 09c0c0b8a5db0..42b1561fb2993 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3094,7 +3094,6 @@ bool Target::RunStopHooks() { bool print_hook_header = (m_stop_hooks.size() != 1); bool print_thread_header = (num_exe_ctx != 1); - bool auto_continue = false; bool should_stop = false; bool requested_continue = false; @@ -3108,10 +3107,6 @@ bool Target::RunStopHooks() { if (!cur_hook_sp->ExecutionContextPasses(exc_ctx)) continue; - // We only consult the auto-continue for a stop hook if it matched the - // specifier. - auto_continue |= cur_hook_sp->GetAutoContinue(); - if (print_hook_header && !any_thread_matched) { StreamString s; cur_hook_sp->GetDescription(s, eDescriptionLevelBrief); @@ -3130,7 +3125,10 @@ bool Target::RunStopHooks() { auto result = cur_hook_sp->HandleStop(exc_ctx, output_sp); switch (result) { case StopHook::StopHookResult::KeepStopped: - should_stop = true; + if (cur_hook_sp->GetAutoContinue()) + requested_continue = true; + else + should_stop = true; break; case StopHook::StopHookResult::RequestContinue: requested_continue = true; @@ -3155,10 +3153,9 @@ bool Target::RunStopHooks() { } } - // Resume iff: - // 1) At least one hook requested to continue and no hook asked to stop, or - // 2) at least one hook had auto continue on. - if ((requested_continue && !should_stop) || auto_continue) { + // Resume iff at least one hook requested to continue and no hook asked to + // stop. + if (requested_continue && !should_stop) { Log *log = GetLog(LLDBLog::Process); Status error = m_process_sp->PrivateResume(); if (error.Success()) { diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py index 0c42fda260d1b..7d52676121827 100644 --- a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py +++ b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py @@ -9,9 +9,6 @@ class TestStopHooks(TestBase): - # If your test case doesn't stress debug info, then - # set this to true. That way it won't be run once for - # each debug info format. NO_DEBUG_INFO_TESTCASE = True def setUp(self): @@ -42,12 +39,18 @@ def step_out_test(self): interp = self.dbg.GetCommandInterpreter() result = lldb.SBCommandReturnObject() - interp.HandleCommand("target stop-hook add -o 'expr g_var++'", result) + # Add two stop hooks here, one to auto-continue and one not. Make sure + # that we still stop in that case. + interp.HandleCommand("target stop-hook add -G false -o 'expr g_var++'", result) self.assertTrue(result.Succeeded(), "Set the target stop hook") + + interp.HandleCommand("target stop-hook add -G true -o 'expr g_var++'", result) + self.assertTrue(result.Succeeded(), "Set the second target stop hook") + thread.StepOut() var = target.FindFirstGlobalVariable("g_var") self.assertTrue(var.IsValid()) - self.assertEqual(var.GetValueAsUnsigned(), 1, "Updated g_var") + self.assertEqual(var.GetValueAsUnsigned(), 2, "Updated g_var") def after_expr_test(self): interp = self.dbg.GetCommandInterpreter() _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits