mirror of
https://github.com/python/cpython.git
synced 2025-10-28 09:10:36 +00:00
gh-93502: Add new C-API functions to trace object creation and destruction (#115945)
This commit is contained in:
parent
2770d5caca
commit
6bcbee09df
10 changed files with 207 additions and 8 deletions
|
|
@ -257,7 +257,7 @@ extern int _PyDict_CheckConsistency(PyObject *mp, int check_content);
|
|||
when a memory block is reused from a free list.
|
||||
|
||||
Internal function called by _Py_NewReference(). */
|
||||
extern int _PyTraceMalloc_NewReference(PyObject *op);
|
||||
extern int _PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, void*);
|
||||
|
||||
// Fast inlined version of PyType_HasFeature()
|
||||
static inline int
|
||||
|
|
|
|||
|
|
@ -132,6 +132,12 @@ typedef struct _Py_DebugOffsets {
|
|||
} unicode_object;
|
||||
} _Py_DebugOffsets;
|
||||
|
||||
/* Reference tracer state */
|
||||
struct _reftracer_runtime_state {
|
||||
PyRefTracer tracer_func;
|
||||
void* tracer_data;
|
||||
};
|
||||
|
||||
/* Full Python runtime state */
|
||||
|
||||
/* _PyRuntimeState holds the global state for the CPython runtime.
|
||||
|
|
@ -236,6 +242,7 @@ typedef struct pyruntimestate {
|
|||
struct _fileutils_state fileutils;
|
||||
struct _faulthandler_runtime_state faulthandler;
|
||||
struct _tracemalloc_runtime_state tracemalloc;
|
||||
struct _reftracer_runtime_state ref_tracer;
|
||||
|
||||
// The rwmutex is used to prevent overlapping global and per-interpreter
|
||||
// stop-the-world events. Global stop-the-world events lock the mutex
|
||||
|
|
|
|||
|
|
@ -128,6 +128,10 @@ extern PyTypeObject _PyExc_MemoryError;
|
|||
}, \
|
||||
.faulthandler = _faulthandler_runtime_state_INIT, \
|
||||
.tracemalloc = _tracemalloc_runtime_state_INIT, \
|
||||
.ref_tracer = { \
|
||||
.tracer_func = NULL, \
|
||||
.tracer_data = NULL, \
|
||||
}, \
|
||||
.stoptheworld = { \
|
||||
.is_global = 1, \
|
||||
}, \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue