Skip to content

Commit c3d5295

Browse files
authored
Fix breakpoint removal after debugger exit (#1179)
1 parent a37e8fe commit c3d5295

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

core/debuggerstate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,17 +683,17 @@ bool DebuggerBreakpoints::AddOffset(const ModuleNameAndOffset& address)
683683

684684
bool DebuggerBreakpoints::RemoveAbsolute(uint64_t remoteAddress)
685685
{
686-
if (!m_state->GetAdapter())
687-
return false;
688-
689686
ModuleNameAndOffset info = m_state->GetModules()->AbsoluteAddressToRelative(remoteAddress);
690687
auto it = FindBreakpoint(info);
691688
if (it == m_breakpoints.end())
692689
return false;
693690

694691
m_breakpoints.erase(it);
695692
SerializeMetadata();
696-
m_state->GetAdapter()->RemoveBreakpoint(remoteAddress);
693+
694+
if (m_state->GetAdapter() && m_state->IsConnected())
695+
m_state->GetAdapter()->RemoveBreakpoint(remoteAddress);
696+
697697
return true;
698698
}
699699

test/debugger_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,23 @@ def test_breakpoint(self):
367367
self.assertEqual(dbg.ip, entry)
368368
dbg.quit_and_wait()
369369

370+
def test_remove_breakpoint_after_exit(self):
371+
"""Removing a logical breakpoint after DbgEng teardown must not call the backend."""
372+
if self.adapter_type != 'DBGENG':
373+
self.skipTest('Regression is specific to DbgEng teardown')
374+
375+
fpath = name_to_fpath('helloworld', self.arch)
376+
bv = load(fpath)
377+
dbg = self.create_debugger(bv)
378+
self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])
379+
self.assertEqual(sleep_and_go(dbg), DebugStopReason.ProcessExited)
380+
381+
entry = dbg.data.entry_point
382+
dbg.add_breakpoint(entry)
383+
self.assertTrue(any(bp.address == entry for bp in dbg.breakpoints))
384+
dbg.delete_breakpoint(entry)
385+
self.assertFalse(any(bp.address == entry for bp in dbg.breakpoints))
386+
370387
def test_breakpoint_condition(self):
371388
fpath = name_to_fpath('helloworld', self.arch)
372389
bv = load(fpath)

0 commit comments

Comments
 (0)