-
Notifications
You must be signed in to change notification settings - Fork 350
Exception dump hook #10517
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?
Exception dump hook #10517
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 |
|---|---|---|
|
|
@@ -8,9 +8,13 @@ | |
| #include <soc.h> | ||
| #include <adsp_debug_window.h> | ||
| #include <sof/common.h> | ||
| #include <zephyr/logging/log.h> | ||
| #include <zephyr/arch/exception.h> | ||
|
|
||
| #include <user/debug_stream_text_msg.h> | ||
|
|
||
| LOG_MODULE_REGISTER(debug_stream_text_msg); | ||
|
|
||
| void ds_msg(const char *format, ...) | ||
| { | ||
| va_list args; | ||
|
|
@@ -33,3 +37,57 @@ void ds_msg(const char *format, ...) | |
| sizeof(buf.msg.hdr.data[0])); | ||
| debug_stream_slot_send_record(&buf.msg.hdr); | ||
| } | ||
|
|
||
| static struct { | ||
| struct debug_stream_text_msg msg; | ||
| char text[768]; | ||
| } __packed buf = { 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.
|
||
| static int reports_sent_cpu[CONFIG_MP_MAX_NUM_CPUS] = { 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. ditto 0 |
||
| static size_t pos; | ||
|
|
||
| static void ds_exception_drain(bool flush) | ||
| { | ||
| if (flush) { | ||
| pos = 0; | ||
| return; | ||
| } | ||
|
|
||
| if (reports_sent_cpu[arch_proc_id()]++ > 0) | ||
| return; | ||
|
|
||
| buf.msg.hdr.id = DEBUG_STREAM_RECORD_ID_TEXT_MSG; | ||
| buf.msg.hdr.size_words = SOF_DIV_ROUND_UP(sizeof(buf.msg) + pos, | ||
| sizeof(buf.msg.hdr.data[0])); | ||
| memset(buf.text + pos, 0, buf.msg.hdr.size_words * sizeof(uint32_t) - pos); | ||
|
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.
|
||
| debug_stream_slot_send_record(&buf.msg.hdr); | ||
| pos = 0; | ||
| } | ||
|
|
||
| static void ds_exception_dump(const char *format, va_list args) | ||
| { | ||
| ssize_t len; | ||
|
|
||
| if (reports_sent_cpu[arch_proc_id()] > 0) | ||
| return; | ||
|
|
||
| len = vsnprintf(buf.text + pos, sizeof(buf.text) - pos, format, args); | ||
| if (len < 0) { | ||
| pos = 0; | ||
| return; | ||
| } | ||
| pos += MIN(len, sizeof(buf.text)); | ||
|
|
||
| if (pos >= sizeof(buf.text)) | ||
| ds_exception_drain(false); | ||
| } | ||
|
|
||
| #if defined(CONFIG_EXCEPTION_DUMP_HOOK) | ||
|
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. without |
||
| static int init_exception_dump_hook(void) | ||
| { | ||
| set_exception_dump_hook(ds_exception_dump, ds_exception_drain); | ||
| LOG_INF("exception_dump_hook set"); | ||
| return 0; | ||
| } | ||
|
|
||
| SYS_INIT(init_exception_dump_hook, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); | ||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| #define __SOC_DEBUG_STREAM_TEXT_MSG_H__ | ||
|
|
||
| #include <user/debug_stream_slot.h> | ||
| #include <stdarg.h> | ||
|
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. does anything in the header need it? I guess you wanted this in .c |
||
|
|
||
| /* | ||
| * Debug Stream text message. | ||
|
|
||
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.
k_spinlock_init()