mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 13:25:45 +02: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:
parent
b083003cf7
commit
1fd26a03b2
@ -42,11 +42,16 @@ do_cmd_help(char *argv[])
|
||||
// tracing ----------------------------------------
|
||||
|
||||
thread_local BeesTracer *BeesTracer::tl_next_tracer = nullptr;
|
||||
thread_local bool BeesTracer::tl_first = true;
|
||||
thread_local bool BeesTracer::tl_silent = false;
|
||||
|
||||
BeesTracer::~BeesTracer()
|
||||
{
|
||||
if (!tl_silent && current_exception()) {
|
||||
if (tl_first) {
|
||||
BEESLOGNOTICE("--- BEGIN TRACE --- exception ---");
|
||||
tl_first = false;
|
||||
}
|
||||
try {
|
||||
m_func();
|
||||
} catch (exception &e) {
|
||||
@ -61,6 +66,7 @@ BeesTracer::~BeesTracer()
|
||||
tl_next_tracer = m_next_tracer;
|
||||
if (!m_next_tracer) {
|
||||
tl_silent = false;
|
||||
tl_first = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,6 +197,7 @@ class BeesTracer {
|
||||
|
||||
thread_local static BeesTracer *tl_next_tracer;
|
||||
thread_local static bool tl_silent;
|
||||
thread_local static bool tl_first;
|
||||
public:
|
||||
BeesTracer(function<void()> f, bool silent = false);
|
||||
~BeesTracer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user