Skip to content

Commit c4aa33d

Browse files
committed
DPL: fix for printing O2_SIGNPOST_END without start interval
1 parent bd41c6a commit c4aa33d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Framework/Foundation/include/Framework/Signpost.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ inline _o2_signpost_id_t _o2_signpost_id_make_with_pointer(_o2_log_t* log, void
246246
#include <execinfo.h>
247247
#include "Framework/RuntimeError.h"
248248
#include "Framework/BacktraceHelpers.h"
249+
void _o2_signpost_event_emit_v(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, va_list args);
249250
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);
250251

251252
// returns true if the push was successful, false if the stack was full
@@ -358,11 +359,8 @@ void* _o2_log_create(char const* name, int defaultStacktrace)
358359

359360
// This will look at the slot in the log associated to the ID.
360361
// If the slot is empty, it will return the id and increment the indentation level.
361-
void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, ...)
362+
void _o2_signpost_event_emit_v(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, va_list args)
362363
{
363-
va_list args;
364-
va_start(args, format);
365-
366364
// Find the index of the activity
367365
int leading = 0;
368366

@@ -386,7 +384,6 @@ void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* n
386384
char prebuffer[4096];
387385
int s = snprintf(prebuffer, 4096, "id%.16" PRIx64 ":%-16s*>%*c", id.value, name, leading, ' ');
388386
vsnprintf(prebuffer + s, 4096 - s, format, args);
389-
va_end(args);
390387
O2_LOG_MACRO("%s", prebuffer);
391388
if (log->stacktrace > 1) {
392389
void* traces[o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE];
@@ -396,6 +393,15 @@ void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* n
396393
}
397394
}
398395

396+
// We separate this so that we can still emit the end signpost when the log is not enabled.
397+
void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, ...)
398+
{
399+
va_list args;
400+
va_start(args, format);
401+
_o2_signpost_event_emit_v(log, id, name, format, args);
402+
va_end(args);
403+
}
404+
399405
// This will look at the slot in the log associated to the ID.
400406
// If the slot is empty, it will return the id and increment the indentation level.
401407
void _o2_signpost_interval_begin(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, ...)
@@ -434,7 +440,7 @@ void _o2_signpost_interval_end_v(_o2_log_t* log, _o2_signpost_id_t id, char cons
434440
// We should not make this an error because one could have enabled the log after the interval
435441
// was started.
436442
if (i == log->ids.size()) {
437-
_o2_signpost_event_emit(log, id, name, format, args);
443+
_o2_signpost_event_emit_v(log, id, name, format, args);
438444
return;
439445
}
440446
// i is the slot index

0 commit comments

Comments
 (0)