Sound Open Firmware
Loading...
Searching...
No Matches

Dictionary-based trace logging engine, log filtering, and mailbox trace fallback. More...

Include dependency graph for trace-soflogger.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  trace_filter
 Runtime trace filter criteria for components and pipelines. More...
 

Macros

#define _DECLARE_LOG_ENTRY(lvl, format, comp_class, n_params)
 The start of this linker output MUST match the 'ldc_entry_header' struct defined in the logger program running in user space.
 
#define _TRACE_EVENT_MAX_ARGUMENT_COUNT   4
 
#define trace_event_with_ids(class, ctx, id_1, id_2, format, ...)
 
#define trace_event_atomic_with_ids(class, ctx, id_1, id_2, format, ...)
 
#define trace_warn_with_ids(class, ctx, id_1, id_2, format, ...)
 
#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format, ...)
 
#define _trace_event_with_ids(lvl, class, ctx, id_1, id_2, format, ...)    _log_message(trace_log_filtered, false, lvl, class, ctx, id_1, id_2, format, ##__VA_ARGS__)
 
#define _trace_event_atomic_with_ids(lvl, class, ctx, id_1, id_2, format, ...)    _log_message(trace_log_filtered, true, lvl, class, ctx, id_1, id_2, format, ##__VA_ARGS__)
 
#define MTRACE_DUPLICATION_LEVEL   LOG_LEVEL_ERROR
 
#define trace_point(x)   platform_trace_point(x)
 
#define BASE_LOG_ASSERT_FAIL_MSG
 
#define CT_ASSERT(COND, MESSAGE)    ((void)sizeof(char[1 - 2 * !(COND)]))
 
#define trace_check_size_uint32(a)    CT_ASSERT(sizeof(a) <= sizeof(uint32_t), "error: trace argument is bigger than a uint32_t");
 
#define STATIC_ASSERT_ARG_SIZE(...)    META_MAP(1, trace_check_size_uint32, __VA_ARGS__)
 
#define _log_message(log_func, atomic, lvl, comp_class, ctx, id_1, id_2, format, ...)
 _log_message is where the memory-saving dictionary magic described above happens: the "format" string argument is moved to a special linker section and replaced by a &log_entry pointer to it.
 
#define _log_nodict(atomic, arg_count, lvl, format, ...)
 
#define tracev_event_with_ids(class, ctx, id_1, id_2, format, ...)    trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
 
#define tracev_event_atomic_with_ids(class, ctx, id_1, id_2, format, ...)    trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
 
#define trace_error_with_ids(...)   trace_event_with_ids(__VA_ARGS__)
 
#define trace_error_atomic_with_ids(...)    trace_event_atomic_with_ids(__VA_ARGS__)
 
#define trace_dev_err(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...)
 Trace from a device on err level.
 
#define trace_dev_warn(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...)
 Trace from a device on warning level.
 
#define trace_dev_info(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...)
 Trace from a device on info level.
 
#define trace_dev_dbg(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...)
 Trace from a device on dbg level.
 
#define tr_err_atomic(ctx, fmt, ...)
 
#define tr_warn_atomic(ctx, fmt, ...)
 
#define tr_info_atomic(ctx, fmt, ...)
 
#define tr_dbg_atomic(ctx, fmt, ...)
 
#define tr_err(ctx, fmt, ...)
 
#define tr_warn(ctx, fmt, ...)
 
#define tr_info(ctx, fmt, ...)
 
#define tr_dbg(ctx, fmt, ...)
 
#define mtrace_printf(log_level, format_str, ...)
 Direct, low-level access to mbox / shared memory logging when DMA tracing is either not initialized yet or disabled or found broken for any reason.
 

Typedefs

typedef void(* log_func_t) (bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list args)
 Function pointer type for formatted trace logger backends.
 

Functions

static struct trace * trace_get (void)
 Retrieve global trace subsystem context from SOF runtime.
 
void trace_flush_dma_to_mbox (void)
 Flush buffered trace data from DMA buffer to Mailbox Window.
 
void trace_on (void)
 Globally resume trace event logging.
 
void trace_off (void)
 Globally pause trace event logging.
 
void trace_init (struct sof *sof)
 Initialize the trace subsystem and allocate global trace buffers.
 
void trace_log_filtered (bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list args)
 Emit a filtered dictionary trace message.
 
void trace_log_unfiltered (bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list args)
 Emit an unfiltered dictionary trace message directly to buffers.
 
struct sof_ipc_trace_filter_elem * trace_filter_fill (struct sof_ipc_trace_filter_elem *elem, struct sof_ipc_trace_filter_elem *end, struct trace_filter *filter)
 Populate an IPC trace filter element array.
 
int trace_filter_update (const struct trace_filter *elem)
 Update runtime trace filtering configuration from IPC payload.
 
void mtrace_dict_entry (bool atomic_context, uint32_t log_entry_pointer, int n_args,...)
 Appends one SOF dictionary entry and log statement to shared memory mtrace.
 
void mtrace_event (const char *complete_packet, uint32_t length)
 Posts a fully prepared log header and log entry packet to mtrace buffer.
 
void _log_sofdict (log_func_t sofdict_logf, bool atomic, const void *log_entry, const struct tr_ctx *ctx, const uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count,...)
 Internal dictionary logger formatting and dispatch helper.
 

Detailed Description

Dictionary-based trace logging engine, log filtering, and mailbox trace fallback.

Macro Definition Documentation

◆ _DECLARE_LOG_ENTRY

#define _DECLARE_LOG_ENTRY (   lvl,
  format,
  comp_class,
  n_params 
)
Value:
__section(".static_log." #lvl) \
static const struct { \
uint32_t level; \
uint32_t component_class; \
uint32_t params_num; \
uint32_t line_idx; \
uint32_t file_name_len; \
uint32_t text_len; \
const char file_name[sizeof(RELATIVE_FILE)]; \
const char text[sizeof(format)]; \
} log_entry = { \
lvl, \
comp_class, \
n_params, \
__LINE__, \
sizeof(RELATIVE_FILE), \
sizeof(format), \
RELATIVE_FILE, \
format \
}
#define __section(x)
Definition compiler_attributes.h:19

The start of this linker output MUST match the 'ldc_entry_header' struct defined in the logger program running in user space.

◆ _log_message

#define _log_message (   log_func,
  atomic,
  lvl,
  comp_class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)
Value:
do { \
_DECLARE_LOG_ENTRY(lvl, format, comp_class, \
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__)); \
STATIC_ASSERT_ARG_SIZE(__VA_ARGS__); \
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \
); \
_log_sofdict(log_func, atomic, &log_entry, ctx, lvl, id_1, id_2, \
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), ##__VA_ARGS__); \
_log_nodict(atomic, META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \
lvl, format, ##__VA_ARGS__); \
} while (0)
#define _TRACE_EVENT_MAX_ARGUMENT_COUNT
Definition trace-soflogger.h:63
#define BASE_LOG_ASSERT_FAIL_MSG
Definition trace-soflogger.h:295

_log_message is where the memory-saving dictionary magic described above happens: the "format" string argument is moved to a special linker section and replaced by a &log_entry pointer to it.

This must be a macro for the source location to be meaningful.

◆ _log_nodict

#define _log_nodict (   atomic,
  arg_count,
  lvl,
  format,
  ... 
)
Value:
do { \
if ((lvl) <= MTRACE_DUPLICATION_LEVEL) \
printk("%llu " format "\n", k_cycle_get_64(), \
##__VA_ARGS__); \
} while (0)
#define MTRACE_DUPLICATION_LEVEL
Definition trace-soflogger.h:242

◆ _trace_event_atomic_with_ids

#define _trace_event_atomic_with_ids (   lvl,
  class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)     _log_message(trace_log_filtered, true, lvl, class, ctx, id_1, id_2, format, ##__VA_ARGS__)

◆ _TRACE_EVENT_MAX_ARGUMENT_COUNT

#define _TRACE_EVENT_MAX_ARGUMENT_COUNT   4

◆ _trace_event_with_ids

#define _trace_event_with_ids (   lvl,
  class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)     _log_message(trace_log_filtered, false, lvl, class, ctx, id_1, id_2, format, ##__VA_ARGS__)

◆ BASE_LOG_ASSERT_FAIL_MSG

#define BASE_LOG_ASSERT_FAIL_MSG
Value:
unsupported_amount_of_params_in_trace_event\
_thrown_from_macro_BASE_LOG_in_trace_h

◆ CT_ASSERT

#define CT_ASSERT (   COND,
  MESSAGE 
)     ((void)sizeof(char[1 - 2 * !(COND)]))

◆ MTRACE_DUPLICATION_LEVEL

#define MTRACE_DUPLICATION_LEVEL   LOG_LEVEL_ERROR

◆ mtrace_printf

#define mtrace_printf (   log_level,
  format_str,
  ... 
)
Value:
do { \
STATIC_ASSERT(META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__) \
too_many_mtrace_printf_arguments); \
_DECLARE_LOG_ENTRY(log_level, format_str, _TRACE_INV_CLASS, \
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__)); \
mtrace_dict_entry(true, (uint32_t)&log_entry, \
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \
##__VA_ARGS__); \
} while (0)
#define _TRACE_INV_CLASS
This has been replaced in commits 6ce635aa82 and earlier by the DECLARE_TR_CTX, tr_ctx and component ...
Definition trace.h:126

Direct, low-level access to mbox / shared memory logging when DMA tracing is either not initialized yet or disabled or found broken for any reason.

To keep it simpler than and with minimal dependencies on the huge number of lines above, this does not check arguments at compile time. There is neither log level filtering, throttling or any other advanced feature.

◆ STATIC_ASSERT_ARG_SIZE

#define STATIC_ASSERT_ARG_SIZE (   ...)     META_MAP(1, trace_check_size_uint32, __VA_ARGS__)

◆ tr_dbg

#define tr_dbg (   ctx,
  fmt,
  ... 
)
Value:
_TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#define _TRACE_INV_ID
Default value when there is no specific pipeline, dev, dai, etc.
Definition trace.h:121
#define tracev_event_with_ids(class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:357

◆ tr_dbg_atomic

#define tr_dbg_atomic (   ctx,
  fmt,
  ... 
)
Value:
fmt, ##__VA_ARGS__)
#define tracev_event_atomic_with_ids(class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:359

◆ tr_err

#define tr_err (   ctx,
  fmt,
  ... 
)
Value:
_TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#define trace_error_with_ids(...)
Definition trace-soflogger.h:376

◆ tr_err_atomic

#define tr_err_atomic (   ctx,
  fmt,
  ... 
)
Value:
fmt, ##__VA_ARGS__)
#define trace_error_atomic_with_ids(...)
Definition trace-soflogger.h:377

◆ tr_info

#define tr_info (   ctx,
  fmt,
  ... 
)
Value:
_TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#define trace_event_with_ids(class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:102

◆ tr_info_atomic

#define tr_info_atomic (   ctx,
  fmt,
  ... 
)
Value:
fmt, ##__VA_ARGS__)
#define trace_event_atomic_with_ids(class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:106

◆ tr_warn

#define tr_warn (   ctx,
  fmt,
  ... 
)
Value:
_TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#define trace_warn_with_ids(class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:110

◆ tr_warn_atomic

#define tr_warn_atomic (   ctx,
  fmt,
  ... 
)
Value:
fmt, ##__VA_ARGS__)
#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:114

◆ trace_check_size_uint32

#define trace_check_size_uint32 (   a)     CT_ASSERT(sizeof(a) <= sizeof(uint32_t), "error: trace argument is bigger than a uint32_t");

◆ trace_dev_dbg

#define trace_dev_dbg (   get_ctx_m,
  get_id_m,
  get_subid_m,
  dev,
  fmt,
  ... 
)
Value:
get_ctx_m(dev), get_id_m(dev), \
get_subid_m(dev), fmt, ##__VA_ARGS__)

Trace from a device on dbg level.

◆ trace_dev_err

#define trace_dev_err (   get_ctx_m,
  get_id_m,
  get_subid_m,
  dev,
  fmt,
  ... 
)
Value:
get_id_m(dev), get_subid_m(dev), \
fmt, ##__VA_ARGS__)

Trace from a device on err level.

Parameters
get_ctx_mMacro that can retrieve trace context from dev
get_id_mMacro that can retrieve device's id0 from the dev
get_subid_mMacro that can retrieve device's id1 from the dev
devDevice
fmtFormat followed by parameters
...Parameters

◆ trace_dev_info

#define trace_dev_info (   get_ctx_m,
  get_id_m,
  get_subid_m,
  dev,
  fmt,
  ... 
)
Value:
get_id_m(dev), get_subid_m(dev), \
fmt, ##__VA_ARGS__)

Trace from a device on info level.

◆ trace_dev_warn

#define trace_dev_warn (   get_ctx_m,
  get_id_m,
  get_subid_m,
  dev,
  fmt,
  ... 
)
Value:
get_id_m(dev), get_subid_m(dev), \
fmt, ##__VA_ARGS__)

Trace from a device on warning level.

◆ trace_error_atomic_with_ids

#define trace_error_atomic_with_ids (   ...)     trace_event_atomic_with_ids(__VA_ARGS__)

◆ trace_error_with_ids

#define trace_error_with_ids (   ...)    trace_event_with_ids(__VA_ARGS__)

◆ trace_event_atomic_with_ids

#define trace_event_atomic_with_ids (   class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)
Value:
_trace_event_atomic_with_ids(LOG_LEVEL_INFO, class, ctx, id_1, id_2, \
format, ##__VA_ARGS__)
#define LOG_LEVEL_INFO
Normal informational operational messages.
Definition trace.h:33
#define _trace_event_atomic_with_ids(lvl, class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:212

◆ trace_event_with_ids

#define trace_event_with_ids (   class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)
Value:
_trace_event_with_ids(LOG_LEVEL_INFO, class, ctx, id_1, id_2, \
format, ##__VA_ARGS__)
#define _trace_event_with_ids(lvl, class, ctx, id_1, id_2, format,...)
Definition trace-soflogger.h:209

◆ trace_point

#define trace_point (   x)    platform_trace_point(x)

◆ trace_warn_atomic_with_ids

#define trace_warn_atomic_with_ids (   class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)
Value:
ctx, id_1, id_2, \
format, ##__VA_ARGS__)
#define LOG_LEVEL_WARNING
Warning conditions requiring attention.
Definition trace.h:32

◆ trace_warn_with_ids

#define trace_warn_with_ids (   class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)
Value:
_trace_event_with_ids(LOG_LEVEL_WARNING, class, ctx, id_1, id_2, \
format, ##__VA_ARGS__)

◆ tracev_event_atomic_with_ids

#define tracev_event_atomic_with_ids (   class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)     trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)

◆ tracev_event_with_ids

#define tracev_event_with_ids (   class,
  ctx,
  id_1,
  id_2,
  format,
  ... 
)     trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)