summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-07-19 12:19:27 (GMT)
committerGuido van Rossum <guido@python.org>2001-07-19 12:19:27 (GMT)
commitf5df46d701d29baf738365da6fcf1b8a3ceabb71 (patch)
tree064bca37c5ccc89644057a9347b7803f6db74240
parent130fb175781ca6902ab8f711e2175206ecb74fcc (diff)
downloadcpython-f5df46d701d29baf738365da6fcf1b8a3ceabb71.zip
cpython-f5df46d701d29baf738365da6fcf1b8a3ceabb71.tar.gz
cpython-f5df46d701d29baf738365da6fcf1b8a3ceabb71.tar.bz2
Add a low-level API to access interpreters, for David Beazley.
SF patch #436376.
-rw-r--r--Include/pystate.h7
-rw-r--r--Python/pystate.c25
2 files changed, 32 insertions, 0 deletions
diff --git a/Include/pystate.h b/Include/pystate.h
index 41024e8..712e9dc 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -100,6 +100,13 @@ extern DL_IMPORT(PyThreadState *) _PyThreadState_Current;
#define PyThreadState_GET() (_PyThreadState_Current)
#endif
+/* Routines for advanced debuggers, requested by David Beazley.
+ Don't use unless you know what you are doing! */
+DL_IMPORT(PyInterpreterState *) PyInterpreterState_Head(void);
+DL_IMPORT(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
+DL_IMPORT(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
+DL_IMPORT(PyThreadState *) PyThreadState_Next(PyThreadState *);
+
#ifdef __cplusplus
}
#endif
diff --git a/Python/pystate.c b/Python/pystate.c
index 2f15fdf..9a41ccf 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -264,3 +264,28 @@ PyThreadState_GetDict(void)
_PyThreadState_Current->dict = PyDict_New();
return _PyThreadState_Current->dict;
}
+
+
+/* Routines for advanced debuggers, requested by David Beazley.
+ Don't use unless you know what you are doing! */
+
+PyInterpreterState *
+PyInterpreterState_Head(void)
+{
+ return interp_head;
+}
+
+PyInterpreterState *
+PyInterpreterState_Next(PyInterpreterState *interp) {
+ return interp->next;
+}
+
+PyThreadState *
+PyInterpreterState_ThreadHead(PyInterpreterState *interp) {
+ return interp->tstate_head;
+}
+
+PyThreadState *
+PyThreadState_Next(PyThreadState *tstate) {
+ return tstate->next;
+}