mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
GH-101520: Move tracemalloc functionality into core, leaving interface in Modules. (#104508)
This commit is contained in:
parent
26931944dd
commit
f7df173949
11 changed files with 1621 additions and 1545 deletions
|
@ -31,7 +31,6 @@ PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc);
|
||||||
|
|
||||||
extern void _Py_InitVersion(void);
|
extern void _Py_InitVersion(void);
|
||||||
extern PyStatus _PyFaulthandler_Init(int enable);
|
extern PyStatus _PyFaulthandler_Init(int enable);
|
||||||
extern int _PyTraceMalloc_Init(int enable);
|
|
||||||
extern PyObject * _PyBuiltin_Init(PyInterpreterState *interp);
|
extern PyObject * _PyBuiltin_Init(PyInterpreterState *interp);
|
||||||
extern PyStatus _PySys_Create(
|
extern PyStatus _PySys_Create(
|
||||||
PyThreadState *tstate,
|
PyThreadState *tstate,
|
||||||
|
|
|
@ -33,6 +33,40 @@ PyAPI_FUNC(int) PyTraceMalloc_Untrack(
|
||||||
PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
|
PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
|
||||||
unsigned int domain,
|
unsigned int domain,
|
||||||
uintptr_t ptr);
|
uintptr_t ptr);
|
||||||
|
|
||||||
|
/* Return non-zero if tracemalloc is tracing */
|
||||||
|
PyAPI_FUNC(int) _PyTraceMalloc_IsTracing(void);
|
||||||
|
|
||||||
|
/* Clear the tracemalloc traces */
|
||||||
|
PyAPI_FUNC(void) _PyTraceMalloc_ClearTraces(void);
|
||||||
|
|
||||||
|
/* Clear the tracemalloc traces */
|
||||||
|
PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetTraces(void);
|
||||||
|
|
||||||
|
/* Clear tracemalloc traceback for an object */
|
||||||
|
PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetObjectTraceback(PyObject *obj);
|
||||||
|
|
||||||
|
/* Initialize tracemalloc */
|
||||||
|
PyAPI_FUNC(int) _PyTraceMalloc_Init(void);
|
||||||
|
|
||||||
|
/* Start tracemalloc */
|
||||||
|
PyAPI_FUNC(int) _PyTraceMalloc_Start(int max_nframe);
|
||||||
|
|
||||||
|
/* Stop tracemalloc */
|
||||||
|
PyAPI_FUNC(void) _PyTraceMalloc_Stop(void);
|
||||||
|
|
||||||
|
/* Get the tracemalloc traceback limit */
|
||||||
|
PyAPI_FUNC(int) _PyTraceMalloc_GetTracebackLimit(void);
|
||||||
|
|
||||||
|
/* Get the memory usage of tracemalloc in bytes */
|
||||||
|
PyAPI_FUNC(size_t) _PyTraceMalloc_GetMemory(void);
|
||||||
|
|
||||||
|
/* Get the current size and peak size of traced memory blocks as a 2-tuple */
|
||||||
|
PyAPI_FUNC(PyObject *) _PyTraceMalloc_GetTracedMemory(void);
|
||||||
|
|
||||||
|
/* Set the peak size of traced memory blocks to the current size */
|
||||||
|
PyAPI_FUNC(void) _PyTraceMalloc_ResetPeak(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !Py_TRACEMALLOC_H */
|
#endif /* !Py_TRACEMALLOC_H */
|
||||||
|
|
|
@ -421,6 +421,7 @@ PYTHON_OBJS= \
|
||||||
Python/sysmodule.o \
|
Python/sysmodule.o \
|
||||||
Python/thread.o \
|
Python/thread.o \
|
||||||
Python/traceback.o \
|
Python/traceback.o \
|
||||||
|
Python/tracemalloc.o \
|
||||||
Python/getopt.o \
|
Python/getopt.o \
|
||||||
Python/pystrcmp.o \
|
Python/pystrcmp.o \
|
||||||
Python/pystrtod.o \
|
Python/pystrtod.o \
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Move the core functionality of the ``tracemalloc`` module in the ``Python/``
|
||||||
|
folder, leaving just the module wrapper in ``Modules/``.
|
File diff suppressed because it is too large
Load diff
|
@ -242,6 +242,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\Python\thread.c" />
|
<ClCompile Include="..\Python\thread.c" />
|
||||||
<ClCompile Include="..\Python\traceback.c" />
|
<ClCompile Include="..\Python\traceback.c" />
|
||||||
|
<ClCompile Include="..\Python\tracemalloc.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- BEGIN frozen modules -->
|
<!-- BEGIN frozen modules -->
|
||||||
|
|
|
@ -394,6 +394,9 @@
|
||||||
<ClCompile Include="..\Python\traceback.c">
|
<ClCompile Include="..\Python\traceback.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Python\tracemalloc.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\Objects\tupleobject.c">
|
<ClCompile Include="..\Objects\tupleobject.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -567,6 +567,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\Python\thread.c" />
|
<ClCompile Include="..\Python\thread.c" />
|
||||||
<ClCompile Include="..\Python\traceback.c" />
|
<ClCompile Include="..\Python\traceback.c" />
|
||||||
|
<ClCompile Include="..\Python\tracemalloc.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- BEGIN deepfreeze -->
|
<!-- BEGIN deepfreeze -->
|
||||||
|
|
|
@ -1268,6 +1268,9 @@
|
||||||
<ClCompile Include="..\Python\traceback.c">
|
<ClCompile Include="..\Python\traceback.c">
|
||||||
<Filter>Python</Filter>
|
<Filter>Python</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Python\tracemalloc.c">
|
||||||
|
<Filter>Python</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\Python\bootstrap_hash.c">
|
<ClCompile Include="..\Python\bootstrap_hash.c">
|
||||||
<Filter>Python</Filter>
|
<Filter>Python</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -1129,11 +1129,12 @@ init_interp_main(PyThreadState *tstate)
|
||||||
return _PyStatus_ERR("can't initialize signals");
|
return _PyStatus_ERR("can't initialize signals");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_PyTraceMalloc_Init(config->tracemalloc) < 0) {
|
if (config->tracemalloc) {
|
||||||
return _PyStatus_ERR("can't initialize tracemalloc");
|
if (_PyTraceMalloc_Start(config->tracemalloc) < 0) {
|
||||||
|
return _PyStatus_ERR("can't start tracemalloc");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PY_HAVE_PERF_TRAMPOLINE
|
#ifdef PY_HAVE_PERF_TRAMPOLINE
|
||||||
if (config->perf_profiling) {
|
if (config->perf_profiling) {
|
||||||
if (_PyPerfTrampoline_SetCallbacks(&_Py_perfmap_callbacks) < 0 ||
|
if (_PyPerfTrampoline_SetCallbacks(&_Py_perfmap_callbacks) < 0 ||
|
||||||
|
|
1560
Python/tracemalloc.c
Normal file
1560
Python/tracemalloc.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue