cpython
cpython copied to clipboard
gh-142834: pdb commands command should use last available breakpoint
What this PR does
When commands is invoked without an argument, pdb now finds and uses the last available (non-deleted) breakpoint instead of blindly using the last breakpoint number which might have been deleted.
main.py:
foo = 1
bar = 2
➜ ./python -m pdb main.py
> /cpython/main.py(2)<module>()
-> foo = 1
(Pdb) b 3
Breakpoint 1 at /cpython/main.py:3
(Pdb) b 2
Breakpoint 2 at /cpython/main.py:2
(Pdb) clear 2
Deleted breakpoint 2 at /cpython/main.py:2
(Pdb) commands # should set command on breakpoint 1
*** cannot set commands: Breakpoint 2 already deleted
after fix:
➜ ./python -m pdb main.py
> /cpython/main.py(2)<module>()
-> foo = 1
(Pdb) b 3
Breakpoint 1 at /cpython/main.py:3
(Pdb) b 2
Breakpoint 2 at /cpython/main.py:2
(Pdb) clear 2
Deleted breakpoint 2 at /cpython/main.py:2
(Pdb) commands
(com) p "success"
(com) end
(Pdb) c
'success'
> /home/loyd/code_files/cpython/main.py(3)<module>()
-> bar = 2
- Issue: gh-142834