Pdb and derived debuggers (IPdb, Upb, …) proposes advanced features for debugging, but lacks different fine-grain stepping (instruction level and AST-node level) or object-centric breakpoints (OC breakpoints).
I saw that there is some efforts to make Pdb and Bdb compatible with the PEP-669 and that add the instruction level stepping, but not the AST-node level or object-centric breakpoints.
I worked a little while in the Smalltalk community and this is something that is existing, depending on the Smalltalk dialect you are using. This makes debugging way more efficient, especially object-centric breakpoints when debugging UI.
In the past, with a collegue, we made some experiments to introduce object-centric breakpoints and AST-node granularity in Python using run time code rewriting (basically), but lately, seeing the last addition in Python 3.11 about bytecode localisation, I gave it another shot with a different/more direct approach in this PoC, trying to work with Bdb/Pdb/IPdb architecture. The addition of such granularitly stepping and OC breakpoints seems feasible.
It extends/subclasses IPdb with an interactive selection of AST nodes using curses and introducing, I was able to include the AST-node granularity breakpoint and two object-centric breakpoints: stop on instance attribute read and stop on instance attribute write (and some expérimental evaluation stack manipulation).
Obviously, this PoC impacts performances as it requires constant checks for the object-centric breakpoints, and there is probably a lot of corner cases.
I really understand AST-node granularity and object-centric breakpoints are definitely not mandatory, but they really make life easier on numerous occasion.
- Being able to step/stop sub-expression after sub-expression and to peek/query the topstack (no need to split or re-evaluate sub-expression in long lines);
- Have strong object-centric breakpoints to help debugging object-oriented code (helps focusing on object interactions when debugging).
- Need to access the top of the evaluation stack (currently done with a C extension, not amazing);
- Need for an interactive selection of the AST-node (currently done through a curse TUI).
I looked for tickets/issues that would have been discussed already in this category or in the old python-ideas mailing list.