Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Nov 12, 2023
1 parent c07c92b commit 91a7c20
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
from _pydev_bundle._pydev_saved_modules import threading
from _pydevd_bundle.pydevd_constants import get_global_debugger, IS_WINDOWS, IS_JYTHON, get_current_thread_id, \
sorted_dict_repr, set_global_debugger, DebugInfoHolder
sorted_dict_repr, set_global_debugger, DebugInfoHolder, USE_SYS_MONITORING
from _pydev_bundle import pydev_log
from contextlib import contextmanager
from _pydevd_bundle import pydevd_constants, pydevd_defaults
Expand Down Expand Up @@ -234,7 +234,8 @@ def _on_forked_process(setup_tracing=True):

def _on_set_trace_for_new_thread(global_debugger):
if global_debugger is not None:
global_debugger.enable_tracing()
if not USE_SYS_MONITORING:
global_debugger.enable_tracing()


def _get_str_type_compatible(s, args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
_filename_to_ignored_lines = {}


def default_should_trace_hook(frame, absolute_filename):
def default_should_trace_hook(code, absolute_filename):
'''
Return True if this frame should be traced, False if tracing should be blocked.
'''
Expand Down Expand Up @@ -72,7 +72,7 @@ def default_should_trace_hook(frame, absolute_filename):

_filename_to_ignored_lines[absolute_filename] = ignored_lines

func_line = frame.f_code.co_firstlineno - 1 # co_firstlineno is 1-based, so -1 is needed
func_line = code.co_firstlineno - 1 # co_firstlineno is 1-based, so -1 is needed
return not (
func_line - 1 in ignored_lines or # -1 to get line before method
func_line in ignored_lines) # method line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
'pydevd_vars.py': PYDEV_FILE,
'pydevd_vm_type.py': PYDEV_FILE,
'pydevd_xml.py': PYDEV_FILE,
'pydevd_sys_monitoring.py': PYDEV_FILE,
}

# if we try to trace io.py it seems it can get halted (see http://bugs.python.org/issue4716)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ def trace_dispatch(self, frame, event, arg):
# I.e.: cache the result on self.should_skip (no need to evaluate the same frame multiple times).
# Note that on a code reload, we won't re-evaluate this because in practice, the frame.f_code
# Which will be handled by this frame is read-only, so, we can cache it safely.
if not pydevd_dont_trace.should_trace_hook(frame, abs_path_canonical_path_and_base[0]):
if not pydevd_dont_trace.should_trace_hook(frame.f_code, abs_path_canonical_path_and_base[0]):
# -1, 0, 1 to be Cython-friendly
should_skip = self.should_skip = 1
else:
Expand Down Expand Up @@ -1212,7 +1212,7 @@ def trace_dispatch(self, frame, event, arg):
return None if is_call else NO_FTRACE

elif pydevd_dont_trace.should_trace_hook is not None:
if not pydevd_dont_trace.should_trace_hook(back, back_absolute_filename):
if not pydevd_dont_trace.should_trace_hook(back.f_code, back_absolute_filename):
# In this case, we'll have to skip the previous one because it shouldn't be traced.
# Also, we have to reset the tracing, because if the parent's parent (or some
# other parent) has to be traced and it's not currently, we wouldn't stop where
Expand Down
Loading

0 comments on commit 91a7c20

Please sign in to comment.