https://github.com/jimingham updated https://github.com/llvm/llvm-project/pull/129340
>From 02e908312518e85f1d637529c9f62e3dd9551035 Mon Sep 17 00:00:00 2001 From: Jim Ingham <jing...@apple.com> Date: Fri, 28 Feb 2025 15:55:03 -0800 Subject: [PATCH 1/3] Fix a bug copying the stop hooks from the dummy target. We didn't also copy over the next stop hook id, which meant we would overwrite the stop hooks from the dummy target with stop hooks set after they are copied over. --- lldb/source/Target/Target.cpp | 1 + .../target/stop-hooks/TestStopHooks.py | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index db289fe9c4b64..550424720e095 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -211,6 +211,7 @@ Target::~Target() { void Target::PrimeFromDummyTarget(Target &target) { m_stop_hooks = target.m_stop_hooks; + m_stop_hook_next_id = target.m_stop_hook_next_id; for (const auto &breakpoint_sp : target.m_breakpoint_list.Breakpoints()) { if (breakpoint_sp->IsInternal()) diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py index fe59bd8a5d007..5215ec7258d14 100644 --- a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py +++ b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py @@ -26,10 +26,15 @@ def test_stop_hooks_step_out(self): self.step_out_test() def test_stop_hooks_after_expr(self): - """Test that a stop hook fires when hitting a breakpoint - that runs an expression""" + """Test that a stop hook fires when hitting a breakpoint that + runs an expression""" self.after_expr_test() + def test_stop_hooks_before_and_after_creation(self): + """Test that if we add a stop hook in the dummy target, we can + they don't collide with ones set directly in the target.""" + self.before_and_after_target() + def step_out_test(self): (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Set a breakpoint here", self.main_source_file @@ -85,3 +90,18 @@ def after_expr_test(self): var = target.FindFirstGlobalVariable("g_var") self.assertTrue(var.IsValid()) self.assertEqual(var.GetValueAsUnsigned(), 1, "Updated g_var") + + def before_and_after_target(self): + 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") + + (target, process, thread, first_bkpt) = lldbutil.run_to_source_breakpoint( + self, "Set a breakpoint here", self.main_source_file + ) + + interp.HandleCommand("target stop-hook add -o 'thread backtrace'", result) + self.assertTrue(result.Succeeded(), "Set the target stop hook") + self.expect("target stop-hook list", substrs=["expr g_var++", "thread backtrace"]) + >From 72e6f179525f1e13e7a1617ab04853304d116537 Mon Sep 17 00:00:00 2001 From: Jim Ingham <jing...@apple.com> Date: Fri, 28 Feb 2025 16:23:31 -0800 Subject: [PATCH 2/3] uglify --- .../test/API/commands/target/stop-hooks/TestStopHooks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py index 5215ec7258d14..c2cdcf0e2af52 100644 --- a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py +++ b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py @@ -27,12 +27,12 @@ def test_stop_hooks_step_out(self): def test_stop_hooks_after_expr(self): """Test that a stop hook fires when hitting a breakpoint that - runs an expression""" + runs an expression""" self.after_expr_test() def test_stop_hooks_before_and_after_creation(self): """Test that if we add a stop hook in the dummy target, we can - they don't collide with ones set directly in the target.""" + they don't collide with ones set directly in the target.""" self.before_and_after_target() def step_out_test(self): @@ -103,5 +103,6 @@ def before_and_after_target(self): interp.HandleCommand("target stop-hook add -o 'thread backtrace'", result) self.assertTrue(result.Succeeded(), "Set the target stop hook") - self.expect("target stop-hook list", substrs=["expr g_var++", "thread backtrace"]) - + self.expect( + "target stop-hook list", substrs=["expr g_var++", "thread backtrace"] + ) >From 1f2d82a0d89c7eef48753840d06d63624b1fb8fd Mon Sep 17 00:00:00 2001 From: Jim Ingham <jing...@apple.com> Date: Fri, 28 Feb 2025 16:59:54 -0800 Subject: [PATCH 3/3] Better comment on the test. --- lldb/test/API/commands/target/stop-hooks/TestStopHooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py index c2cdcf0e2af52..6aaed98d41d89 100644 --- a/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py +++ b/lldb/test/API/commands/target/stop-hooks/TestStopHooks.py @@ -31,8 +31,8 @@ def test_stop_hooks_after_expr(self): self.after_expr_test() def test_stop_hooks_before_and_after_creation(self): - """Test that if we add a stop hook in the dummy target, we can - they don't collide with ones set directly in the target.""" + """Test that if we add a stop hooks in the dummy target, + they aren't overridden by the ones set directly in the target.""" self.before_and_after_target() def step_out_test(self): _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits