Skip to content

gh-120769: Add pdb meta command to print frame status. #120770

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

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Jun 20, 2024

Using w 0 is a neat trick but it messed up with cmd.Cmd. We lost the last command with executing a valid command.

I came up with a way to sneak in secret commands (what I call a meta command) without changing too much of the current structure. The meta commands will not be recorded by cmd.Cmd and we can do whatever we want with it.

With this feature, we can unify the way to print the stack entry with or without the commands in cmdqueue.

I also renamed preloop - that's only used for display and it is only supposed to be displayed when user input is expected ("stops in the current frame" according to the docs). The test coverage is not great but for now it will display while commands from cmdqueue are executing.

The reason I changed display in a seemingly unrelated fix is because this is the way to ensure display still shows after stack entry print, not before.

By unifying the way to print frame status, we can print more stuff per stop, like async/thread info.

Meta commands could be useful in the future for us to sneak in other secret commands without messing with the core cmdloop and the command completion.

@gaogaotiantian
Copy link
Member Author

Hi @iritkatriel , sorry about the back and forth on this matter. I thought w 0 was a good solution back then but it had some issues. I wanted to unify how we print the stack entry (so we don't need to check if cmdqueue is empty) but appending w 0 unconditionally will break command repeat. I went for a "new command" but not a cmd.Cmd command so we have more flexibility. I think this structure will be useful in the future as well. This is not public so the user does not need to know about it.

@gaogaotiantian gaogaotiantian merged commit 31ce5c0 into python:main Jun 20, 2024
35 checks passed
@gaogaotiantian gaogaotiantian deleted the pdb-meta-commands branch June 20, 2024 17:38
@gaogaotiantian
Copy link
Member Author

Do you think it's worth it to backport this and fully remove the w related change in 3.12 and 3.13? Less surprise to a few users.

@iritkatriel
Copy link
Member

Yes, might as well.

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.

2 participants