#include "LanguageHook.h"
#include "AddonUtils.h"
+using namespace XBMCAddonUtils;
+
namespace XBMCAddon
{
// need a place to put the vtab
if (languageHook != NULL)
languageHook->Release();
-#ifdef LOG_LIFECYCLE_EVENTS
- CLog::Log(LOGDEBUG, "NEWADDON LIFECYCLE destroying %s 0x%lx", classname.c_str(), (long)(((void*)this)));
+#ifdef ENABLE_TRACE_API
+ TraceGuard tg_;
+ CLog::Log(LOGDEBUG, "%sNEWADDON destroying %s 0x%lx", tg_.getSpaces(), classname.c_str(), (long)(((void*)this)));
#endif
#ifdef XBMC_ADDON_DEBUG_MEMORY
AddonClass::AddonClass(const char* cname) : refs(0L), classname(cname), m_isDeallocating(false),
languageHook(NULL)
{
-#ifdef LOG_LIFECYCLE_EVENTS
- CLog::Log(LOGDEBUG, "NEWADDON LIFECYCLE constructing %s 0x%lx", classname.c_str(), (long)(((void*)this)));
+#ifdef ENABLE_TRACE_API
+ TraceGuard tg_;
+ CLog::Log(LOGDEBUG, "%sNEWADDON constructing %s 0x%lx", tg_.getSpaces(), classname.c_str(), (long)(((void*)this)));
#endif
#ifdef XBMC_ADDON_DEBUG_MEMORY
*
* Comment out (or uncomment out) to change the setting.
*/
-#define LOG_LIFECYCLE_EVENTS
+//#define LOG_LIFECYCLE_EVENTS
/**
* Defining XBMC_ADDON_DEBUG_MEMORY will make the Acquire and Release
static char** spaces = getSpacesArray(256);
+ const char* TraceGuard::getSpaces() { return spaces[depth]; }
+
TraceGuard::TraceGuard(const char* _function) :function(_function)
{
parent = tlParent.get();
CLog::Log(LOGDEBUG, "%sNEWADDON Entering %s", spaces[depth], function);
}
+ TraceGuard::TraceGuard() :function(NULL)
+ {
+ parent = tlParent.get();
+ depth = parent == NULL ? 0 : parent->depth + 1;
+ tlParent.set(this);
+ // silent
+ }
+
TraceGuard::~TraceGuard()
{
- CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);
+ if (function)
+ CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);
// need to pop the stack
tlParent.set(this->parent);
#pragma once
-#define ENABLE_TRACE_API
+//#define ENABLE_TRACE_API
#include "threads/SingleLock.h"
TraceGuard* parent;
int depth;
+ const char* getSpaces();
+
TraceGuard(const char* _function);
+ TraceGuard();
~TraceGuard();
};
#endif
// we need to grab the object lock to see if the object of the call
// is deallocating. holding this lock should prevent it from
// deallocating durring the execution of this call.
- CLog::Log(LOGDEBUG,"NEWADDON executing callback 0x%lx", (long)(p->cb.get()));
+#ifdef ENABLE_TRACE_API
+ CLog::Log(LOGDEBUG,"%sNEWADDON executing callback 0x%lx",_tg.getSpaces(),(long)(p->cb.get()));
+#endif
Synchronize lock2(*(p->cb->getObject()));
if (!p->cb->getObject()->isDeallocating())
{
if(p->handler->shouldRemoveCallback(userData))
{
- CLog::Log(LOGDEBUG,"NEWADDON removing callback 0x%lx for PyThreadState 0x%lx from queue", (long)(p->cb.get()) ,(long)userData);
+#ifdef ENABLE_TRACE_API
+ CLog::Log(LOGDEBUG,"%sNEWADDON removing callback 0x%lx for PyThreadState 0x%lx from queue", _tg.getSpaces(),(long)(p->cb.get()) ,(long)userData);
+#endif
g_callQueue.erase(iter);
}
else