summaryrefslogtreecommitdiff
path: root/tools/standalone_miri/debug.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-03-04 21:20:00 +0800
committerJohn Hodge <tpg@mutabah.net>2018-03-17 18:52:16 +0800
commita8cd5861fdee9040a82654cc9d1fd41f98759d8b (patch)
treed5a05b794a422b4a3b25af874d6b155b9cf877d0 /tools/standalone_miri/debug.hpp
parent5d78f1ba303a0e8196e62d4bd0c7708387164993 (diff)
downloadmrust-a8cd5861fdee9040a82654cc9d1fd41f98759d8b.tar.gz
Standalone MIRI - Filled with hacks, but advancing
Diffstat (limited to 'tools/standalone_miri/debug.hpp')
-rw-r--r--tools/standalone_miri/debug.hpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/standalone_miri/debug.hpp b/tools/standalone_miri/debug.hpp
index 342ea6fe..5afad96e 100644
--- a/tools/standalone_miri/debug.hpp
+++ b/tools/standalone_miri/debug.hpp
@@ -72,11 +72,26 @@ FunctionTrace<T,U> FunctionTrace_d(const char* fname, const char* file, unsigned
return FunctionTrace<T,U>(fname, file, line, entry, exit);
}
+struct DebugExceptionTodo:
+ public ::std::exception
+{
+ const char* what() const {
+ return "TODO hit";
+ }
+};
+struct DebugExceptionError:
+ public ::std::exception
+{
+ const char* what() const {
+ return "error";
+ }
+};
+
#define TRACE_FUNCTION_R(entry, exit) auto ftg##__LINE__ = FunctionTrace_d(__FUNCTION__,__FILE__,__LINE__,[&](DebugSink& FunctionTrace_ss){FunctionTrace_ss << entry;}, [&](DebugSink& FunctionTrace_ss) {FunctionTrace_ss << exit;} )
#define LOG_TRACE(strm) do { if(DebugSink::enabled(__FUNCTION__)) DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Trace) << strm; } while(0)
#define LOG_DEBUG(strm) do { if(DebugSink::enabled(__FUNCTION__)) DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Debug) << strm; } while(0)
-#define LOG_ERROR(strm) do { DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Error) << strm; exit(1); } while(0)
+#define LOG_ERROR(strm) do { DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Error) << strm; throw DebugExceptionError{}; } while(0)
#define LOG_FATAL(strm) do { DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Fatal) << strm; exit(1); } while(0)
-#define LOG_TODO(strm) do { DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Bug) << "TODO: " << strm; abort(); } while(0)
+#define LOG_TODO(strm) do { DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Bug) << "TODO: " << strm; throw DebugExceptionTodo{}; } while(0)
#define LOG_BUG(strm) do { DebugSink::get(__FUNCTION__,__FILE__,__LINE__,DebugLevel::Bug) << "BUG: " << strm; abort(); } while(0)
#define LOG_ASSERT(cnd,strm) do { if( !(cnd) ) { LOG_BUG("Assertion failure: " #cnd " - " << strm); } } while(0)