summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-20 15:46:36 (GMT)
committerGitHub <noreply@github.com>2017-06-20 15:46:36 (GMT)
commit5ea4c0677389ead2eee759958694cff2c65834a7 (patch)
tree90e13f3ef6da418c459de164cb7f21e9ab70a1c9 /Modules
parent26cb4657bcc9a7adffa95798ececb588dddfeadb (diff)
downloadcpython-5ea4c0677389ead2eee759958694cff2c65834a7.zip
cpython-5ea4c0677389ead2eee759958694cff2c65834a7.tar.gz
cpython-5ea4c0677389ead2eee759958694cff2c65834a7.tar.bz2
bpo-30054: Expose tracemalloc C API (#1236)
* Make PyTraceMalloc_Track() and PyTraceMalloc_Untrack() functions public (remove the "_" prefix) * Remove the _PyTraceMalloc_domain_t type: use directly unsigned int. * Document methods Note: methods are already tested in test_tracemalloc.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c10
-rw-r--r--Modules/_tracemalloc.c20
2 files changed, 15 insertions, 15 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 8c44ad2..83ba33d 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -3958,15 +3958,15 @@ tracemalloc_track(PyObject *self, PyObject *args)
if (release_gil) {
Py_BEGIN_ALLOW_THREADS
- res = _PyTraceMalloc_Track(domain, (uintptr_t)ptr, size);
+ res = PyTraceMalloc_Track(domain, (uintptr_t)ptr, size);
Py_END_ALLOW_THREADS
}
else {
- res = _PyTraceMalloc_Track(domain, (uintptr_t)ptr, size);
+ res = PyTraceMalloc_Track(domain, (uintptr_t)ptr, size);
}
if (res < 0) {
- PyErr_SetString(PyExc_RuntimeError, "_PyTraceMalloc_Track error");
+ PyErr_SetString(PyExc_RuntimeError, "PyTraceMalloc_Track error");
return NULL;
}
@@ -3987,9 +3987,9 @@ tracemalloc_untrack(PyObject *self, PyObject *args)
if (PyErr_Occurred())
return NULL;
- res = _PyTraceMalloc_Untrack(domain, (uintptr_t)ptr);
+ res = PyTraceMalloc_Untrack(domain, (uintptr_t)ptr);
if (res < 0) {
- PyErr_SetString(PyExc_RuntimeError, "_PyTraceMalloc_Track error");
+ PyErr_SetString(PyExc_RuntimeError, "PyTraceMalloc_Untrack error");
return NULL;
}
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 950789b..00d3542 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -74,7 +74,7 @@ __attribute__((packed))
#endif
{
uintptr_t ptr;
- _PyTraceMalloc_domain_t domain;
+ unsigned int domain;
} pointer_t;
/* Pack the frame_t structure to reduce the memory footprint on 64-bit
@@ -578,7 +578,7 @@ tracemalloc_use_domain(void)
static void
-tracemalloc_remove_trace(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
+tracemalloc_remove_trace(unsigned int domain, uintptr_t ptr)
{
trace_t trace;
int removed;
@@ -605,7 +605,7 @@ tracemalloc_remove_trace(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
static int
-tracemalloc_add_trace(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
+tracemalloc_add_trace(unsigned int domain, uintptr_t ptr,
size_t size)
{
pointer_t key = {ptr, domain};
@@ -1267,7 +1267,7 @@ traceback_to_pyobject(traceback_t *traceback, _Py_hashtable_t *intern_table)
static PyObject*
-trace_to_pyobject(_PyTraceMalloc_domain_t domain, trace_t *trace,
+trace_to_pyobject(unsigned int domain, trace_t *trace,
_Py_hashtable_t *intern_tracebacks)
{
PyObject *trace_obj = NULL;
@@ -1313,7 +1313,7 @@ tracemalloc_get_traces_fill(_Py_hashtable_t *traces, _Py_hashtable_entry_t *entr
void *user_data)
{
get_traces_t *get_traces = user_data;
- _PyTraceMalloc_domain_t domain;
+ unsigned int domain;
trace_t trace;
PyObject *tracemalloc_obj;
int res;
@@ -1428,7 +1428,7 @@ finally:
static traceback_t*
-tracemalloc_get_traceback(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
+tracemalloc_get_traceback(unsigned int domain, uintptr_t ptr)
{
trace_t trace;
int found;
@@ -1783,8 +1783,8 @@ _PyTraceMalloc_Fini(void)
}
int
-_PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
- size_t size)
+PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr,
+ size_t size)
{
int res;
#ifdef WITH_THREAD
@@ -1812,7 +1812,7 @@ _PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
int
-_PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
+PyTraceMalloc_Untrack(unsigned int domain, uintptr_t ptr)
{
if (!tracemalloc_config.tracing) {
/* tracemalloc is not tracing: do nothing */
@@ -1828,7 +1828,7 @@ _PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
PyObject*
-_PyTraceMalloc_GetTraceback(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
+_PyTraceMalloc_GetTraceback(unsigned int domain, uintptr_t ptr)
{
traceback_t *traceback;