Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
25 changes: 23 additions & 2 deletions lldb/test/API/commands/target/stop-hooks/TestStopHooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot a word? we can they don't collide

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
Expand Down Expand Up @@ -85,3 +90,19 @@ 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"]
)