summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-12-13 11:00:00 (GMT)
committerGitHub <noreply@github.com>2024-12-13 11:00:00 (GMT)
commite62e1ca4553dbcf9d7f89be24bebcbd9213f9ae5 (patch)
tree96bdcc3ab96408b5970ab657ded4387430c83f58 /Python/sysmodule.c
parent5fc6bb2754a25157575efc0b37da78c629fea46e (diff)
downloadcpython-e62e1ca4553dbcf9d7f89be24bebcbd9213f9ae5.zip
cpython-e62e1ca4553dbcf9d7f89be24bebcbd9213f9ae5.tar.gz
cpython-e62e1ca4553dbcf9d7f89be24bebcbd9213f9ae5.tar.bz2
GH-126833: Dumps graphviz representation of executor graph. (GH-126880)
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 6df297f..d6719f9 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2344,6 +2344,30 @@ sys_is_stack_trampoline_active_impl(PyObject *module)
Py_RETURN_FALSE;
}
+/*[clinic input]
+sys._dump_tracelets
+
+ outpath: object
+
+Dump the graph of tracelets in graphviz format
+[clinic start generated code]*/
+
+static PyObject *
+sys__dump_tracelets_impl(PyObject *module, PyObject *outpath)
+/*[clinic end generated code: output=a7fe265e2bc3b674 input=5bff6880cd28ffd1]*/
+{
+ FILE *out = _Py_fopen_obj(outpath, "wb");
+ if (out == NULL) {
+ return NULL;
+ }
+ int err = _PyDumpExecutors(out);
+ fclose(out);
+ if (err) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
/*[clinic input]
sys._getframemodulename
@@ -2603,6 +2627,7 @@ static PyMethodDef sys_methods[] = {
#endif
SYS__GET_CPU_COUNT_CONFIG_METHODDEF
SYS__IS_GIL_ENABLED_METHODDEF
+ SYS__DUMP_TRACELETS_METHODDEF
{NULL, NULL} // sentinel
};