[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AST-level granularity stepping and object-centric breakpoint for ipdb #14577

Open
aranega opened this issue Nov 7, 2024 · 3 comments
Open

AST-level granularity stepping and object-centric breakpoint for ipdb #14577

aranega opened this issue Nov 7, 2024 · 3 comments

Comments

@aranega
Copy link
aranega commented Nov 7, 2024

Hi there,

A year ago, I worked on a PoC for Python 3.11 that adds AST-level stepping and some object-centric breakpoints for ipdb. It extends/subclasses IPdb with an interactive selection of AST nodes using curses.

Having AST-level stepping brings interesting features for the debugger as we can stop in a specific AST-node, so expression nodes, not only statement nodes, e.g: you can stop just before the execution of n.y in [n.x + n.y for n in collection], or you can ask to continue execution until a expression/sub-expression is reached in the same execution frame, which can be handy for recursive-call debugs.
With object-centric breakpoints, you can ask to stop for any read/write of an attribute of a specific object instance.

Those kind of breakpoints are not strictly necessary in a debugging context, but they tremendously help when complex interactions between objects are involved. These are typically features that exists in Smalltalk (depending on the dialect), and that are valuable to any language that supports objects and OO in general.

It seems that Python 3.13 is currently not compatible with the PoC, and I'm evaluating if I find time to port it or not for Python >= 3.13. At the same time, I wonder if that could be potentially features that could be interesting to be proposed as a PR for ipdb/IPython directly?

@Carreau
Copy link
Member
Carreau commented Nov 11, 2024

This is cool !

I myself have had difficulties keeping up with Python 3.13.

I don't know if I'm ready to bake that in, into IPython itself ; (and note that ipdb is it's own package ) but I'm happy to add hooks into IPython that are enabled by default if dbge is installed so that the functionality is available by default.

This lets you update dbge at your own pace – without being limited on me to review/merge; and when it has been a bit more battle tested; why not merge it in core.

@aranega
Copy link
Author
aranega commented Nov 14, 2024

Thanks for your answer! Having some hooks as you suggest is definitely something that would be really amazing in the first place. I'll then see how to update the code on my side, then, what would be the necessary hooks I would need.

When I'll be up-to-date on this, I'll create a ticket on the repository for IPdb instead. I created the ticket here in the first place as I saw there was not so much activity there in the ticket/PR section, and I wasn't sure the repository was more used as a mirror and the discussions about features would have been centralized here.

Unless people think it's something valuable, I'll perhaps just remove the command of forcing the top of the evaluation stack of a frame to a value. It's useful, but complicated to use and can lead to failures in the VM if not handled properly by the user.

@Carreau
Copy link
Member
Carreau commented Nov 18, 2024

No worries; let me know the hooks or changes you need, and ipdb is a small-ish wrapper around IPython.debugger, so most core changes will likely be here, I just can't promise anything if you want changes in the IPdb repository ;-)

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

No branches or pull requests

2 participants