Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class PyDBAdditionalThreadInfo(object):
"pydev_use_scoped_step_frame",
"weak_thread",
"is_in_wait_loop",
"hit_breakpoint_ids",
]
# ENDIF
# fmt: on
Expand Down Expand Up @@ -118,6 +119,7 @@ def __init__(self):
# at this time (otherwise it may be suspended but still didn't reach a point.
# to pause).
self.is_in_wait_loop = False
self.hit_breakpoint_ids = None

# fmt: off
# IFDEF CYTHON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def handle_hit_condition(self, frame):


class FunctionBreakpoint(object):
def __init__(self, func_name, condition, expression, suspend_policy="NONE", hit_condition=None, is_logpoint=False):
def __init__(self, breakpoint_id, func_name, condition, expression, suspend_policy="NONE", hit_condition=None, is_logpoint=False):
self.breakpoint_id = breakpoint_id
self.condition = condition
self.func_name = func_name
self.expression = expression
Expand Down
8,636 changes: 4,419 additions & 4,217 deletions src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_cython.c

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cdef class PyDBAdditionalThreadInfo:
cdef public bint pydev_use_scoped_step_frame
cdef public object weak_thread
cdef public bint is_in_wait_loop
cdef public object hit_breakpoint_ids

cpdef get_topmost_frame(self, thread)
cpdef update_stepping_info(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ cdef class PyDBAdditionalThreadInfo:
# "pydev_use_scoped_step_frame",
# "weak_thread",
# "is_in_wait_loop",
# "hit_breakpoint_ids",
# ]
# ENDIF
# fmt: on
Expand Down Expand Up @@ -124,6 +125,7 @@ cdef class PyDBAdditionalThreadInfo:
# at this time (otherwise it may be suspended but still didn't reach a point.
# to pause).
self.is_in_wait_loop = False
self.hit_breakpoint_ids = None

# fmt: off
# IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
Expand Down Expand Up @@ -1088,6 +1090,10 @@ cdef class PyDBFrame:

# if thread has a suspend flag, we suspend with a busy wait
if info.pydev_state == 2:
# This may also be reached by an unrelated pause, hence the inner check.
# Scoped to this suspension only: cleared in PyDB._do_wait_suspend.
if stop or stop_on_plugin_breakpoint:
info.hit_breakpoint_ids = [breakpoint.breakpoint_id]
self.do_wait_suspend(thread, frame, event, arg)
return self.trace_dispatch
else:
Expand Down
4 changes: 4 additions & 0 deletions src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ def trace_dispatch(self, frame, event, arg):

# if thread has a suspend flag, we suspend with a busy wait
if info.pydev_state == STATE_SUSPEND:
# This may also be reached by an unrelated pause, hence the inner check.
# Scoped to this suspension only: cleared in PyDB._do_wait_suspend.
if stop or stop_on_plugin_breakpoint:
info.hit_breakpoint_ids = [breakpoint.breakpoint_id]
self.do_wait_suspend(thread, frame, event, arg)
return self.trace_dispatch
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,19 @@ def make_console_message(self, msg):
]
)

def _get_hit_breakpoint_ids(self, py_db, info, stop_reason):
if stop_reason not in ("breakpoint", "function breakpoint"):
return None

hit_breakpoint_ids = info.hit_breakpoint_ids
if not hit_breakpoint_ids:
return None

if stop_reason == "breakpoint" and any(py_db.has_breakpoint_id_collision(bp_id) for bp_id in hit_breakpoint_ids):
return None

return hit_breakpoint_ids

@overrides(NetCommandFactory.make_thread_suspend_single_notification)
def make_thread_suspend_single_notification(self, py_db, thread_id, thread, stop_reason):
exc_desc = None
Expand Down Expand Up @@ -427,6 +440,7 @@ def make_thread_suspend_single_notification(self, py_db, thread_id, thread, stop
text=exc_name,
allThreadsStopped=True,
preserveFocusHint=preserve_focus_hint,
hitBreakpointIds=self._get_hit_breakpoint_ids(py_db, info, stop_reason),
)
event = pydevd_schema.StoppedEvent(body)
return NetCommand(CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION, 0, event, is_json=True)
Expand Down Expand Up @@ -519,6 +533,7 @@ def make_thread_suspend_message(self, py_db, thread_id, frames_list, stop_reason
text=exc_name,
allThreadsStopped=False,
preserveFocusHint=preserve_focus_hint,
hitBreakpointIds=self._get_hit_breakpoint_ids(py_db, info, stop_reason),
)
event = pydevd_schema.StoppedEvent(body)
return NetCommand(CMD_THREAD_SUSPEND, 0, event, is_json=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,14 @@ def on_setfunctionbreakpoints_request(self, py_db, request):
for bp in arguments.breakpoints:
hit_condition = self._get_hit_condition_expression(bp.get("hitCondition"))
condition = bp.get("condition")
breakpoint_id = self._next_breakpoint_id()

function_breakpoints.append(FunctionBreakpoint(bp["name"], condition, expression, suspend_policy, hit_condition, is_logpoint))
function_breakpoints.append(
FunctionBreakpoint(breakpoint_id, bp["name"], condition, expression, suspend_policy, hit_condition, is_logpoint)
)

# Note: always succeeds.
breakpoints_set.append(pydevd_schema.Breakpoint(verified=True, id=self._next_breakpoint_id()).to_dict())
breakpoints_set.append(pydevd_schema.Breakpoint(verified=True, id=breakpoint_id).to_dict())

self.api.set_function_breakpoints(py_db, function_breakpoints)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ def _stop_on_breakpoint(
py_db.writer.add_command(cmd)

if stop:
additional_info.hit_breakpoint_ids = [bp.breakpoint_id]
py_db.set_suspend(
thread_info.thread,
stop_reason,
Expand All @@ -1359,6 +1360,7 @@ def _stop_on_breakpoint(
elif stop_on_plugin_breakpoint:
stop_at_frame = py_db.plugin.suspend(py_db, thread_info.thread, frame, bp_type)
if stop_at_frame and thread_info.additional_info.pydev_state == STATE_SUSPEND:
additional_info.hit_breakpoint_ids = [bp.breakpoint_id]
_do_wait_suspend(py_db, thread_info, stop_at_frame, "line", None)
return

Expand Down
Loading
Loading