mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Add comments about PyThreadState and the usage of its fields.
This commit is contained in:
parent
527c46996f
commit
55fa66dd45
2 changed files with 9 additions and 1 deletions
|
@ -53,12 +53,16 @@ typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
|
||||||
#define PyTrace_C_RETURN 6
|
#define PyTrace_C_RETURN 6
|
||||||
|
|
||||||
typedef struct _ts {
|
typedef struct _ts {
|
||||||
|
/* See Python/ceval.c for comments explaining most fields */
|
||||||
|
|
||||||
struct _ts *next;
|
struct _ts *next;
|
||||||
PyInterpreterState *interp;
|
PyInterpreterState *interp;
|
||||||
|
|
||||||
struct _frame *frame;
|
struct _frame *frame;
|
||||||
int recursion_depth;
|
int recursion_depth;
|
||||||
|
/* 'tracing' keeps track of the execution depth when tracing/profiling.
|
||||||
|
This is to prevent the actual trace/profile code from being recorded in
|
||||||
|
the trace/profile. */
|
||||||
int tracing;
|
int tracing;
|
||||||
int use_tracing;
|
int use_tracing;
|
||||||
|
|
||||||
|
@ -75,7 +79,7 @@ typedef struct _ts {
|
||||||
PyObject *exc_value;
|
PyObject *exc_value;
|
||||||
PyObject *exc_traceback;
|
PyObject *exc_traceback;
|
||||||
|
|
||||||
PyObject *dict;
|
PyObject *dict; /* Stores per-thread state */
|
||||||
|
|
||||||
/* tick_counter is incremented whenever the check_interval ticker
|
/* tick_counter is incremented whenever the check_interval ticker
|
||||||
* reaches zero. The purpose is to give a useful measure of the number
|
* reaches zero. The purpose is to give a useful measure of the number
|
||||||
|
|
|
@ -3284,10 +3284,12 @@ PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
|
||||||
Py_XINCREF(arg);
|
Py_XINCREF(arg);
|
||||||
tstate->c_profilefunc = NULL;
|
tstate->c_profilefunc = NULL;
|
||||||
tstate->c_profileobj = NULL;
|
tstate->c_profileobj = NULL;
|
||||||
|
/* Must make sure that tracing is not ignored if 'temp' is freed */
|
||||||
tstate->use_tracing = tstate->c_tracefunc != NULL;
|
tstate->use_tracing = tstate->c_tracefunc != NULL;
|
||||||
Py_XDECREF(temp);
|
Py_XDECREF(temp);
|
||||||
tstate->c_profilefunc = func;
|
tstate->c_profilefunc = func;
|
||||||
tstate->c_profileobj = arg;
|
tstate->c_profileobj = arg;
|
||||||
|
/* Flag that tracing or profiling is turned on */
|
||||||
tstate->use_tracing = (func != NULL) || (tstate->c_tracefunc != NULL);
|
tstate->use_tracing = (func != NULL) || (tstate->c_tracefunc != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3299,10 +3301,12 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
|
||||||
Py_XINCREF(arg);
|
Py_XINCREF(arg);
|
||||||
tstate->c_tracefunc = NULL;
|
tstate->c_tracefunc = NULL;
|
||||||
tstate->c_traceobj = NULL;
|
tstate->c_traceobj = NULL;
|
||||||
|
/* Must make sure that profiling is not ignored if 'temp' is freed */
|
||||||
tstate->use_tracing = tstate->c_profilefunc != NULL;
|
tstate->use_tracing = tstate->c_profilefunc != NULL;
|
||||||
Py_XDECREF(temp);
|
Py_XDECREF(temp);
|
||||||
tstate->c_tracefunc = func;
|
tstate->c_tracefunc = func;
|
||||||
tstate->c_traceobj = arg;
|
tstate->c_traceobj = arg;
|
||||||
|
/* Flag that tracing or profiling is turned on */
|
||||||
tstate->use_tracing = ((func != NULL)
|
tstate->use_tracing = ((func != NULL)
|
||||||
|| (tstate->c_profilefunc != NULL));
|
|| (tstate->c_profilefunc != NULL));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue