}
#if USE_COMPUTED_GOTOS
- TARGET_DO_TRACING: {
+ TARGET_DO_TRACING:
#else
- case DO_TRACING: {
+ case DO_TRACING:
#endif
+ {
+ if (tstate->tracing == 0) {
int instr_prev = skip_backwards_over_extended_args(frame->f_code, frame->f_lasti);
frame->f_lasti = INSTR_OFFSET();
TRACING_NEXTOPARG();
frame->stacktop = -1;
}
}
- TRACING_NEXTOPARG();
- PRE_DISPATCH_GOTO();
- DISPATCH_GOTO();
}
-
+ TRACING_NEXTOPARG();
+ PRE_DISPATCH_GOTO();
+ DISPATCH_GOTO();
+ }
#if USE_COMPUTED_GOTOS
_unknown_opcode:
}
}
+void
+PyThreadState_EnterTracing(PyThreadState *tstate)
+{
+ tstate->tracing++;
+}
+
+void
+PyThreadState_LeaveTracing(PyThreadState *tstate)
+{
+ tstate->tracing--;
+}
+
static int
call_trace(Py_tracefunc func, PyObject *obj,
PyThreadState *tstate, _PyInterpreterFrame *frame,
int what, PyObject *arg)
{
int result;
- if (tstate->tracing)
+ if (tstate->tracing) {
return 0;
- tstate->tracing++;
- _PyThreadState_PauseTracing(tstate);
+ }
PyFrameObject *f = _PyFrame_GetFrameObject(frame);
if (f == NULL) {
return -1;
}
+ PyThreadState_EnterTracing(tstate);
assert (frame->f_lasti >= 0);
initialize_trace_info(&tstate->trace_info, frame);
f->f_lineno = _PyCode_CheckLineNumber(frame->f_lasti*sizeof(_Py_CODEUNIT), &tstate->trace_info.bounds);
result = func(obj, f, what, arg);
f->f_lineno = 0;
- _PyThreadState_ResumeTracing(tstate);
- tstate->tracing--;
+ PyThreadState_LeaveTracing(tstate);
return result;
}
PyObject *result;
tstate->tracing = 0;
- _PyThreadState_ResumeTracing(tstate);
result = PyObject_Call(func, args, NULL);
tstate->tracing = save_tracing;
tstate->cframe->use_tracing = save_use_tracing;
tstate->c_profilefunc = NULL;
tstate->c_profileobj = NULL;
/* Must make sure that tracing is not ignored if 'profileobj' is freed */
- _PyThreadState_ResumeTracing(tstate);
+ _PyThreadState_UpdateTracingState(tstate);
Py_XDECREF(profileobj);
Py_XINCREF(arg);
tstate->c_profilefunc = func;
/* Flag that tracing or profiling is turned on */
- _PyThreadState_ResumeTracing(tstate);
+ _PyThreadState_UpdateTracingState(tstate);
return 0;
}
tstate->c_tracefunc = NULL;
tstate->c_traceobj = NULL;
/* Must make sure that profiling is not ignored if 'traceobj' is freed */
- _PyThreadState_ResumeTracing(tstate);
+ _PyThreadState_UpdateTracingState(tstate);
Py_XDECREF(traceobj);
Py_XINCREF(arg);
tstate->c_tracefunc = func;
/* Flag that tracing or profiling is turned on */
- _PyThreadState_ResumeTracing(tstate);
+ _PyThreadState_UpdateTracingState(tstate);
return 0;
}