-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-124552 : Improve the accuracy of possible breakpoint check in bdb #124553
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
Changes from 4 commits
ba6e6fd
6766505
f2e6926
53a6c5f
4fef93e
92408c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||
import fnmatch | ||||
import sys | ||||
import os | ||||
import weakref | ||||
from inspect import CO_GENERATOR, CO_COROUTINE, CO_ASYNC_GENERATOR | ||||
|
||||
__all__ = ["BdbQuit", "Bdb", "Breakpoint"] | ||||
|
@@ -36,6 +37,7 @@ def __init__(self, skip=None): | |||
self.frame_returning = None | ||||
self.trace_opcodes = False | ||||
self.enterframe = None | ||||
self.code_lineno = weakref.WeakKeyDictionary() | ||||
|
||||
self._load_breaks() | ||||
|
||||
|
@@ -155,6 +157,9 @@ def dispatch_return(self, frame, arg): | |||
if self.stop_here(frame) or frame == self.returnframe: | ||||
# Ignore return events in generator except when stepping. | ||||
if self.stopframe and frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS: | ||||
# It's possible to trigger a StopIteration exception in | ||||
# the caller so we must set the trace function in the caller | ||||
self._set_caller_tracefunc(frame) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is this related to this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a hidden bug which was exposed by the change of |
||||
return self.trace_dispatch | ||||
try: | ||||
self.frame_returning = frame | ||||
|
@@ -275,7 +280,23 @@ def do_clear(self, arg): | |||
def break_anywhere(self, frame): | ||||
"""Return True if there is any breakpoint for frame's filename. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment needs updating (it's not just filename now). |
||||
""" | ||||
return self.canonic(frame.f_code.co_filename) in self.breaks | ||||
filename = self.canonic(frame.f_code.co_filename) | ||||
if filename not in self.breaks: | ||||
return False | ||||
for lineno in self.breaks[filename]: | ||||
if self.lineno_in_frame(lineno, frame): | ||||
return True | ||||
return False | ||||
|
||||
def lineno_in_frame(self, lineno, frame): | ||||
"""Return True if the line number is in the frame's code object. | ||||
""" | ||||
code = frame.f_code | ||||
if lineno < code.co_firstlineno: | ||||
return False | ||||
if code not in self.code_lineno: | ||||
self.code_lineno[code] = set(lineno for _, _, lineno in code.co_lines()) | ||||
return lineno in self.code_lineno[frame.f_code] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
# Derived classes should override the user_* methods | ||||
# to gain control. | ||||
|
@@ -360,7 +381,7 @@ def set_next(self, frame): | |||
def set_return(self, frame): | ||||
"""Stop when returning from the given frame.""" | ||||
if frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS: | ||||
self._set_stopinfo(frame, None, -1) | ||||
self._set_stopinfo(frame, frame, -1) | ||||
else: | ||||
self._set_stopinfo(frame.f_back, frame) | ||||
|
||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Improve the accuracy of possible breakpoint check in bdb so we can disable unnecessary events in functions. | ||
gaogaotiantian marked this conversation as resolved.
Show resolved
Hide resolved
|
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.