Skip to content

Commit 2e073e3

Browse files
committed
Explain: revert debugger time on reverse_finish failure
Previously, `reverse_finish` only restored the selected frame on failure. Just reverting the frame should work considering what `reverse_finish`, but restoring the full bookmarked time is safer, consistent with other tools and restores the frame anyway.
1 parent c27c1aa commit 2e073e3

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

explain/explain.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ def tool_reverse_next(self) -> None:
490490
@report
491491
@source_context
492492
@collect_output
493+
@revert_time_on_failure
493494
@chain_of_thought
494495
def tool_reverse_finish(self, target_fn: str) -> None:
495496
"""
@@ -500,29 +501,24 @@ def tool_reverse_finish(self, target_fn: str) -> None:
500501
which will improve performance.
501502
502503
On success it will pop at least one stack frame, even in recursive calls. On failure it will
503-
return to the originally-selected stack frame.
504+
return to the original point in time.
504505
505506
Params:
506507
target_fn: the function you want to reverse-finish back to. This must be present in
507508
the current backtrace or the command will fail.
508509
"""
509-
orig_frame = gdbutils.selected_frame()
510-
try:
511-
frame = orig_frame.older()
512-
while frame and frame.name() != target_fn:
513-
frame = frame.older()
510+
frame = gdbutils.selected_frame().older()
511+
while frame and frame.name() != target_fn:
512+
frame = frame.older()
514513

515-
if not frame:
516-
raise Exception("No such frame in current backtrace.")
514+
if not frame:
515+
raise Exception("No such frame in current backtrace.")
517516

518-
# Finish out into the specified frame.
519-
frame.newer().select()
520-
self.udb.execution.reverse_finish(cmd="reverse-finish")
517+
# Finish out into the specified frame.
518+
frame.newer().select()
519+
self.udb.execution.reverse_finish(cmd="reverse-finish")
521520

522-
assert gdbutils.selected_frame().name() == target_fn
523-
except:
524-
orig_frame.select()
525-
raise
521+
assert gdbutils.selected_frame().name() == target_fn
526522

527523
def _reverse_into_target_function(self, target_fn: str) -> str:
528524
"""

0 commit comments

Comments
 (0)