-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-139721: Add ignore_module/unignore_module commands to pdb #139724
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
base: main
Are you sure you want to change the base?
Conversation
Add two new commands to pdb for skipping frames from specified modules: - ignore_module [module_name]: Add modules to skip during debugging - unignore_module [module_name]: Remove modules from skip list When a module is ignored, the debugger automatically skips over its frames during step, next, continue, up, and down commands. Supports wildcard patterns via fnmatch for flexible submodule matching.
Fix pdbcmd_sig_re to include underscores for commands like ignore_module
401e1e3
to
e3d97d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like the "unignore" verb (but I don't have a really better suggestion). How about ignore-module X on/off. Or "[show/hide]-module-frames"? (though you need to write more characters, but you can use autocompletion otherwise).
# Support for documenting pdb commands | ||
|
||
pdbcmd_sig_re = re.compile(r'([a-z()!]+)\s*(.*)') | ||
pdbcmd_sig_re = re.compile(r'([a-z()!_]+)\s*(.*)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commands usually have dashes instead of underscores. At least most UNIX commands would be with dashes so I think it's better to have dashes in general. (also gdb uses dashes and not underscores for commands with multiple words)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to follow the convention of using snake case, the other option I was thinking is not using separator as pdb does with the commands longlist
, whatis
and retval
. Adding dashes will imply changing how the commands are defined and discovered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For CLI-like options, I would prefer using dashes. Those are not really variables (even though they are stored in variables in the end). I'll leave the decision to Tian but we could also consider not having dashes/underscores at all if we find better words (showmodule, hidemodule would be fine I think although we're not really hiding them per se, just hiding them in the traceback).
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module() | ||
-> mod.foo_pony(callback) | ||
(Pdb) step | ||
[... skipped 1 ignored module(s)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I know why we have an ignored module here although the test uses the default parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an skipped module in the Pdb initialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, it wasn't part of the diff. If we already have skip=...
to parametrize this, I would suggest that we use skipmodule
and unskipmodule
for the commands instead.
|
||
newframe = i | ||
if module_skipped: | ||
self.message(f'[... skipped {module_skipped} frame(s) ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest indicating which module was ignored if there is only 1 module being ignored.
try: | ||
self.skip.remove(module_name) | ||
self.message(f'No longer ignoring module: {module_name}') | ||
except KeyError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only be emitted after .remove
was called (in case .message
raises a KeyError for some obscure reasons)
@@ -0,0 +1,5 @@ | |||
Add ``ignore_module`` and ``unignore_module`` commands to :mod:`pdb` to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would also need a What's New entry because it's a new feature for 3.15.
- Skip standard library modules (``threading``, ``multiprocessing``, ``logging.*``) | ||
- Skip test framework internals (``*pytest*``, ``unittest.*``) | ||
|
||
.. versionadded:: 3.15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. versionadded:: 3.15 | |
.. versionadded:: next |
I'm not a big fan of that verb either but I tried to keep the functionality and naming consistent with other "oposite" commands like alias/unalias and display/undisplay |
I'd prefer the A |
Please take a look at my comment #139721 (comment) before spending more time on this feature. Thanks! |
Add two new commands to pdb for skipping frames from specified modules:
When a module is ignored, the debugger automatically skips over its frames during step, next, continue, up, and down commands. Supports wildcard patterns via fnmatch for flexible module matching.
This feature improves debugging productivity when working with frameworks by allowing developers to hide framework-internal frames and focus on application code.
Issue: #139721