diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-11-23 16:31:19 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-11-23 16:31:19 +0000 |
| commit | 7d7ca8ee2eaae704989a1552ad429794d402f550 (patch) | |
| tree | 1586bab92060b0d6f8e6a447990a42e4e9f4a79b /lib | |
| parent | 4ea3e16caea18f079d66b387d000d9ba2db8fd1b (diff) | |
| download | enigma2-7d7ca8ee2eaae704989a1552ad429794d402f550.tar.gz enigma2-7d7ca8ee2eaae704989a1552ad429794d402f550.zip | |
add PyObject refcount debugging code
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/actions/action.h | 1 | ||||
| -rw-r--r-- | lib/base/nconfig.cpp | 2 | ||||
| -rw-r--r-- | lib/dvb/epgcache.cpp | 2 | ||||
| -rw-r--r-- | lib/dvb_ci/dvbci_ui.h | 2 | ||||
| -rw-r--r-- | lib/gui/elistboxcontent.cpp | 2 | ||||
| -rw-r--r-- | lib/nav/core.cpp | 2 | ||||
| -rw-r--r-- | lib/python/Makefile.am | 3 | ||||
| -rw-r--r-- | lib/python/connections.h | 1 | ||||
| -rw-r--r-- | lib/python/python.cpp | 39 | ||||
| -rw-r--r-- | lib/python/python.h | 27 | ||||
| -rw-r--r-- | lib/service/service.cpp | 2 |
11 files changed, 72 insertions, 11 deletions
diff --git a/lib/actions/action.h b/lib/actions/action.h index 560fdbbf..79c2dd27 100644 --- a/lib/actions/action.h +++ b/lib/actions/action.h @@ -7,7 +7,6 @@ #include <features.h> #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L -#include <Python.h> #include <lib/python/python.h> #include <string> #include <map> diff --git a/lib/base/nconfig.cpp b/lib/base/nconfig.cpp index 562b3503..878f4837 100644 --- a/lib/base/nconfig.cpp +++ b/lib/base/nconfig.cpp @@ -1,5 +1,5 @@ #include <lib/base/nconfig.h> -#include <Python.h> +#include <lib/python/python.h> PyObject *ePythonConfigQuery::m_queryFunc; diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp index e8394c40..9c2849b1 100644 --- a/lib/dvb/epgcache.cpp +++ b/lib/dvb/epgcache.cpp @@ -14,7 +14,7 @@ #include <lib/base/eerror.h> #include <lib/dvb/pmt.h> #include <lib/dvb/db.h> -#include <Python.h> +#include <lib/python/python.h> int eventData::CacheSize=0; descriptorMap eventData::descriptors; diff --git a/lib/dvb_ci/dvbci_ui.h b/lib/dvb_ci/dvbci_ui.h index b06eb454..5237e2f4 100644 --- a/lib/dvb_ci/dvbci_ui.h +++ b/lib/dvb_ci/dvbci_ui.h @@ -5,7 +5,7 @@ /* avoid warnigs :) */ #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L -#include <Python.h> +#include <lib/python/python.h> #include <lib/python/connections.h> #define MAX_SLOTS 4 diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index 261c548b..fd2091a1 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -1,7 +1,7 @@ #include <lib/gui/elistbox.h> #include <lib/gui/elistboxcontent.h> #include <lib/gdi/font.h> -#include <Python.h> +#include <lib/python/python.h> /* The basic idea is to have an interface which gives all relevant list diff --git a/lib/nav/core.cpp b/lib/nav/core.cpp index 7f76fa3f..0b4270d9 100644 --- a/lib/nav/core.cpp +++ b/lib/nav/core.cpp @@ -1,6 +1,6 @@ #include <lib/nav/core.h> #include <lib/base/eerror.h> -#include <Python.h> +#include <lib/python/python.h> void eNavigation::serviceEvent(iPlayableService* service, int event) { diff --git a/lib/python/Makefile.am b/lib/python/Makefile.am index 1cc01544..e0d5f0cd 100644 --- a/lib/python/Makefile.am +++ b/lib/python/Makefile.am @@ -11,6 +11,9 @@ libenigma_python_a_SOURCES = \ enigma_python_wrap.cxx: enigma_python.i swig -I$(top_srcdir)/ -c++ -python enigma_python.i + echo "#include <lib/python/python.h>" > bla.cxx + cat enigma_python_wrap.cxx >> bla.cxx + mv bla.cxx enigma_python_wrap.cxx installdir = $(LIBDIR)/enigma2/python diff --git a/lib/python/connections.h b/lib/python/connections.h index 8a06f7fa..9da6a002 100644 --- a/lib/python/connections.h +++ b/lib/python/connections.h @@ -7,7 +7,6 @@ #include <features.h> #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L -#include <Python.h> #include <lib/python/python.h> class PSignal diff --git a/lib/python/python.cpp b/lib/python/python.cpp index 119bff1c..2636a3d5 100644 --- a/lib/python/python.cpp +++ b/lib/python/python.cpp @@ -1,4 +1,3 @@ -#include <lib/python/python.h> #include <lib/base/eerror.h> /* avoid warnigs :) */ #undef _POSIX_C_SOURCE @@ -8,6 +7,44 @@ extern "C" void init_enigma(); extern void bsodFatal(); +void Impl_Py_DECREF(const char* file, int line, PyObject *obj) +{ + if (!obj) + { + eDebug("decref python object null pointer %s %d!!!", + file, line); + bsodFatal(); + } + if (obj->ob_refcnt <= 0) + { + eDebug("decref python object with refcounting value %d (%s %d)!!!", obj->ob_refcnt, file, line); + bsodFatal(); + } + Py_DECREF(obj); +} + +void Impl_Py_INCREF(const char* file, int line, PyObject *obj) +{ + if (!obj) + { + eDebug("incref python object null pointer %s %d!!!", file, line); + bsodFatal(); + } + if (obj->ob_refcnt <= 0) + { + eDebug("incref python object with refcounting value %d (%s %d)!!!", obj->ob_refcnt, file, line); + bsodFatal(); + } + if (obj->ob_refcnt == 0x7FFFFFFF) + { + eDebug("incref python object with refcounting value %d (MAX_INT!!!) (%s %d)!!!", obj->ob_refcnt, file, line); + bsodFatal(); + } + Py_INCREF(obj); +} + +#include <lib/python/python.h> + DEFINE_REF(TestObj); TestObj::TestObj() diff --git a/lib/python/python.h b/lib/python/python.h index 46e1a03d..27d2a9b1 100644 --- a/lib/python/python.h +++ b/lib/python/python.h @@ -3,10 +3,33 @@ #include <string> #include <lib/base/object.h> - -typedef struct _object PyObject; +#include <Python.h> // useable for debugging python refcounting +#undef Py_DECREF +#undef Py_XDECREF +#undef Py_INCREF +#undef Py_XINCREF +#define Py_XDECREF(obj) Impl_Py_XDECREF(__FILE__, __LINE__, obj) +#define Py_DECREF(obj) Impl_Py_DECREF(__FILE__, __LINE__, obj) +#define Py_XINCREF(obj) Impl_Py_XINCREF(__FILE__, __LINE__, obj) +#define Py_INCREF(obj) Impl_Py_INCREF(__FILE__, __LINE__, obj) + +void Impl_Py_DECREF(const char* file, int line, PyObject *obj); + +inline void Impl_Py_XDECREF(const char* file, int line, PyObject *obj) +{ + if (obj) + Impl_Py_DECREF(file, line, obj); +} + +void Impl_Py_INCREF(const char* file, int line, PyObject *obj); + +inline void Impl_Py_XINCREF(const char* file, int line, PyObject *obj) +{ + if (obj) + Impl_Py_INCREF(file, line, obj); +} extern PyObject *New_TestObj(); diff --git a/lib/service/service.cpp b/lib/service/service.cpp index 8ac7ebd4..181ec22f 100644 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -4,7 +4,7 @@ #include <lib/service/service.h> #include <lib/base/init_num.h> #include <lib/base/init.h> -#include <Python.h> +#include <lib/python/python.h> eServiceReference::eServiceReference(const std::string &string) { |
