mirror of
				https://github.com/Zygo/bees.git
				synced 2025-10-31 10:10:34 +01:00 
			
		
		
		
	tracer: annotate both ends of the stack trace
Add a matching "--- BEGIN TRACE..." line to complement the "--- END TRACE..." line. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
		| @@ -42,11 +42,16 @@ do_cmd_help(char *argv[]) | |||||||
| // tracing ---------------------------------------- | // tracing ---------------------------------------- | ||||||
|  |  | ||||||
| thread_local BeesTracer *BeesTracer::tl_next_tracer = nullptr; | thread_local BeesTracer *BeesTracer::tl_next_tracer = nullptr; | ||||||
|  | thread_local bool BeesTracer::tl_first = true; | ||||||
| thread_local bool BeesTracer::tl_silent = false; | thread_local bool BeesTracer::tl_silent = false; | ||||||
|  |  | ||||||
| BeesTracer::~BeesTracer() | BeesTracer::~BeesTracer() | ||||||
| { | { | ||||||
| 	if (!tl_silent && current_exception()) { | 	if (!tl_silent && current_exception()) { | ||||||
|  | 		if (tl_first) { | ||||||
|  | 			BEESLOGNOTICE("--- BEGIN TRACE --- exception ---"); | ||||||
|  | 			tl_first = false; | ||||||
|  | 		} | ||||||
| 		try { | 		try { | ||||||
| 			m_func(); | 			m_func(); | ||||||
| 		} catch (exception &e) { | 		} catch (exception &e) { | ||||||
| @@ -61,6 +66,7 @@ BeesTracer::~BeesTracer() | |||||||
| 	tl_next_tracer = m_next_tracer; | 	tl_next_tracer = m_next_tracer; | ||||||
| 	if (!m_next_tracer) { | 	if (!m_next_tracer) { | ||||||
| 		tl_silent = false; | 		tl_silent = false; | ||||||
|  | 		tl_first = true; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -197,6 +197,7 @@ class BeesTracer { | |||||||
|  |  | ||||||
| 	thread_local static BeesTracer *tl_next_tracer; | 	thread_local static BeesTracer *tl_next_tracer; | ||||||
| 	thread_local static bool tl_silent; | 	thread_local static bool tl_silent; | ||||||
|  | 	thread_local static bool tl_first; | ||||||
| public: | public: | ||||||
| 	BeesTracer(function<void()> f, bool silent = false); | 	BeesTracer(function<void()> f, bool silent = false); | ||||||
| 	~BeesTracer(); | 	~BeesTracer(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user