]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix tracing completely
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Sat, 18 Oct 2025 19:59:07 +0000 (20:59 +0100)
committerKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Sat, 18 Oct 2025 19:59:07 +0000 (20:59 +0100)
Python/ceval_macros.h

index 52dd8f7c3acae010b1172bc5b9faa7ce07733df8..f68e84e973896e2505ef2e0a586f35bf2e96ceff 100644 (file)
 #  define BAIL_TRACING_NO_DISPATCH() \
     do { \
         LEAVE_TRACING(); \
-        if (!_PyErr_Occurred(tstate)) { \
+        if (!_PyErr_Occurred(tstate) && !_is_sys_tracing) { \
             _PyFrame_SetStackPointer(frame, stack_pointer); \
             int _err = _PyOptimizer_Optimize(frame, tstate); \
             _PyJIT_FinalizeTracing(tstate); \
         } \
     } while (0);
 #  define RECORD_TRACE_NO_DISPATCH() do { \
-        if (IS_JIT_TRACING() && add_to_code_trace(tstate, frame, old_code, old_func, this_instr, next_instr, opcode, oparg, _jump_taken)) { \
+        int _is_sys_tracing = (tstate->c_tracefunc != NULL) || (tstate->c_profilefunc == NULL); \
+        if (_is_sys_tracing || IS_JIT_TRACING()  && add_to_code_trace(tstate, frame, old_code, old_func, this_instr, next_instr, opcode, oparg, _jump_taken)) { \
             BAIL_TRACING_NO_DISPATCH(); \
         } \
     } while (0);
@@ -227,9 +228,6 @@ do { \
 
 #define TRACING_DISPATCH() \
     { \
-        if (tstate->c_tracefunc || tstate->c_profilefunc) { \
-            DISPATCH(); \
-        } \
         assert(frame->stackpointer == NULL); \
         RECORD_TRACE_NO_DISPATCH(); \
         NEXTOPARG(); \