From bfab486611fb9dba2efcab3262ace9f281876521 Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Thu, 15 Jun 2023 11:12:58 +0800 Subject: [PATCH] assert: add panic notifier data for notify more information Signed-off-by: zhangyuan21 --- include/assert.h | 4 ---- include/nuttx/panic_notifier.h | 9 +++++++++ sched/misc/assert.c | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/assert.h b/include/assert.h index 8cd1fa3531..6a2d8bca34 100644 --- a/include/assert.h +++ b/include/assert.h @@ -140,10 +140,6 @@ #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) -/**************************************************************************** - * Included Files - ****************************************************************************/ - /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/include/nuttx/panic_notifier.h b/include/nuttx/panic_notifier.h index 2e6553d2ef..525e68dd4f 100644 --- a/include/nuttx/panic_notifier.h +++ b/include/nuttx/panic_notifier.h @@ -27,6 +27,7 @@ #include #include +#include #include @@ -41,6 +42,14 @@ enum panic_type_e PANIC_KERNEL_FINAL = 2, }; +/* Notifier data for panic */ + +struct panic_notifier_s +{ + FAR struct tcb_s *rtcb; + FAR void *regs; +}; + /**************************************************************************** * Public Function ****************************************************************************/ diff --git a/sched/misc/assert.c b/sched/misc/assert.c index ac17b3460b..74c1c231b1 100644 --- a/sched/misc/assert.c +++ b/sched/misc/assert.c @@ -553,6 +553,7 @@ void _assert(FAR const char *filename, int linenum, FAR const char *msg, FAR void *regs) { FAR struct tcb_s *rtcb = running_task(); + struct panic_notifier_s notifier_data; struct utsname name; bool fatal = true; int flags; @@ -581,7 +582,10 @@ void _assert(FAR const char *filename, int linenum, } #endif - panic_notifier_call_chain(fatal ? PANIC_KERNEL : PANIC_TASK, rtcb); + notifier_data.rtcb = rtcb; + notifier_data.regs = regs; + panic_notifier_call_chain(fatal ? PANIC_KERNEL : PANIC_TASK, + ¬ifier_data); uname(&name); _alert("Current Version: %s %s %s %s %s\n", @@ -658,7 +662,7 @@ void _assert(FAR const char *filename, int linenum, /* Flush any buffered SYSLOG data */ syslog_flush(); - panic_notifier_call_chain(PANIC_KERNEL_FINAL, rtcb); + panic_notifier_call_chain(PANIC_KERNEL_FINAL, ¬ifier_data); reboot_notifier_call_chain(SYS_HALT, NULL);