summaryrefslogtreecommitdiffstats
path: root/Include/pystate.h
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-06-27 19:18:03 (GMT)
committerFred Drake <fdrake@acm.org>2001-06-27 19:18:03 (GMT)
commit55fb6e037170ddb645c552079ec8fe6c042de542 (patch)
tree02f1e8fb2e7fef02acc5b2a5f7fa7241dcf0fe9c /Include/pystate.h
parent8f4558583f3b7e2d98e13baec06c2f43c9e6a723 (diff)
downloadcpython-55fb6e037170ddb645c552079ec8fe6c042de542.zip
cpython-55fb6e037170ddb645c552079ec8fe6c042de542.tar.gz
cpython-55fb6e037170ddb645c552079ec8fe6c042de542.tar.bz2
Revise the interface to the profiling and tracing support for the
Python interpreter. This change adds two new C-level APIs: PyEval_SetProfile() and PyEval_SetTrace(). These can be used to install profile and trace functions implemented in C, which can operate at much higher speeds than Python-based functions. The overhead for calling a C-based profile function is a very small fraction of a percent of the overhead involved in calling a Python-based function. The machinery required to call a Python-based profile or trace function been moved to sysmodule.c, where sys.setprofile() and sys.setprofile() simply become users of the new interface.
Diffstat (limited to 'Include/pystate.h')
-rw-r--r--Include/pystate.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/Include/pystate.h b/Include/pystate.h
index 27ffe32..d5e2e1f 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -31,6 +31,15 @@ typedef struct _is {
struct _frame; /* Avoid including frameobject.h */
+/* Py_tracefunc return -1 when raising an exception, or 0 for success. */
+typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
+
+/* The following values are used for 'what' for tracefunc functions: */
+#define PyTrace_CALL 0
+#define PyTrace_EXCEPTION 1
+#define PyTrace_LINE 2
+#define PyTrace_RETURN 3
+
typedef struct _ts {
struct _ts *next;
@@ -41,8 +50,10 @@ typedef struct _ts {
int ticker;
int tracing;
- PyObject *sys_profilefunc;
- PyObject *sys_tracefunc;
+ Py_tracefunc c_profilefunc;
+ Py_tracefunc c_tracefunc;
+ PyObject *c_profileobj;
+ PyObject *c_traceobj;
PyObject *curexc_type;
PyObject *curexc_value;