diff options
author | John Hodge <tpg@mutabah.net> | 2018-03-18 10:48:26 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-03-18 10:48:26 +0800 |
commit | 5b0450395af81ceba0d0ac27fc73b16f966bd7d3 (patch) | |
tree | e3c753b83a562be78cdbd74b8164dab785bf07a6 /tools/minicargo/debug.cpp | |
parent | 363e6fa172f787e970c8abc8f631b6d60d571248 (diff) | |
download | mrust-5b0450395af81ceba0d0ac27fc73b16f966bd7d3.tar.gz |
All - Move toml parser and path header to a common library, start on custom target specs.
Diffstat (limited to 'tools/minicargo/debug.cpp')
-rw-r--r-- | tools/minicargo/debug.cpp | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/tools/minicargo/debug.cpp b/tools/minicargo/debug.cpp deleted file mode 100644 index a3fb9956..00000000 --- a/tools/minicargo/debug.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MiniCargo - mrustc's minimal clone of cargo - * - By John Hodge (Mutabah/thePowersGang) - * - * debug.cpp - * - Debugging helpers - */ -#if defined(__MINGW32__) -# define DISABLE_MULTITHREAD // Mingw32 doesn't have c++11 threads -#endif -#include <set> -#include <iostream> -#include "debug.h" -#include <mutex> - -static int giIndentLevel = 0; -static const char* gsDebugPhase = ""; -static ::std::set<::std::string> gmDisabledDebug; -#ifndef DISABLE_MULTITHREAD -static ::std::mutex gDebugLock; -#endif - -void Debug_SetPhase(const char* phase_name) -{ - gsDebugPhase = phase_name; -} -bool Debug_IsEnabled() -{ - if( gmDisabledDebug.find(gsDebugPhase) != gmDisabledDebug.end() ) - return false; - return true; -} -void Debug_DisablePhase(const char* phase_name) -{ - gmDisabledDebug.insert( ::std::string(phase_name) ); -} -void Debug_Print(::std::function<void(::std::ostream& os)> cb) -{ - if( !Debug_IsEnabled() ) - return ; -#ifndef DISABLE_MULTITHREAD - ::std::unique_lock<::std::mutex> _lh { gDebugLock }; -#endif - - ::std::cout << gsDebugPhase << "- "; - for(auto i = giIndentLevel; i --; ) - ::std::cout << " "; - cb(::std::cout); - ::std::cout << ::std::endl; -} -void Debug_EnterScope(const char* name, dbg_cb_t cb) -{ - if( !Debug_IsEnabled() ) - return ; -#ifndef DISABLE_MULTITHREAD - ::std::unique_lock<::std::mutex> _lh { gDebugLock }; -#endif - - ::std::cout << gsDebugPhase << "- "; - for(auto i = giIndentLevel; i --; ) - ::std::cout << " "; - ::std::cout << ">>> " << name << "("; - cb(::std::cout); - ::std::cout << ")" << ::std::endl; - giIndentLevel ++; -} -void Debug_LeaveScope(const char* name, dbg_cb_t cb) -{ - if( !Debug_IsEnabled() ) - return ; -#ifndef DISABLE_MULTITHREAD - ::std::unique_lock<::std::mutex> _lh { gDebugLock }; -#endif - - ::std::cout << gsDebugPhase << "- "; - giIndentLevel --; - for(auto i = giIndentLevel; i --; ) - ::std::cout << " "; - ::std::cout << "<<< " << name << ::std::endl; -} |