X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fdebug.cpp;h=1a467265c551570e4a42a69bad764c990e386977;hb=c7c03ad7a60b77040d0dfc360a79f065e0c2c971;hp=3608f42d2315254f829a105ee22766332d30a3ce;hpb=e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd;p=dragonfireclient.git diff --git a/src/debug.cpp b/src/debug.cpp index 3608f42d2..1a467265c 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -21,12 +21,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "porting.h" #include "debug.h" #include "exceptions.h" -#include "threads.h" -#include -#include +#include +#include #include #include -#include "threading/mutex.h" +#include +#include #include "threading/mutex_auto_lock.h" #include "config.h" @@ -36,98 +36,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "filesys.h" #endif -/* - Debug output -*/ - -#define DEBUGSTREAM_COUNT 2 - -FILE *g_debugstreams[DEBUGSTREAM_COUNT] = {stderr, NULL}; - -#define DEBUGPRINT(...)\ -{\ - for(int i=0; i g_debug_stacks; -Mutex g_debug_stacks_mutex; - -void debug_stacks_init() -{ -} - -void debug_stacks_print_to(std::ostream &os) -{ - MutexAutoLock lock(g_debug_stacks_mutex); - - os<<"Debug stacks:"<::iterator - i = g_debug_stacks.begin(); - i != g_debug_stacks.end(); ++i) - { - i->second->print(os, false); - } -} - -void debug_stacks_print() -{ - MutexAutoLock lock(g_debug_stacks_mutex); - - DEBUGPRINT("Debug stacks:\n"); - - for(std::map::iterator - i = g_debug_stacks.begin(); - i != g_debug_stacks.end(); ++i) - { - DebugStack *stack = i->second; - - for(int i=0; iprint(g_debugstreams[i], true); - } - } -} - -DebugStacker::DebugStacker(const char *text) -{ - threadid_t threadid = get_current_thread_id(); - - MutexAutoLock lock(g_debug_stacks_mutex); - - std::map::iterator n; - n = g_debug_stacks.find(threadid); - if(n != g_debug_stacks.end()) - { - m_stack = n->second; - } - else - { - /*DEBUGPRINT("Creating new debug stack for thread %x\n", - (unsigned int)threadid);*/ - m_stack = new DebugStack(threadid); - g_debug_stacks[threadid] = m_stack; - } - - if(m_stack->stack_i >= DEBUG_STACK_SIZE) - { - m_overflowed = true; - } - else - { - m_overflowed = false; - - snprintf(m_stack->stack[m_stack->stack_i], - DEBUG_STACK_TEXT_SIZE, "%s", text); - m_stack->stack_i++; - if(m_stack->stack_i > m_stack->stack_max_i) - m_stack->stack_max_i = m_stack->stack_i; - } -} - -DebugStacker::~DebugStacker() -{ - MutexAutoLock lock(g_debug_stacks_mutex); - - if(m_overflowed == true) - return; - - m_stack->stack_i--; - - if(m_stack->stack_i == 0) - { - threadid_t threadid = m_stack->threadid; - /*DEBUGPRINT("Deleting debug stack for thread %x\n", - (unsigned int)threadid);*/ - delete m_stack; - g_debug_stacks.erase(threadid); - } -} - #ifdef _MSC_VER const char *Win32ExceptionCodeToString(DWORD exception_code)