Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Nov 9, 2023
1 parent 92ec806 commit 7a9c471
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def _current_frames():
IS_PY311_OR_GREATER = sys.version_info >= (3, 11)
IS_PY312_OR_GREATER = sys.version_info >= (3, 12)

USE_SYS_MONITORING = IS_PY312_OR_GREATER and hasattr(sys, 'monitoring')


def version_str(v):
return '.'.join((str(x) for x in v[:3])) + ''.join((str(x) for x in v[3:]))
Expand Down Expand Up @@ -507,7 +509,7 @@ def iter_chars(b):
return iter(b)


if IS_JYTHON:
if IS_JYTHON or USE_SYS_MONITORING:

def NO_FTRACE(frame, event, arg):
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from _pydevd_bundle.pydevd_utils import notify_about_gevent_if_needed
import weakref
from _pydevd_bundle.pydevd_constants import IS_JYTHON, IS_IRONPYTHON, \
PYDEVD_APPLY_PATCHING_TO_HIDE_PYDEVD_THREADS
PYDEVD_APPLY_PATCHING_TO_HIDE_PYDEVD_THREADS, USE_SYS_MONITORING
from _pydev_bundle.pydev_log import exception as pydev_log_exception
import sys
from _pydev_bundle import pydev_log
import pydevd_tracing
from _pydevd_bundle.pydevd_collect_bytecode_info import iter_instructions
from _pydevd_sys_monitoring import pydevd_sys_monitoring

if IS_JYTHON:
import org.python.core as JyCore # @UnresolvedImport
Expand Down Expand Up @@ -67,6 +68,9 @@ def do_kill_pydev_thread(self):

def _stop_trace(self):
if self.pydev_do_not_trace:
if USE_SYS_MONITORING:
pydevd_sys_monitoring.stop_monitoring(all_threads=False)
return
pydevd_tracing.SetTrace(None) # no debugging on this thread


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from _pydev_bundle import pydev_log
from _pydevd_bundle import pydevd_dont_trace
from _pydevd_bundle.pydevd_constants import (RETURN_VALUES_DICT, NO_FTRACE,
EXCEPTION_TYPE_HANDLED, EXCEPTION_TYPE_USER_UNHANDLED, PYDEVD_IPYTHON_CONTEXT)
EXCEPTION_TYPE_HANDLED, EXCEPTION_TYPE_USER_UNHANDLED, PYDEVD_IPYTHON_CONTEXT,
USE_SYS_MONITORING)
from _pydevd_bundle.pydevd_frame_utils import add_exception_to_frame, just_raised, remove_exception_from_frame, ignore_exception_trace
from _pydevd_bundle.pydevd_utils import get_clsname_for_code
from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame
Expand Down Expand Up @@ -1251,3 +1252,11 @@ def trace_dispatch(self, frame, event, arg):
info.is_tracing -= 1

# end trace_dispatch


if USE_SYS_MONITORING:

class PyDBFrame:

def __init__(self, *args, **kwargs):
raise RuntimeError("Not expected to be used in sys.monitoring.")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from _pydev_bundle.pydev_log import exception as pydev_log_exception
from _pydev_bundle._pydev_saved_modules import threading
from _pydevd_bundle.pydevd_constants import (get_current_thread_id, NO_FTRACE,
USE_CUSTOM_SYS_CURRENT_FRAMES_MAP, ForkSafeLock)
USE_CUSTOM_SYS_CURRENT_FRAMES_MAP, ForkSafeLock, USE_SYS_MONITORING)
from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER

# IFDEF CYTHON
Expand Down Expand Up @@ -488,3 +488,8 @@ def __call__(self, frame, event, arg):
return _original_call(self, frame, event, arg)

ThreadTracer.__call__ = __call__

if USE_SYS_MONITORING:

def fix_top_level_trace_and_get_trace_func(*args, **kwargs):
raise RuntimeError('Not used in sys.monitoring mode.')
Loading

0 comments on commit 7a9c471

Please sign in to comment.