From 87f4af1ccabae6e64e3411eb60f6e4e8a51310b6 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 22 Sep 2016 11:22:19 +0800 Subject: main - Add a hacky MRUSTC_DEBUG environment variable to enable debug for passes --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 85916db5..b3425e0d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,6 +31,7 @@ int g_debug_indent_level = 0; void init_debug_list() { + // TODO: Mutate this map using an environment variable g_debug_disable_map.insert( "Parse" ); g_debug_disable_map.insert( "LoadCrates" ); g_debug_disable_map.insert( "Expand" ); @@ -61,6 +62,25 @@ void init_debug_list() g_debug_disable_map.insert( "Dump MIR" ); g_debug_disable_map.insert( "HIR Serialise" ); + + const char* debug_string = ::std::getenv("MRUSTC_DEBUG"); + if( debug_string ) + { + while( debug_string[0] ) + { + const char* end = strchr(debug_string, ':'); + + if( end ) { + ::std::string s { debug_string, end }; + g_debug_disable_map.erase( s ); + debug_string = end + 1; + } + else { + g_debug_disable_map.erase( debug_string ); + break; + } + } + } } bool debug_enabled() { -- cgit v1.2.3