Skip to content

Commit 8e63310

Browse files
committed
DPL: allow printing stacktrace on signposts
1 parent 64c47f6 commit 8e63310

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Framework/Core/src/runDataProcessing.cxx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,9 +2741,20 @@ void enableSignposts(std::string const& signpostsToEnable)
27412741
auto* log = (_o2_log_t*)l;
27422742
auto* selectedName = (char const*)context;
27432743
std::string prefix = "ch.cern.aliceo2.";
2744-
if (strcmp(name, (prefix + selectedName).data()) == 0) {
2745-
LOGP(info, "Enabling signposts for stream \"ch.cern.aliceo2.{}\"", selectedName);
2746-
_o2_log_set_stacktrace(log, 1);
2744+
auto* last = strchr(selectedName, ':');
2745+
int maxDepth = 1;
2746+
if (last) {
2747+
char* err;
2748+
maxDepth = strtol(last + 1, &err, 10);
2749+
if (*(last + 1) == '\0' || *err != '\0') {
2750+
maxDepth = 1;
2751+
}
2752+
}
2753+
2754+
auto fullName = prefix + std::string{selectedName, last ? last - selectedName : strlen(selectedName)};
2755+
if (strncmp(name, fullName.data(), fullName.size()) == 0) {
2756+
LOGP(info, "Enabling signposts for stream \"{}\" with depth {}.", fullName, maxDepth);
2757+
_o2_log_set_stacktrace(log, maxDepth);
27472758
return false;
27482759
} else {
27492760
LOGP(info, "Signpost stream \"{}\" disabled. Enable it with o2-log -p {} -a {}", name, pid, (void*)&log->stacktrace);

Framework/Foundation/include/Framework/Signpost.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* n
381381
O2_LOG_MACRO("%s", prebuffer);
382382
if (log->stacktrace > 1) {
383383
void* traces[o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE];
384-
int maxBacktrace = backtrace(traces, o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE);
384+
// We add one extra frame, because one is for the logging
385+
int maxBacktrace = backtrace(traces, (log->stacktrace + 1) < o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE ? (log->stacktrace + 1) : o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE);
385386
o2::framework::BacktraceHelpers::demangled_backtrace_symbols(traces, maxBacktrace, STDERR_FILENO);
386387
}
387388
}

0 commit comments

Comments
 (0)