Skip to content

Commit 34deb12

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 9ce8795 commit 34deb12

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/debug/debug_stream/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,14 @@ 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+
select SOF_DEBUG_STREAM_TEXT_MSG
72+
help
73+
Enable assert print sending over debug stream as text
74+
message. This feature is also sensitive to Zephyr option
75+
CONFIG_EXCEPTION_DUMP_HOOK_ONLY. If that is set then the
76+
asserts are not printed through printk interface.
77+
6878
endif

src/debug/debug_stream/debug_stream_text_msg.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,32 @@ static int init_exception_dump_hook(void)
150150
}
151151

152152
SYS_INIT(init_exception_dump_hook, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
153+
154+
#if defined(CONFIG_SOF_DEBUG_STREAM_TEXT_MSG_ASSERT_PRINT)
155+
void assert_print(const char *fmt, ...)
156+
{
157+
va_list ap;
158+
159+
/* Do not print assert after exception has been dumped */
160+
if (ds_cpu[arch_proc_id()].reports_sent > 0)
161+
return;
162+
163+
va_start(ap, fmt);
164+
#if !defined(CONFIG_EXCEPTION_DUMP_HOOK_ONLY)
165+
{
166+
va_list ap2;
167+
168+
va_copy(ap2, ap);
169+
#endif
170+
ds_vamsg(fmt, ap);
171+
#if !defined(CONFIG_EXCEPTION_DUMP_HOOK_ONLY)
172+
vprintk(fmt, ap2);
173+
va_end(ap2);
174+
}
175+
#endif
176+
ds_vamsg(fmt, ap);
177+
va_end(ap);
178+
}
179+
EXPORT_SYMBOL(assert_print);
180+
#endif
153181
#endif

0 commit comments

Comments
 (0)