Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Nov 15, 2023
1 parent 16dc3d0 commit 1ce6cf3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
22 changes: 17 additions & 5 deletions pydevd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ def add_break_on_exception(

return eb

def set_suspend(self, thread, stop_reason, suspend_other_threads=False, is_pause=False, original_step_cmd=-1):
def set_suspend(self, thread, stop_reason, suspend_other_threads=False, is_pause=False, original_step_cmd=-1, suspend_requested: bool=False):
'''
:param thread:
The thread which should be suspended.
Expand All @@ -1914,17 +1914,22 @@ def set_suspend(self, thread, stop_reason, suspend_other_threads=False, is_pause
:param original_step_cmd:
If given we may change the stop reason to this.
:param suspend_requested:
If the execution will be suspended right away then this may be false, otherwise,
if the thread should be stopped due to this suspend at a later time then it
should be true.
'''
self._threads_suspended_single_notification.increment_suspend_time()
if is_pause:
self._threads_suspended_single_notification.on_pause()

info = mark_thread_suspended(thread, stop_reason, original_step_cmd=original_step_cmd)

if is_pause:
if USE_SYS_MONITORING:
pydevd_sys_monitoring.update_monitor_events(suspend_requested=True)
if (suspend_requested or is_pause) and USE_SYS_MONITORING:
pydevd_sys_monitoring.update_monitor_events(suspend_requested=True)

if is_pause:
# Must set tracing after setting the state to suspend.
frame = info.get_topmost_frame(thread)
if frame is not None:
Expand Down Expand Up @@ -3061,9 +3066,16 @@ def _locked_settrace(
additional_info.pydev_step_cmd = CMD_STEP_OVER
additional_info.pydev_step_stop = stop_at_frame
additional_info.suspend_type = PYTHON_SUSPEND
if USE_SYS_MONITORING:
pydevd_sys_monitoring.update_monitor_events(suspend_requested=True)
py_db.set_trace_for_frame_and_parents(t, stop_at_frame)
else:
# Ask to break as soon as possible.
py_db.set_suspend(t, CMD_SET_BREAK)
py_db.set_suspend(t, CMD_SET_BREAK, suspend_requested=True)
py_db.set_trace_for_frame_and_parents(t, get_frame().f_back)

if USE_SYS_MONITORING:
pydevd_sys_monitoring.restart_events()


def stoptrace():
Expand Down
7 changes: 4 additions & 3 deletions tests_python/test_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ def test_module_entry_point(case_setup_m_switch_entry_point):
writer.finished_ok = True


@pytest.mark.skipif(not IS_CPYTHON, reason='CPython only test.')
@pytest.mark.skipif(not IS_CPYTHON or USE_SYS_MONITORING, reason='CPython only test.')
def test_check_tracer_with_exceptions(case_setup):

def get_environ(writer):
Expand Down Expand Up @@ -1402,7 +1402,7 @@ def additional_output_checks(writer, stdout, stderr):
writer.write_run_thread(hit.thread_id)

if not unhandled:
if sys.version_info[:2] >= (3, 12):
if sys.version_info[:2] >= (3, 12) and 'generator' not in target_file:
expected_lines = [
writer.get_line_index_with_content('# call exc'),
]
Expand Down Expand Up @@ -2547,7 +2547,8 @@ def test_py_37_breakpoint(case_setup, filename):
with case_setup.test_file(filename) as writer:
writer.write_make_initial_run()

hit = writer.wait_for_breakpoint_hit(file=filename, line=3)
hit = writer.wait_for_breakpoint_hit(file=filename)
assert hit.line in (3, 7), 'Expected hit in line 3 or 7. Found at: %s' % (hit.line,)

writer.write_run_thread(hit.thread_id)

Expand Down

0 comments on commit 1ce6cf3

Please sign in to comment.