Skip to content

Commit 9ce8795

Browse files
author
Jyri Sarha
committed
debug_stream: text_msg: add va_list-based logging helper
Add ds_vamsg(const char *format, va_list ap) to the debug stream text message API and implementation. Refactor ds_msg() to forward to ds_vamsg() so formatting and record emission are handled in one shared path. This enables callers that already operate on va_list to emit debug stream text messages without rebuilding variadic arguments, and keeps the message construction logic centralized. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent ee02719 commit 9ce8795

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/debug/debug_stream/debug_stream_text_msg.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@
1515

1616
LOG_MODULE_REGISTER(debug_stream_text_msg);
1717

18-
void ds_msg(const char *format, ...)
18+
void ds_vamsg(const char *format, va_list args)
1919
{
20-
va_list args;
2120
struct {
2221
struct debug_stream_text_msg msg;
2322
char text[128];
2423
} __packed buf = { 0 };
2524
ssize_t len;
2625

27-
va_start(args, format);
2826
len = vsnprintf(buf.text, sizeof(buf.text), format, args);
29-
va_end(args);
3027

3128
if (len < 0)
3229
return;
@@ -38,6 +35,15 @@ void ds_msg(const char *format, ...)
3835
debug_stream_slot_send_record(&buf.msg.hdr);
3936
}
4037

38+
void ds_msg(const char *format, ...)
39+
{
40+
va_list args;
41+
42+
va_start(args, format);
43+
ds_vamsg(format, args);
44+
va_end(args);
45+
}
46+
4147
#if defined(CONFIG_EXCEPTION_DUMP_HOOK)
4248
/* The debug stream debug window slot is 4k, and when it is split
4349
* between the cores and the header/other overhead is removed, with 5

src/include/user/debug_stream_text_msg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define __SOC_DEBUG_STREAM_TEXT_MSG_H__
88

99
#include <user/debug_stream_slot.h>
10+
#include <stdarg.h>
1011

1112
/*
1213
* Debug Stream text message.
@@ -21,5 +22,6 @@ struct debug_stream_text_msg {
2122
* CONFIG_SOF_DEBUG_STREAM_TEXT_MSG to enable this function.
2223
*/
2324
void ds_msg(const char *format, ...);
25+
void ds_vamsg(const char *format, va_list ap);
2426

2527
#endif /* __SOC_DEBUG_STREAM_TEXT_MSG_H__ */

0 commit comments

Comments
 (0)