Skip to content

gh-142834: pdb commands command should use last available breakpoint#142835

Merged
gaogaotiantian merged 11 commits intopython:mainfrom
cocolato:fix_pdb_commands
Dec 20, 2025
Merged

gh-142834: pdb commands command should use last available breakpoint#142835
gaogaotiantian merged 11 commits intopython:mainfrom
cocolato:fix_pdb_commands

Conversation

@cocolato
Copy link
Contributor

@cocolato cocolato commented Dec 16, 2025

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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants