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

gh-59013: Set breakpoint on the first executable line in pdb when using break func #112470

Merged
merged 6 commits into from
Jan 31, 2024

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Nov 27, 2023

In #110582, we made break foo work if foo is already a known function (that has an associated code object). However, if foo is in another module or it's not defined yet, we still use regular expression to find the definition, which will still set the breakpoint on the def line. This is an inconsistent behavior and will confuse users because the actual break will be on the first executable line.

This PR solves the issue by trying to compile the head of function to find the first executable line. As long as the first couple of lines are compilable, we should be able to find the first executable line of the function and set the break point on it. This skips comments, empty lines well (and not using pure strings to figure it out).

Notably, this is a breaking change - because the previous behavior is confusing.

@gaogaotiantian
Copy link
Member Author

Hi @iritkatriel , do you have some time to take a look at this PR? Basically this tries to locate the first line of the function when the user break on a function that is not complied yet so the line number of the breakpoint would be correct.

Lib/test/test_pdb.py Outdated Show resolved Hide resolved
Lib/test/test_pdb.py Outdated Show resolved Hide resolved
Lib/test/test_pdb.py Outdated Show resolved Hide resolved
Lib/test/test_pdb.py Show resolved Hide resolved
gaogaotiantian and others added 2 commits January 30, 2024 13:21
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@iritkatriel iritkatriel merged commit 765b9ce into python:main Jan 31, 2024
31 checks passed
@gaogaotiantian gaogaotiantian deleted the pdb-break-function branch February 2, 2024 03:44
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
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