FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-82987: Stop on calling frame unconditionally for inline breakpoints by gaogaotiantian · Pull Request #130493 · python/cpython · GitHub

/ cpython Public

gh-82987: Stop on calling frame unconditionally for inline breakpoints - #130493

Merged
gaogaotiantian merged 6 commits into
python:mainfrom
gaogaotiantian:breakpoint-stop-unconditionally
Mar 4, 2025
Merged

gh-82987: Stop on calling frame unconditionally for inline breakpoints#130493
gaogaotiantian merged 6 commits into
python:mainfrom
gaogaotiantian:breakpoint-stop-unconditionally

Conversation

gaogaotiantian commented Feb 24, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

The testing code

import pdb
def foo():
    x = 40 + 2
    pdb.Pdb(skip=['__main__']).set_trace()
foo()

seems a bit silly, but this is a real issue because we use the last instance of pdb for inline breakpoints now.

So if we instantiate a debugger like p = pdb.Pdb(skip=["django.*"]) somewhere, and we set an inline breakpoint in Django with an innocent breakpoint(), it still won't stop inside Django modules.

Overall I think it's reasonable that we always stop for inline breakpoints. The implementation I chose is to remove the condition for opcode events which also makes sense. For now that event is exclusively used by inline breakpoints. Even if we add instruction level debugging in the future, I think the only useful command is "step instruction". It's hard to imagine instruction level breakpoints or something like until instruction. Always trigger user function for opcode seems like an okay solution.

Comment thread Lib/bdb.py Outdated
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
@@ -0,0 +1 @@
:mod:`pdb` will always stop on calling frames when inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` are used, regardless of whether the module matches ``skip`` pattern.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is probably worth a what's new entry.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

And a versionchange comment in the doc?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done

gaogaotiantian and others added 2 commits March 3, 2025 17:37
Comment thread Doc/library/pdb.rst Outdated
Added the *mode* argument.

.. versionchanged:: 3.14
*skip* will be ignored if inline breakpoints like :func:`breakpoint` or :func:`set_trace` are used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

"if ... are used" could be misunderstood to mean that skip will always be ignored if those are ever used.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Will changing it to "when ... are used" better? Or we should just use the longer version from the news entry?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think "when .. are used" has the same problem, as does the longer version from the news entry.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will always stop the program at calling frame, ignoring the ``skip`` pattern (if any).

Is this better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Then I'll use this for all 3 places :)

gaogaotiantian merged commit 63b6ec3 into python:main Mar 4, 2025
gaogaotiantian deleted the breakpoint-stop-unconditionally branch March 4, 2025 16:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL