GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-59013: Set breakpoint on the first executable line in pdb when using `break func` by gaogaotiantian · Pull Request #112470 · python/cpython

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Nov 27, 2023 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

  • Issue: Pdb does not stop at a breakpoint set on the line of a function definition #59013

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

equationzhao and fjqz177 reacted with heart emoji
All reactions
  • ❤️ 2 reactions
gaogaotiantian added 2 commits November 27, 2023 11:27
@gaogaotiantian
Make break function work consistently
727f6c5
@gaogaotiantian
Fix test name, add multiline test
9c33910
@JelleZijlstra JelleZijlstra closed this Nov 27, 2023
@JelleZijlstra JelleZijlstra reopened this Nov 27, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Nov 27, 2023
Pdb does not stop at a breakpoint set on the line of a function definition #59013
Closed
@blurb-it
📜🤖 Added by blurb_it.
8ffd987
@bedevere-app bedevere-app Bot added the awaiting review label Nov 27, 2023
@gaogaotiantian
Update 2023-11-27-19-54-43.gh-issue-59013.chpQ0e.rst
eff6675
@gaogaotiantian
gaogaotiantian requested a review from iritkatriel November 27, 2023 21:23
@gaogaotiantian

gaogaotiantian commented Jan 29, 2024

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel
iritkatriel reviewed Jan 30, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-11-27-19-54-43.gh-issue-59013.chpQ0e.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_pdb.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_pdb.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_pdb.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_pdb.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

gaogaotiantian and others added 2 commits January 30, 2024 13:21
@gaogaotiantian @iritkatriel
Add line number to the code
bb1f81a
Co-authored-by: Irit Katriel <[email protected]>
@gaogaotiantian
Update 2023-11-27-19-54-43.gh-issue-59013.chpQ0e.rst
3868f88
iritkatriel
iritkatriel reviewed Jan 30, 2024
View reviewed changes
Comment thread Lib/pdb.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel
iritkatriel approved these changes Jan 31, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Jan 31, 2024
@iritkatriel
iritkatriel merged commit 765b9ce into python:main Jan 31, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 31, 2024
@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
@gaogaotiantian @aisk
pythongh-59013: Set breakpoint on the first executable line of functi…
24c44c0
…on when using `break func` in pdb (python#112470)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@gaogaotiantian @iritkatriel @JelleZijlstra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.