X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fdebug.cpp;h=8c02f1d6b00ad54a403b13b72afd2c1c575e8c7f;hb=dec8c43de3afdbd2e257a031f5e053e7f1e74aa0;hp=8b25cc22d4ec6b08a8f17ce78ed0f444345147f5;hpb=9f031a67594162a53b07acbfbc65faf8c4938e99;p=oweals%2Fminetest.git diff --git a/src/debug.cpp b/src/debug.cpp index 8b25cc22d..8c02f1d6b 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -1,6 +1,6 @@ /* -Minetest-c55 -Copyright (C) 2010 celeron55, Perttu Ahola +Minetest +Copyright (C) 2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -18,17 +18,36 @@ 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 "jthread/jmutex.h" +#include "jthread/jmutexautolock.h" +#include "config.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 +218,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 +232,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 +297,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); } }