Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/include/sof/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ void trace_on(void);
void trace_off(void);
void trace_init(struct sof *sof);
void trace_log(bool send_atomic, const void *log_entry,
const struct tr_ctx *ctx, uint32_t id_1, uint32_t id_2,
int arg_count, ...);
const struct tr_ctx *ctx, uint32_t lvl, uint32_t id_1,
uint32_t id_2, int arg_count, ...);

#define _trace_event_with_ids(lvl, class, ctx, id_1, id_2, format, ...) \
_log_message(false, lvl, class, ctx, id_1, id_2, \
Expand Down Expand Up @@ -201,7 +201,7 @@ do { \
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \
BASE_LOG_ASSERT_FAIL_MSG \
); \
trace_log(atomic, &log_entry, ctx, id_1, id_2, \
trace_log(atomic, &log_entry, ctx, lvl, id_1, id_2, \
PP_NARG(__VA_ARGS__), ##__VA_ARGS__); \
} while (0)

Expand Down
19 changes: 16 additions & 3 deletions src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,22 @@ static inline void mtrace_event(const char *data, uint32_t length)
}
#endif /* CONFIG_TRACEM */

/**
* \brief Runtime trace filtering
* \param lvl log level (LOG_LEVEL_ ERROR, INFO, DEBUG ...)
* \param uuid uuid address
* \return false when trace is filtered out, otherwise true
*/
static inline bool trace_filter_pass(uint32_t lvl,
const struct tr_ctx *ctx)
{
/* LOG_LEVEL_CRITICAL has low value, LOG_LEVEL_VERBOSE high */
return lvl <= ctx->level;
}

void trace_log(bool send_atomic, const void *log_entry,
const struct tr_ctx *ctx, uint32_t id_1, uint32_t id_2,
int arg_count, ...)
const struct tr_ctx *ctx, uint32_t lvl, uint32_t id_1,
uint32_t id_2, int arg_count, ...)
{
uint32_t data[MESSAGE_SIZE_DWORDS(_TRACE_EVENT_MAX_ARGUMENT_COUNT)];
const int message_size = MESSAGE_SIZE(arg_count);
Expand All @@ -109,7 +122,7 @@ void trace_log(bool send_atomic, const void *log_entry,
unsigned long flags;
#endif /* CONFIG_TRACEM */

if (!trace->enable) {
if (!trace->enable || !trace_filter_pass(lvl, ctx)) {
platform_shared_commit(trace, sizeof(*trace));
return;
}
Expand Down
5 changes: 3 additions & 2 deletions test/cmocka/src/common_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ void WEAK __panic(uint32_t p, char *filename, uint32_t linenum)
}

void WEAK trace_log(bool send_atomic, const void *log_entry,
const struct tr_ctx *ctx, uint32_t id_1, uint32_t id_2,
int arg_count, ...)
const struct tr_ctx *ctx, uint32_t lvl, uint32_t id_1,
uint32_t id_2, int arg_count, ...)
{
(void) send_atomic;
(void) log_entry;
(void) ctx;
(void) lvl;
(void) id_1;
(void) id_2;
(void) arg_count;
Expand Down