Phase 5 follow-up: step-over lands in the caller; Hits column syncs
- debugger.py step_over: pdb stops once more at the --Return-- event inside the finishing function, so one extra `next` lands in the caller (GDB `next` behaviour). A --Return-- stop at a breakpoint line is no longer misreported as a breakpoint hit. - debugger_ui.py: sync hit counts from pdb on every stop so the breakpoint pane's Hits column shows the real count. - tests: step over the last line of a function lands in the caller (new test_step_over_last_line_lands_in_caller). Full suite: 240 tests pass.
This commit is contained in:
1 parent
b6702c381e
commit
ba3b144383
3 files changed
+33
-3
No files matched your search
+13
-3
@@ -535,7 +535,10 @@ class PdbSession:
|
||||
frame = parsed
|
||||
break
|
||||
bp_id = 0
|
||||
if frame is not None:
|
||||
if frame is not None and "--Return--" not in response:
|
||||
# A --Return-- stop is reported at the returning
|
||||
# function's last line, which may itself be a
|
||||
# breakpoint line — that is a step stop, not a hit.
|
||||
for bp in self._breakpoints:
|
||||
if bp.id and bp.file == frame.file \
|
||||
and bp.line == frame.line and bp.enabled:
|
||||
@@ -608,8 +611,15 @@ class PdbSession:
|
||||
return self._exec("step", timeout_s)
|
||||
|
||||
def step_over(self, timeout_s=None):
|
||||
"""Step over the current line (pdb ``next``)."""
|
||||
return self._exec("next", timeout_s)
|
||||
"""Step over the current line (pdb ``next``). Stepping over
|
||||
the last line of a function stops at pdb's ``--Return--``
|
||||
event inside that function; one more step lands in the
|
||||
caller, like GDB's ``next``."""
|
||||
if not self._exec("next", timeout_s):
|
||||
return False
|
||||
if "--Return--" in self._last_exec_response:
|
||||
return self._exec("next", timeout_s)
|
||||
return True
|
||||
|
||||
def step_out(self, timeout_s=None):
|
||||
"""Step out of the current function (pdb ``return``). At
|
||||
|
||||
@@ -677,6 +677,9 @@ class DebuggerWindow:
|
||||
self.on_status(text)
|
||||
|
||||
def _after_state_change(self):
|
||||
# Sync hit counts from pdb so the Hits column is accurate.
|
||||
if self.session.state == STATE_STOPPED:
|
||||
self.session.refresh_breakpoints()
|
||||
self._refresh_all()
|
||||
self._update_buttons()
|
||||
self._drain_output()
|
||||
|
||||
@@ -142,6 +142,23 @@ class SessionTests(unittest.TestCase):
|
||||
self.assertEqual(self.session.state, STATE_EXITED)
|
||||
self.assertIn("total 13", self.session.target_output())
|
||||
|
||||
def test_step_over_last_line_lands_in_caller(self):
|
||||
# Stepping over the last line of a function (return b) must
|
||||
# land in the caller, not sit on the --Return-- event inside
|
||||
# the function at a line that happens to hold a breakpoint.
|
||||
self.assertTrue(self.session.start(self.script))
|
||||
self.session.add_breakpoint("%s:4" % self.script)
|
||||
self.assertTrue(self.session.cont())
|
||||
self.assertEqual(self.session.last_stop.frame.line, 4)
|
||||
self.assertTrue(self.session.step_over())
|
||||
self.assertEqual(self.session.last_stop.frame.line, 5)
|
||||
self.assertTrue(self.session.step_over())
|
||||
self.assertEqual(self.session.last_stop.frame.function,
|
||||
"<module>")
|
||||
self.assertEqual(self.session.last_stop.frame.line, 7)
|
||||
self.assertEqual(self.session.last_stop.reason,
|
||||
"end-stepping-range")
|
||||
|
||||
def test_locals_evaluation(self):
|
||||
self.assertTrue(self.session.start(self.script))
|
||||
self.session.add_breakpoint("%s:7" % self.script)
|
||||
|
||||
Reference in new issue
Block a user