mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Set frame evaluation function instead of tracing function if it's available
This commit is contained in:
@@ -58,7 +58,7 @@ def _on_forked_process():
|
||||
|
||||
def _on_set_trace_for_new_thread(global_debugger):
|
||||
if global_debugger is not None:
|
||||
global_debugger.SetTrace(global_debugger.trace_dispatch)
|
||||
global_debugger.SetTrace(global_debugger.trace_dispatch, global_debugger.frame_eval_func)
|
||||
|
||||
#===============================================================================
|
||||
# Things related to monkey-patching
|
||||
|
||||
@@ -5,7 +5,7 @@ def set_trace_in_qt():
|
||||
from _pydevd_bundle.pydevd_comm import get_global_debugger
|
||||
debugger = get_global_debugger()
|
||||
if debugger is not None:
|
||||
pydevd_tracing.SetTrace(debugger.trace_dispatch)
|
||||
pydevd_tracing.SetTrace(debugger.trace_dispatch, debugger.frame_eval_func)
|
||||
|
||||
|
||||
_patched_qt = False
|
||||
|
||||
@@ -66,7 +66,13 @@ def _internal_set_trace(tracing_func):
|
||||
if TracingFunctionHolder._original_tracing:
|
||||
TracingFunctionHolder._original_tracing(tracing_func)
|
||||
|
||||
def SetTrace(tracing_func):
|
||||
|
||||
def SetTrace(tracing_func, frame_eval_func=None):
|
||||
if tracing_func is not None and frame_eval_func is not None:
|
||||
# There is no need to set tracing function if frame evaluation is available
|
||||
frame_eval_func()
|
||||
return
|
||||
|
||||
if TracingFunctionHolder._original_tracing is None:
|
||||
#This may happen before replace_sys_set_trace_func is called.
|
||||
sys.settrace(tracing_func)
|
||||
|
||||
@@ -11,7 +11,7 @@ stop_frame_eval = None
|
||||
|
||||
if IS_PY36_OR_OLDER:
|
||||
try:
|
||||
from _pydevd_frame_eval.pydevd_frame_evaluator import set_frame_eval, stop_frame_eval
|
||||
from _pydevd_frame_eval.pydevd_frame_evaluator import frame_eval_func, stop_frame_eval
|
||||
except ImportError:
|
||||
from _pydev_bundle.pydev_monkey import log_error_once
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ cdef PyObject*get_bytecode_while_frame_eval(PyFrameObject *frame, int exc):
|
||||
update_globals_dict(<object> frame.f_globals)
|
||||
return _PyEval_EvalFrameDefault(frame, exc)
|
||||
|
||||
def set_frame_eval():
|
||||
def frame_eval_func():
|
||||
cdef PyThreadState *state = PyThreadState_Get()
|
||||
state.interp.eval_frame = get_bytecode_while_frame_eval
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ from _pydevd_bundle.pydevd_custom_frames import CustomFramesContainer, custom_fr
|
||||
from _pydevd_bundle.pydevd_frame_utils import add_exception_to_frame
|
||||
from _pydevd_bundle.pydevd_kill_all_pydevd_threads import kill_all_pydev_threads
|
||||
from _pydevd_bundle.pydevd_trace_dispatch import trace_dispatch as _trace_dispatch
|
||||
from _pydevd_frame_eval.pydevd_frame_eval_main import set_frame_eval, stop_frame_eval
|
||||
from _pydevd_frame_eval.pydevd_frame_eval_main import frame_eval_func, stop_frame_eval
|
||||
from _pydevd_bundle.pydevd_utils import save_main_module
|
||||
from pydevd_concurrency_analyser.pydevd_concurrency_logger import ThreadingLogger, AsyncioLogger, send_message, cur_time
|
||||
from pydevd_concurrency_analyser.pydevd_thread_wrappers import wrap_threads
|
||||
@@ -868,13 +868,10 @@ class PyDB:
|
||||
|
||||
def prepare_to_run(self):
|
||||
''' Shared code to prepare debugging by installing traces and registering threads '''
|
||||
if set_frame_eval is None:
|
||||
self.patch_threads()
|
||||
pydevd_tracing.SetTrace(self.trace_dispatch)
|
||||
else:
|
||||
# There is no need to set tracing function if frame evaluation is available. Moreover, there is no need to patch thread
|
||||
# functions, because frame evaluation function is set to all threads by default.
|
||||
set_frame_eval()
|
||||
self.patch_threads()
|
||||
pydevd_tracing.SetTrace(self.trace_dispatch, self.frame_eval_func)
|
||||
# There is no need to set tracing function if frame evaluation is available. Moreover, there is no need to patch thread
|
||||
# functions, because frame evaluation function is set to all threads by default.
|
||||
|
||||
PyDBCommandThread(self).start()
|
||||
if self.signature_factory is not None or self.thread_analyser is not None:
|
||||
@@ -883,6 +880,9 @@ class PyDB:
|
||||
|
||||
|
||||
def patch_threads(self):
|
||||
if self.frame_eval_func is not None:
|
||||
# There is no need to patch thread functions, because frame evaluation function is set to all threads by default.
|
||||
return
|
||||
try:
|
||||
# not available in jython!
|
||||
import threading
|
||||
@@ -1008,6 +1008,7 @@ class PyDB:
|
||||
time.sleep(0.01)
|
||||
|
||||
trace_dispatch = _trace_dispatch
|
||||
frame_eval_func = frame_eval_func
|
||||
|
||||
def set_debug(setup):
|
||||
setup['DEBUG_RECORD_SOCKET_READS'] = True
|
||||
@@ -1245,7 +1246,7 @@ def _locked_settrace(
|
||||
|
||||
# note that we do that through pydevd_tracing.SetTrace so that the tracing
|
||||
# is not warned to the user!
|
||||
pydevd_tracing.SetTrace(debugger.trace_dispatch)
|
||||
pydevd_tracing.SetTrace(debugger.trace_dispatch, debugger.frame_eval_func)
|
||||
|
||||
if not trace_only_current_thread:
|
||||
# Trace future threads?
|
||||
@@ -1278,7 +1279,7 @@ def _locked_settrace(
|
||||
additional_info = PyDBAdditionalThreadInfo()
|
||||
t.additional_info = additional_info
|
||||
|
||||
pydevd_tracing.SetTrace(debugger.trace_dispatch)
|
||||
pydevd_tracing.SetTrace(debugger.trace_dispatch, debugger.frame_eval_func)
|
||||
|
||||
if not trace_only_current_thread:
|
||||
# Trace future threads?
|
||||
|
||||
Reference in New Issue
Block a user