Skip to content

Commit d0f555f

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 c9c2d83 commit d0f555f

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/debug/debug_stream/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ config SOF_DEBUG_STREAM_TEXT_MSG
7474
ds_msg(). See include/user/debug_stream_text_msg.h for
7575
prototype.
7676

77+
config SOF_DEBUG_STREAM_TEXT_MSG_ASSERT_PRINT
78+
bool "Enable assert print sending through Debug-Stream"
79+
depends on EXCEPTION_DUMP_HOOK && (ASSERT || ASSERT_VERBOSE)
80+
select SOF_DEBUG_STREAM_TEXT_MSG
81+
help
82+
Enable assert print sending over debug stream as text
83+
message. This feature is also sensitive to Zephyr option
84+
CONFIG_EXCEPTION_DUMP_HOOK_ONLY. If that is set then the
85+
asserts are not printed through printk interface.
86+
7787
endif

src/debug/debug_stream/debug_stream_text_msg.c

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

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

0 commit comments

Comments
 (0)