summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-08-25 12:33:38 +1000
committerAndrew Tridgell <tridge@samba.org>2010-08-25 23:05:05 +1000
commit5a367f641ef44a4b58eaea751146a139c70f4afd (patch)
tree315ea03deac0fbcb37b5a63fb5f30e445211e2e1
parentcb0f8f0ee087475e63bcc969cf501ce9eae9c98f (diff)
downloadsamba-5a367f641ef44a4b58eaea751146a139c70f4afd.tar.gz
samba-5a367f641ef44a4b58eaea751146a139c70f4afd.tar.bz2
samba-5a367f641ef44a4b58eaea751146a139c70f4afd.zip
s4-pyglue: added talloc_report_full() and talloc_enable_null_tracking()
these are useful for tracking down leaks and bugs in python scripts Pair-Programmed-With: Jelmer Vernooij <jelmer@samba.org>
-rw-r--r--source4/scripting/python/pyglue.c30
-rw-r--r--source4/scripting/python/samba/__init__.py2
2 files changed, 32 insertions, 0 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index 5de024c430..ddd44aa7df 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -25,6 +25,7 @@
#include "param/pyparam.h"
#include "lib/socket/netif.h"
#include "lib/socket/netif_proto.h"
+#include "lib/talloc/pytalloc.h"
static PyObject *py_generate_random_str(PyObject *self, PyObject *args)
{
@@ -164,6 +165,31 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args)
return pylist;
}
+/* return a talloc tree string for a talloc python object */
+static PyObject *py_talloc_report_full(PyObject *self, PyObject *args)
+{
+ PyObject *py_obj;
+ PyTypeObject *type;
+
+ if (!PyArg_ParseTuple(args, "O", &py_obj))
+ return NULL;
+
+ if (py_obj == Py_None) {
+ talloc_report_full(NULL, stdout);
+ } else {
+ type = (PyTypeObject*)PyObject_Type(py_obj);
+ talloc_report_full(py_talloc_get_mem_ctx(py_obj), stdout);
+ }
+ return Py_None;
+}
+
+/* return a talloc tree string for a talloc python object */
+static PyObject *py_talloc_enable_null_tracking(PyObject *self, PyObject *args)
+{
+ talloc_enable_null_tracking();
+ return Py_None;
+}
+
static PyMethodDef py_misc_methods[] = {
{ "generate_random_str", (PyCFunction)py_generate_random_str, METH_VARARGS,
@@ -182,6 +208,10 @@ static PyMethodDef py_misc_methods[] = {
"set debug level" },
{ "interface_ips", (PyCFunction)py_interface_ips, METH_VARARGS,
"get interface IP address list"},
+ { "talloc_report_full", (PyCFunction)py_talloc_report_full, METH_VARARGS,
+ "show a talloc tree for an object"},
+ { "talloc_enable_null_tracking", (PyCFunction)py_talloc_enable_null_tracking, METH_VARARGS,
+ "enable tracking of the NULL object"},
{ NULL }
};
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 80873dc779..fcd224202b 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -327,3 +327,5 @@ interface_ips = _glue.interface_ips
set_debug_level = _glue.set_debug_level
unix2nttime = _glue.unix2nttime
generate_random_password = _glue.generate_random_password
+talloc_report_full = _glue.talloc_report_full
+talloc_enable_null_tracking = _glue.talloc_enable_null_tracking