summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-10-15 14:06:30 (GMT)
committerGitHub <noreply@github.com>2021-10-15 14:06:30 (GMT)
commit547d26aa08aa5e4ec6e4f8a5587b30b39064a5ba (patch)
treef89a1327f1847ca97929efec97a12cab09478b2a /Python/pystate.c
parent354c35220d25a893e502014478f6739dad6897f3 (diff)
downloadcpython-547d26aa08aa5e4ec6e4f8a5587b30b39064a5ba.zip
cpython-547d26aa08aa5e4ec6e4f8a5587b30b39064a5ba.tar.gz
cpython-547d26aa08aa5e4ec6e4f8a5587b30b39064a5ba.tar.bz2
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().
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index ee9507c..abd711e 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! */