Skip to content

Commit 2d4b0a1

Browse files
authored
DPL: provide stacktrace for errors also on Linux, if requested. (#13338)
1 parent a2e7b8e commit 2d4b0a1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Framework/Foundation/include/Framework/Signpost.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ inline _o2_signpost_id_t _o2_signpost_id_make_with_pointer(_o2_log_t* log, void
234234
#include <cstdarg>
235235
#include <cstdio>
236236
#include <cstring>
237+
#include <execinfo.h>
237238
#include "Framework/RuntimeError.h"
239+
#include "Framework/BacktraceHelpers.h"
238240
void _o2_signpost_interval_end_v(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, va_list args);
239241

240242
// returns true if the push was successful, false if the stack was full
@@ -377,6 +379,11 @@ void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* n
377379
vsnprintf(prebuffer + s, 4096 - s, format, args);
378380
va_end(args);
379381
O2_LOG_MACRO("%s", prebuffer);
382+
if (log->stacktrace > 1) {
383+
void* traces[o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE];
384+
int maxBacktrace = backtrace(traces, o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE);
385+
o2::framework::BacktraceHelpers::demangled_backtrace_symbols(traces, maxBacktrace, STDERR_FILENO);
386+
}
380387
}
381388

382389
// This will look at the slot in the log associated to the ID.

0 commit comments

Comments
 (0)