-
Notifications
You must be signed in to change notification settings - Fork 358
Debug stream text msg improvements #10845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,28 +13,59 @@ | |
|
|
||
| #include <user/debug_stream_text_msg.h> | ||
|
|
||
| #ifdef CONFIG_USERSPACE | ||
| #include <zephyr/internal/syscall_handler.h> | ||
| #endif | ||
|
|
||
| LOG_MODULE_REGISTER(debug_stream_text_msg); | ||
|
|
||
| void ds_vamsg(const char *format, va_list args) | ||
| #ifdef CONFIG_USERSPACE | ||
| void z_impl_ds_send_text_record(const char *text, size_t len) | ||
| #else | ||
| void ds_send_text_record(const char *text, size_t len) | ||
| #endif | ||
| { | ||
| struct { | ||
| struct debug_stream_text_msg msg; | ||
| char text[128]; | ||
| char text[DS_TEXT_MSG_MAX_LEN]; | ||
| } __packed buf = { 0 }; | ||
| ssize_t len; | ||
|
|
||
| len = vsnprintf(buf.text, sizeof(buf.text), format, args); | ||
|
|
||
| if (len < 0) | ||
| if (!text || len == 0) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a curious mix of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I drop len check. The code can cope with zero length. |
||
| return; | ||
|
|
||
| len = MIN(len, sizeof(buf.text)); | ||
| memcpy(buf.text, text, len); | ||
|
|
||
| buf.msg.hdr.id = DEBUG_STREAM_RECORD_ID_TEXT_MSG; | ||
| buf.msg.hdr.size_words = SOF_DIV_ROUND_UP(sizeof(buf.msg) + len, | ||
| sizeof(buf.msg.hdr.data[0])); | ||
| debug_stream_slot_send_record(&buf.msg.hdr); | ||
| } | ||
|
|
||
| #ifdef CONFIG_USERSPACE | ||
| static inline void z_vrfy_ds_send_text_record(const char *text, size_t len) | ||
| { | ||
| len = MIN(len, DS_TEXT_MSG_MAX_LEN); | ||
| K_OOPS(K_SYSCALL_MEMORY_READ(text, len)); | ||
| z_impl_ds_send_text_record(text, len); | ||
| } | ||
| #include <zephyr/syscalls/ds_send_text_record_mrsh.c> | ||
| #endif | ||
|
|
||
| void ds_vamsg(const char *format, va_list args) | ||
| { | ||
| char text[DS_TEXT_MSG_MAX_LEN]; | ||
| ssize_t len; | ||
|
|
||
| len = vsnprintf(text, sizeof(text), format, args); | ||
|
|
||
| if (len < 0) | ||
| return; | ||
| len = MIN(len, sizeof(text)); | ||
|
|
||
| ds_send_text_record(text, len); | ||
| } | ||
|
Comment on lines
+55
to
+67
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, I'll make debug_stream_slot_send_record() a syscall instead. |
||
|
|
||
| void ds_msg(const char *format, ...) | ||
| { | ||
| va_list args; | ||
|
|
@@ -43,6 +74,7 @@ void ds_msg(const char *format, ...) | |
| ds_vamsg(format, args); | ||
| va_end(args); | ||
| } | ||
| EXPORT_SYMBOL(ds_msg); | ||
|
|
||
| #if defined(CONFIG_EXCEPTION_DUMP_HOOK) | ||
| /* The debug stream debug window slot is 4k, and when it is split | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually we don't have to do this - we just define
z_impl_...()functions and the Zephyr syscall magic calls those when userspace is disabled. Why is this needed here?