From 547d26aa08aa5e4ec6e4f8a5587b30b39064a5ba Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 15 Oct 2021 16:06:30 +0200 Subject: bpo-43760: Add PyThreadState_EnterTracing() (GH-28542) Add PyThreadState_EnterTracing() and PyThreadState_LeaveTracing() functions to the limited C API to suspend and resume tracing and profiling. Add an unit test on the PyThreadState C API to _testcapi. Add also internal _PyThreadState_DisableTracing() and _PyThreadState_ResetTracing(). --- Python/pystate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index ee9507c7dd..abd711ee2e 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1201,6 +1201,22 @@ PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc) } +void +PyThreadState_EnterTracing(PyThreadState *tstate) +{ + tstate->tracing++; + _PyThreadState_DisableTracing(tstate); +} + +void +PyThreadState_LeaveTracing(PyThreadState *tstate) +{ + tstate->tracing--; + _PyThreadState_ResetTracing(tstate); +} + + + /* Routines for advanced debuggers, requested by David Beazley. Don't use unless you know what you are doing! */ -- cgit v1.2.1