-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Support instruction-level debugging in pdb #103049
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
Comments
I linked a prototype for the instruction display. Please let me know if we want to proceed on this feature. I can either do two PRs(I would assume |
We don't want a As for working with opcodes, that's an interesting idea! But do we need a separate assembly mode? It feels to me like it would be more flexible to add new commands for this, like |
I was actually torn between the two ideas - whether to overload the existing command with a state flipper, or to add two extra commands. There are two reasons I'm leaning slightly toward the state solution:
I can go along with the extra commands as well, the debugger I was using for C in my prev company uses more like a state switch solution. We can only display the current instruction when the user uses Actually there's another possibility - we overload everything. In assembly mode, The reason I brought up a new command for Also I guess there are a couple of names for the On the side note, now that I think about it, |
I am excited about this proposal. Indeed, there are plenty of options for how this could be implemented. I would like to know your thoughts on how LLDB handles disassembly. LLDB has separate commands for source and instruction level stepping:
Additionally, LLDB provides settings to control whether to display disassembly when stopped. I took a couple of screenshots for demonstration. By default, LLDB only shows source code when stopped, even with instruction level stepping: Although it does not display disassembly, it marks the corresponding piece of code that is being executed. By setting Do you think pdb could provide a similar user experience? And how beneficial would such behaviour be for Python programmers? |
I guess having Personally, I'd like my debugger to show some difference when I do As for the benefits, I'm not sure. I would guess most of the Python users debug their program with I'm totally fine with |
Dear nosy: I've finished a draft for the implementation. I decided to go no-state. Separate commands for all instruction-related stuff. So, Anyone has suggestions/questions on this? Once the implementation is reviewed and confirmed, I can work on the tests and docs. |
Overall, this approach looks good to me! I agree that it better suits CLI than having a separate assembly mode. I also like that One more thing to consider is the terminal width. Disassembly output can be wide, at least because of the full file paths:
However, I do not have a particular idea of how to approach that properly. |
Unfortunately, this piece is using the internal function of |
Hi all, the feature, test and docs are all finished and ready for review now. |
This is very technically cool, but I can't think of any use cases for end users and it's a lot of code. (Am I just not creative enough?) I can, however, imagine that core devs working on the Python bytecode compiler will get benefit from it. Maybe we should get buy in from some potential users before complicating Bdb? |
Python has All I'm saying is, there are different needs for different developers - for a lot of developers, they do not even use debuggers,. Having a working solution for debugging instructions does not make pdb worse. And yes, there are more code in bdb, but most of them are on isolated paths that are very specific to instruction tracing. It does not impact the current bdb responsibilities. For use cases, there is a very common pattern in Python - one-liners. Often they consist of multiple expressions. As of now, pdb can only execute it as a full line, and the debuggability within the line is horrible. Having an instruction-level debugging in pdb would solve that. However, with the new PEP 669, this work is blocked by the implementation of #103615 , which I'm also responsible for. So this feature will only be visited later. |
Feature or enhancement
Support instruction-level debugging in pdb
li
andlli
to display instructions with source codesi
andni
commandPitch
pdb
could provide a better debugging experience by supporting instruction level debugging. We already have most of the utilities but we need to put them together.The new commands will be introduced:
li(listinst)
,lli(longlistinst)
,si(stepinst)
andni(nextinst)
(Another candidate would bedis
, which is short forimport dis; dis.dis()
).li
andlli
will list source file with the instructions.si
will step one instruction ahead andni
will stay in this frame. We haveopcode
event to support this.Previous discussion
Did not find any.
Linked PRs
The text was updated successfully, but these errors were encountered: