TraceGuard::TraceGuard() :function(NULL) { parent = tlParent.get(); depth = parent == NULL ? 0 : parent->depth + 1; tlParent.set(this); // silent }
void LanguageHook::clearLanguageHook() { LanguageHook* lh = addonLanguageHookTls.get(); addonLanguageHookTls.set(NULL); if (lh) lh->Release(); }
TraceGuard::~TraceGuard() { if (function) CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function); // need to pop the stack tlParent.set(this->parent); }
TraceGuard::TraceGuard(const char* _function) :function(_function) { parent = tlParent.get(); depth = parent == NULL ? 0 : parent->depth + 1; tlParent.set(this); CLog::Log(LOGDEBUG, "%sNEWADDON Entering %s", spaces[depth], function); }
THREADFUNC CThread::staticThread(void* data) { CThread* pThread = (CThread*)(data); std::string name; ThreadIdentifier id; bool autodelete; if (!pThread) { CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__); return 1; } name = pThread->m_ThreadName; id = pThread->m_ThreadId; autodelete = pThread->m_bAutoDelete; pThread->SetThreadInfo(); CLog::Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false")); currentThread.set(pThread); pThread->m_StartEvent.Set(); pThread->OnStartup(); pThread->Process(); pThread->OnExit(); // lock during termination CSingleLock lock(pThread->m_CriticalSection); pThread->m_ThreadId = 0; pThread->m_TermEvent.Set(); pThread->TermHandler(); lock.Leave(); if (autodelete) { CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id); delete pThread; pThread = NULL; } else CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id); return 0; }
DWORD WINAPI CThread::staticThread(LPVOID* data) #endif { CThread* pThread = (CThread*)(data); if (!pThread) { CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__); return 1; } if (pThread->m_ThreadName.empty()) pThread->m_ThreadName = pThread->GetTypeName(); pThread->SetDebugCallStackName(pThread->m_ThreadName.c_str()); CLog::Log(LOGDEBUG,"Thread %s start, auto delete: %d", pThread->m_ThreadName.c_str(), pThread->IsAutoDelete()); currentThread.set(pThread); #ifndef _LINUX /* install win32 exception translator */ win32_exception::install_handler(); #else struct sigaction action; action.sa_handler = term_handler; sigemptyset (&action.sa_mask); action.sa_flags = 0; //sigaction (SIGABRT, &action, NULL); //sigaction (SIGSEGV, &action, NULL); #endif try { pThread->OnStartup(); } #ifndef _LINUX catch (const win32_exception &e) { e.writelog(__FUNCTION__); if( pThread->IsAutoDelete() ) { delete pThread; _endthreadex(123); return 0; } } #endif catch(...) { CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, pThread->m_ThreadName.c_str(), pThread->IsAutoDelete()); if( pThread->IsAutoDelete() ) { delete pThread; #ifndef _LINUX _endthreadex(123); #endif return 0; } } try { pThread->Process(); } #ifndef _LINUX catch (const access_violation &e) { e.writelog(__FUNCTION__); } catch (const win32_exception &e) { e.writelog(__FUNCTION__); } #endif catch(...) { CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, attemping cleanup in OnExit", __FUNCTION__, pThread->m_ThreadName.c_str()); } try { pThread->OnExit(); } #ifndef _LINUX catch (const access_violation &e) { e.writelog(__FUNCTION__); } catch (const win32_exception &e) { e.writelog(__FUNCTION__); } #endif catch(...) { CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread exit", __FUNCTION__, pThread->m_ThreadName.c_str()); } if ( pThread->IsAutoDelete() ) { CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId()); delete pThread; pThread = NULL; } else CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId()); // DXMERGE - this looks like it might have used to have been useful for something... // g_graphicsContext.DeleteThreadContext(); #ifndef _LINUX _endthreadex(123); #endif return 0; }
void LanguageHook::setLanguageHook(LanguageHook* languageHook) { TRACE; languageHook->Acquire(); addonLanguageHookTls.set(languageHook); }