Skip to content

Commit b282d15

Browse files
author
Jyri Sarha
committed
debug_stream: text_msg: add optional assert_print() forwarding
Add optional support to route assert output through debug stream text messages. Introduce Kconfig option SOF_DEBUG_STREAM_TEXT_MSG_ASSERT_PRINT (depends on EXCEPTION_DUMP_HOOK and ASSERT/ASSERT_VERBOSE). Implement assert_print(const char *fmt, ...) to emit via ds_vamsg(), and mirror to vprintk() when CONFIG_EXCEPTION_DUMP_HOOK_ONLY is not set. Avoid duplicate post-fault prints by skipping assert output after an exception report has already been sent on the current CPU. Export assert_print for use by assert paths. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent c534c96 commit b282d15

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/debug/debug_stream/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,13 @@ config SOF_DEBUG_STREAM_TEXT_MSG
6565
ds_msg(). See include/user/debug_stream_text_msg.h for
6666
prototype.
6767

68+
config SOF_DEBUG_STREAM_TEXT_MSG_ASSERT_PRINT
69+
bool "Enable assert print sending through Debug-Stream"
70+
depends on EXCEPTION_DUMP_HOOK && (ASSERT || ASSERT_VERBOSE)
71+
help
72+
Enable assert print sending over debug stream as text
73+
message. This feature is also sensitive to Zephyr option
74+
CONFIG_EXCEPTION_DUMP_HOOK_ONLY. If that is set then the
75+
asserts are not printed through printk interface.
76+
6877
endif

src/debug/debug_stream/debug_stream_text_msg.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,25 @@ static int init_exception_dump_hook(void)
142142
}
143143

144144
SYS_INIT(init_exception_dump_hook, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
145+
146+
#if defined(CONFIG_SOF_DEBUG_STREAM_TEXT_MSG_ASSERT_PRINT)
147+
148+
void assert_print(const char *fmt, ...)
149+
{
150+
va_list ap;
151+
152+
/* Do not print assert after exception has been dumped */
153+
if (reports_sent_cpu[arch_proc_id()] > 0)
154+
return;
155+
156+
va_start(ap, fmt);
157+
158+
ds_vamsg(fmt, ap);
159+
#if !defined(CONFIG_EXCEPTION_DUMP_HOOK_ONLY)
160+
vprintk(fmt, ap);
161+
#endif
162+
va_end(ap);
163+
}
164+
EXPORT_SYMBOL(assert_print);
165+
#endif
145166
#endif

0 commit comments

Comments
 (0)