static inline void
_PyThreadState_UpdateTracingState(PyThreadState *tstate)
{
- int use_tracing = (tstate->c_tracefunc != NULL
- || tstate->c_profilefunc != NULL);
+ bool use_tracing =
+ (tstate->tracing == 0) &&
+ (tstate->c_tracefunc != NULL || tstate->c_profilefunc != NULL);
tstate->cframe->use_tracing = (use_tracing ? 255 : 0);
}
assert(oparg);
oparg <<= 8;
oparg |= _Py_OPARG(*next_instr);
- // We might be tracing. To avoid breaking tracing guarantees in
+ // We might be tracing. To avoid breaking tracing guarantees in
// quickened instructions, always deoptimize the next opcode:
opcode = _PyOpcode_Deopt[_Py_OPCODE(*next_instr)];
PRE_DISPATCH_GOTO();
case DO_TRACING:
#endif
{
- if (tstate->tracing == 0 &&
- INSTR_OFFSET() >= frame->f_code->_co_firsttraceable
- ) {
+ assert(cframe.use_tracing);
+ assert(tstate->tracing == 0);
+ if (INSTR_OFFSET() >= frame->f_code->_co_firsttraceable) {
int instr_prev = _PyInterpreterFrame_LASTI(frame);
frame->prev_instr = next_instr;
TRACING_NEXTOPARG();
PyThreadState_EnterTracing(PyThreadState *tstate)
{
tstate->tracing++;
+ tstate->cframe->use_tracing = 0;
}
void
PyThreadState_LeaveTracing(PyThreadState *tstate)
{
+ assert(tstate->tracing > 0 && tstate->cframe->use_tracing == 0);
tstate->tracing--;
+ _PyThreadState_UpdateTracingState(tstate);
}
static int