X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdebug.cpp;h=278902a081b7fa2836063ace205771cbbcd4c871;hb=2a01050a0cf0826f25240e2cb407535394ee360f;hp=e32cceb8606c2dfc5fd3a2f6e197a2e315b29f0d;hpb=6d0ea26c2d62c3774ff384cf1bfc2a3372b49a3b;p=minetest.git diff --git a/src/debug.cpp b/src/debug.cpp index e32cceb86..278902a08 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -19,16 +19,34 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "debug.h" +#include "exceptions.h" +#include "threads.h" #include #include #include +#include +#include "jthread/jmutex.h" +#include "jthread/jmutexautolock.h" /* Debug output */ +#define DEBUGSTREAM_COUNT 2 + FILE *g_debugstreams[DEBUGSTREAM_COUNT] = {stderr, NULL}; +#define DEBUGPRINT(...)\ +{\ + for(int i=0; i g_debug_stacks; +std::map g_debug_stacks; JMutex g_debug_stacks_mutex; void debug_stacks_init() { - g_debug_stacks_mutex.Init(); } void debug_stacks_print_to(std::ostream &os) @@ -144,12 +214,11 @@ void debug_stacks_print_to(std::ostream &os) os<<"Debug stacks:"<::Iterator - i = g_debug_stacks.getIterator(); - i.atEnd() == false; i++) + for(std::map::iterator + i = g_debug_stacks.begin(); + i != g_debug_stacks.end(); ++i) { - DebugStack *stack = i.getNode()->getValue(); - stack->print(os, false); + i->second->print(os, false); } } @@ -159,11 +228,11 @@ void debug_stacks_print() DEBUGPRINT("Debug stacks:\n"); - for(core::map::Iterator - i = g_debug_stacks.getIterator(); - i.atEnd() == false; i++) + for(std::map::iterator + i = g_debug_stacks.begin(); + i != g_debug_stacks.end(); ++i) { - DebugStack *stack = i.getNode()->getValue(); + DebugStack *stack = i->second; for(int i=0; i::Node *n; + std::map::iterator n; n = g_debug_stacks.find(threadid); - if(n != NULL) + if(n != g_debug_stacks.end()) { - m_stack = n->getValue(); + 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.insert(threadid, m_stack); + g_debug_stacks[threadid] = m_stack; } if(m_stack->stack_i >= DEBUG_STACK_SIZE) @@ -224,7 +293,7 @@ DebugStacker::~DebugStacker() /*DEBUGPRINT("Deleting debug stack for thread %x\n", (unsigned int)threadid);*/ delete m_stack; - g_debug_stacks.remove(threadid); + g_debug_stacks.erase(threadid); } }