From b791ae72094d4e9c4c59fea0e82649eecd343143 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sat, 20 Jan 2024 13:25:18 -0300 Subject: [PATCH] wip --- .../pydevd_sys_monitoring.py | 82 ++++++++++--------- pydevd.py | 16 ++-- tests_python/test_debugger.py | 5 -- 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/_pydevd_sys_monitoring/pydevd_sys_monitoring.py b/_pydevd_sys_monitoring/pydevd_sys_monitoring.py index 906a2fc3..f9aedbed 100644 --- a/_pydevd_sys_monitoring/pydevd_sys_monitoring.py +++ b/_pydevd_sys_monitoring/pydevd_sys_monitoring.py @@ -500,7 +500,8 @@ def _get_func_code_info(code_obj, frame_or_depth) -> FuncCodeInfo: def _enable_line_tracing(code): # print('enable line tracing', code) events = monitor.get_local_events(DEBUGGER_ID, code) - monitor.set_local_events(DEBUGGER_ID, code, events | monitor.events.LINE | monitor.events.JUMP) + # monitor.set_local_events(DEBUGGER_ID, code, events | monitor.events.LINE | monitor.events.JUMP) + monitor.set_local_events(DEBUGGER_ID, code, events | monitor.events.LINE) def _enable_return_tracing(code): @@ -999,44 +1000,45 @@ def _plugin_stepping(py_db, step_cmd, event, frame, thread_info): def _jump_event(code, from_offset, to_offset): - - # A bunch of things have to be repeated especially because in the sys.monitoring - # everything is global, yet, when we start tracing something for stepping that - # needs to be per-thread. - try: - thread_info = _thread_local_info.thread_info - except: - thread_info = _get_thread_info(True, 1) - if thread_info is None: - return - - py_db: object = GlobalDebuggerHolder.global_dbg - if py_db is None or py_db.pydb_disposed: - return monitor.DISABLE - - if not thread_info.trace or thread_info.thread._is_stopped: - # For thread-related stuff we can't disable the code tracing because other - # threads may still want it... - return - - func_code_info: FuncCodeInfo = _get_func_code_info(code, 1) - if func_code_info.always_skip_code or func_code_info.always_filtered_out: - return monitor.DISABLE - - # Same logic as "sys_trace_jump_func" in https://github.com/python/cpython/blob/main/Python/legacy_tracing.c - # if to_offset > from_offset: + return monitor.DISABLE + + # # A bunch of things have to be repeated especially because in the sys.monitoring + # # everything is global, yet, when we start tracing something for stepping that + # # needs to be per-thread. + # try: + # thread_info = _thread_local_info.thread_info + # except: + # thread_info = _get_thread_info(True, 1) + # if thread_info is None: + # return + # + # py_db: object = GlobalDebuggerHolder.global_dbg + # if py_db is None or py_db.pydb_disposed: # return monitor.DISABLE # - from_line = func_code_info.get_line_of_offset(from_offset) - to_line = func_code_info.get_line_of_offset(to_offset) - # print('jump event', code.co_name, 'from line', from_line, 'to line', to_line) - - if from_line != to_line: - return monitor.DISABLE - - # We know the frame depth. - frame = _getframe(1) - return _internal_line_event(func_code_info, frame, frame.f_lineno) + # if not thread_info.trace or thread_info.thread._is_stopped: + # # For thread-related stuff we can't disable the code tracing because other + # # threads may still want it... + # return + # + # func_code_info: FuncCodeInfo = _get_func_code_info(code, 1) + # if func_code_info.always_skip_code or func_code_info.always_filtered_out: + # return monitor.DISABLE + # + # # Same logic as "sys_trace_jump_func" in https://github.com/python/cpython/blob/main/Python/legacy_tracing.c + # # if to_offset > from_offset: + # # return monitor.DISABLE + # # + # from_line = func_code_info.get_line_of_offset(from_offset) + # to_line = func_code_info.get_line_of_offset(to_offset) + # # print('jump event', code.co_name, 'from line', from_line, 'to line', to_line) + # + # if from_line != to_line: + # return monitor.DISABLE + # + # # We know the frame depth. + # frame = _getframe(1) + # return _internal_line_event(func_code_info, frame, frame.f_lineno) def _line_event(code, line): @@ -1368,7 +1370,7 @@ def stop_monitoring(all_threads=False): monitor.register_callback(DEBUGGER_ID, monitor.events.PY_START, None) monitor.register_callback(DEBUGGER_ID, monitor.events.PY_RESUME, None) monitor.register_callback(DEBUGGER_ID, monitor.events.LINE, None) - monitor.register_callback(DEBUGGER_ID, monitor.events.JUMP, None) + # monitor.register_callback(DEBUGGER_ID, monitor.events.JUMP, None) monitor.register_callback(DEBUGGER_ID, monitor.events.PY_RETURN, None) monitor.register_callback(DEBUGGER_ID, monitor.events.RAISE, None) monitor.free_tool_id(monitor.DEBUGGER_ID) @@ -1456,14 +1458,14 @@ def update_monitor_events(suspend_requested: Optional[bool]=None) -> None: monitor.register_callback(DEBUGGER_ID, monitor.events.PY_START, _start_method_event) # monitor.register_callback(DEBUGGER_ID, monitor.events.PY_RESUME, _resume_method_event) monitor.register_callback(DEBUGGER_ID, monitor.events.LINE, _line_event) - monitor.register_callback(DEBUGGER_ID, monitor.events.JUMP, _jump_event) + # monitor.register_callback(DEBUGGER_ID, monitor.events.JUMP, _jump_event) monitor.register_callback(DEBUGGER_ID, monitor.events.PY_RETURN, _return_event) else: monitor.register_callback(DEBUGGER_ID, monitor.events.PY_START, None) monitor.register_callback(DEBUGGER_ID, monitor.events.PY_RESUME, None) monitor.register_callback(DEBUGGER_ID, monitor.events.LINE, None) - monitor.register_callback(DEBUGGER_ID, monitor.events.JUMP, None) + # monitor.register_callback(DEBUGGER_ID, monitor.events.JUMP, None) monitor.register_callback(DEBUGGER_ID, monitor.events.PY_RETURN, None) monitor.set_events(DEBUGGER_ID, required_events) diff --git a/pydevd.py b/pydevd.py index f56c1d62..7bdf1302 100644 --- a/pydevd.py +++ b/pydevd.py @@ -2053,14 +2053,14 @@ def do_wait_suspend(self, thread, frame, event, arg, exception_type=None): # @U thread_id = get_current_thread_id(thread) - if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 2: - pydev_log.debug('do_wait_suspend %s %s %s %s %s %s (%s)' % (frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename, event, arg, constant_to_str(thread.additional_info.pydev_step_cmd), constant_to_str(thread.additional_info.pydev_original_step_cmd))) - pydev_log.debug('--- internal stack ---') - _f = sys._getframe() - while _f is not None: - pydev_log.debug(' -> %s' % (_f)) - _f = _f.f_back - pydev_log.debug('--- end internal stack ---') + # if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 2: + # pydev_log.debug('do_wait_suspend %s %s %s %s %s %s (%s)' % (frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename, event, arg, constant_to_str(thread.additional_info.pydev_step_cmd), constant_to_str(thread.additional_info.pydev_original_step_cmd))) + # pydev_log.debug('--- internal stack ---') + # _f = sys._getframe() + # while _f is not None: + # pydev_log.debug(' -> %s' % (_f)) + # _f = _f.f_back + # pydev_log.debug('--- end internal stack ---') # Send the suspend message message = thread.additional_info.pydev_message diff --git a/tests_python/test_debugger.py b/tests_python/test_debugger.py index 420f62f9..e78d3cf4 100644 --- a/tests_python/test_debugger.py +++ b/tests_python/test_debugger.py @@ -4489,11 +4489,6 @@ def test_frame_eval_mode_corner_case_04(case_setup): hit = writer.wait_for_breakpoint_hit(line=line) writer.write_run_thread(hit.thread_id) - if TODO_PY312: - for i in range(2): - hit = writer.wait_for_breakpoint_hit(line=line) - writer.write_run_thread(hit.thread_id) - writer.finished_ok = True