Skip to content

Commit c8764f0

Browse files
ylnjimingham
andauthoredApr 1, 2025
Fix handling of auto_continue for stop hooks (llvm#129622)
Follow-up fix discussed here: llvm#129578 (comment) --------- Co-authored-by: Jim Ingham <[email protected]>
1 parent 7b2b3fa commit c8764f0

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed
 

‎lldb/source/Target/Target.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,7 +3094,6 @@ bool Target::RunStopHooks() {
30943094

30953095
bool print_hook_header = (m_stop_hooks.size() != 1);
30963096
bool print_thread_header = (num_exe_ctx != 1);
3097-
bool auto_continue = false;
30983097
bool should_stop = false;
30993098
bool requested_continue = false;
31003099

@@ -3108,10 +3107,6 @@ bool Target::RunStopHooks() {
31083107
if (!cur_hook_sp->ExecutionContextPasses(exc_ctx))
31093108
continue;
31103109

3111-
// We only consult the auto-continue for a stop hook if it matched the
3112-
// specifier.
3113-
auto_continue |= cur_hook_sp->GetAutoContinue();
3114-
31153110
if (print_hook_header && !any_thread_matched) {
31163111
StreamString s;
31173112
cur_hook_sp->GetDescription(s, eDescriptionLevelBrief);
@@ -3130,7 +3125,10 @@ bool Target::RunStopHooks() {
31303125
auto result = cur_hook_sp->HandleStop(exc_ctx, output_sp);
31313126
switch (result) {
31323127
case StopHook::StopHookResult::KeepStopped:
3133-
should_stop = true;
3128+
if (cur_hook_sp->GetAutoContinue())
3129+
requested_continue = true;
3130+
else
3131+
should_stop = true;
31343132
break;
31353133
case StopHook::StopHookResult::RequestContinue:
31363134
requested_continue = true;
@@ -3155,10 +3153,9 @@ bool Target::RunStopHooks() {
31553153
}
31563154
}
31573155

3158-
// Resume iff:
3159-
// 1) At least one hook requested to continue and no hook asked to stop, or
3160-
// 2) at least one hook had auto continue on.
3161-
if ((requested_continue && !should_stop) || auto_continue) {
3156+
// Resume iff at least one hook requested to continue and no hook asked to
3157+
// stop.
3158+
if (requested_continue && !should_stop) {
31623159
Log *log = GetLog(LLDBLog::Process);
31633160
Status error = m_process_sp->PrivateResume();
31643161
if (error.Success()) {

‎lldb/test/API/commands/target/stop-hooks/TestStopHooks.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010

1111
class TestStopHooks(TestBase):
12-
# If your test case doesn't stress debug info, then
13-
# set this to true. That way it won't be run once for
14-
# each debug info format.
1512
NO_DEBUG_INFO_TESTCASE = True
1613

1714
def setUp(self):
@@ -42,12 +39,18 @@ def step_out_test(self):
4239

4340
interp = self.dbg.GetCommandInterpreter()
4441
result = lldb.SBCommandReturnObject()
45-
interp.HandleCommand("target stop-hook add -o 'expr g_var++'", result)
42+
# Add two stop hooks here, one to auto-continue and one not. Make sure
43+
# that we still stop in that case.
44+
interp.HandleCommand("target stop-hook add -G false -o 'expr g_var++'", result)
4645
self.assertTrue(result.Succeeded(), "Set the target stop hook")
46+
47+
interp.HandleCommand("target stop-hook add -G true -o 'expr g_var++'", result)
48+
self.assertTrue(result.Succeeded(), "Set the second target stop hook")
49+
4750
thread.StepOut()
4851
var = target.FindFirstGlobalVariable("g_var")
4952
self.assertTrue(var.IsValid())
50-
self.assertEqual(var.GetValueAsUnsigned(), 1, "Updated g_var")
53+
self.assertEqual(var.GetValueAsUnsigned(), 2, "Updated g_var")
5154

5255
def after_expr_test(self):
5356
interp = self.dbg.GetCommandInterpreter()

0 commit comments

Comments
 (0)
Please sign in to comment.