gh-103615: Use local events for opcode tracing (GH-109472)

* Use local monitoring for opcode trace

* Remove f_opcode_trace_set

* Add test for setting f_trace_opcodes after settrace
This commit is contained in:
Tian Gao 2023-11-03 09:39:50 -07:00 committed by GitHub
parent 2bc01cc0c7
commit e0afed7e27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 114 additions and 8 deletions

View file

@ -127,10 +127,13 @@ frame_settrace_opcodes(PyFrameObject *f, PyObject* value, void *Py_UNUSED(ignore
}
if (value == Py_True) {
f->f_trace_opcodes = 1;
_PyInterpreterState_GET()->f_opcode_trace_set = true;
if (f->f_trace) {
return _PyEval_SetOpcodeTrace(f, true);
}
}
else {
f->f_trace_opcodes = 0;
return _PyEval_SetOpcodeTrace(f, false);
}
return 0;
}
@ -842,6 +845,9 @@ frame_settrace(PyFrameObject *f, PyObject* v, void *closure)
}
if (v != f->f_trace) {
Py_XSETREF(f->f_trace, Py_XNewRef(v));
if (v != NULL && f->f_trace_opcodes) {
return _PyEval_SetOpcodeTrace(f, true);
}
}
return 0;
}