sched/misc: Add support for coredump in assert
Add coredump support to collect the stacks and registers of all threads when asserting Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
parent
e0f4a76d6c
commit
86bf7d9bec
@ -4034,6 +4034,30 @@ config BOARD_CRASHDUMP
|
|||||||
"machine state" in a place where on the next reset can write it
|
"machine state" in a place where on the next reset can write it
|
||||||
to more sophisticated storage in a sane operating environment.
|
to more sophisticated storage in a sane operating environment.
|
||||||
|
|
||||||
|
config BOARD_COREDUMP
|
||||||
|
bool "Enable Core Dump after assert"
|
||||||
|
default n
|
||||||
|
depends on ELF_COREDUMP
|
||||||
|
---help---
|
||||||
|
Enable to support for the dump core information after assert.
|
||||||
|
|
||||||
|
if BOARD_COREDUMP
|
||||||
|
|
||||||
|
config BOARD_COREDUMP_FULL
|
||||||
|
bool "Core Dump all thread registers and stacks"
|
||||||
|
default y
|
||||||
|
---help---
|
||||||
|
Enable to support for the dump all task registers and stacks.
|
||||||
|
|
||||||
|
config BOARD_COREDUMP_COMPRESSION
|
||||||
|
bool "Enable Core Dump compression"
|
||||||
|
default y
|
||||||
|
select LIBC_LZF
|
||||||
|
---help---
|
||||||
|
Enable LZF compression algorithm for core dump content
|
||||||
|
|
||||||
|
endif # BOARD_COREDUMP
|
||||||
|
|
||||||
config BOARD_ENTROPY_POOL
|
config BOARD_ENTROPY_POOL
|
||||||
bool "Enable Board level storing of entropy pool structure"
|
bool "Enable Board level storing of entropy pool structure"
|
||||||
default n
|
default n
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/binfmt/binfmt.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
@ -71,6 +72,14 @@
|
|||||||
|
|
||||||
static uint8_t g_last_regs[XCPTCONTEXT_SIZE];
|
static uint8_t g_last_regs[XCPTCONTEXT_SIZE];
|
||||||
|
|
||||||
|
#ifdef CONFIG_BOARD_COREDUMP
|
||||||
|
static struct lib_syslogstream_s g_syslogstream;
|
||||||
|
static struct lib_hexdumpstream_s g_hexstream;
|
||||||
|
# ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
|
||||||
|
static struct lib_lzfoutstream_s g_lzfstream;
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static FAR const char *g_policy[4] =
|
static FAR const char *g_policy[4] =
|
||||||
{
|
{
|
||||||
"FIFO", "RR", "SPORADIC"
|
"FIFO", "RR", "SPORADIC"
|
||||||
@ -459,6 +468,53 @@ static void show_tasks(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: dump_core
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_BOARD_COREDUMP
|
||||||
|
static void dump_core(pid_t pid)
|
||||||
|
{
|
||||||
|
FAR void *stream;
|
||||||
|
int logmask;
|
||||||
|
|
||||||
|
logmask = setlogmask(LOG_ALERT);
|
||||||
|
|
||||||
|
_alert("Start coredump:\n");
|
||||||
|
|
||||||
|
/* Initialize hex output stream */
|
||||||
|
|
||||||
|
lib_syslogstream(&g_syslogstream, LOG_EMERG);
|
||||||
|
|
||||||
|
stream = &g_syslogstream;
|
||||||
|
|
||||||
|
lib_hexdumpstream(&g_hexstream, stream);
|
||||||
|
|
||||||
|
stream = &g_hexstream;
|
||||||
|
|
||||||
|
# ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
|
||||||
|
|
||||||
|
/* Initialize LZF compression stream */
|
||||||
|
|
||||||
|
lib_lzfoutstream(&g_lzfstream, stream);
|
||||||
|
stream = &g_lzfstream;
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Do core dump */
|
||||||
|
|
||||||
|
core_dump(NULL, stream, pid);
|
||||||
|
|
||||||
|
# ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
|
||||||
|
_alert("Finish coredump (Compression Enabled).\n");
|
||||||
|
# else
|
||||||
|
_alert("Finish coredump.\n");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
setlogmask(logmask);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -550,6 +606,16 @@ void _assert(FAR const char *filename, int linenum,
|
|||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||||
board_crashdump(up_getsp(), rtcb, filename, linenum, msg);
|
board_crashdump(up_getsp(), rtcb, filename, linenum, msg);
|
||||||
|
|
||||||
|
#elif defined(CONFIG_BOARD_COREDUMP)
|
||||||
|
/* Dump core information */
|
||||||
|
|
||||||
|
# ifdef CONFIG_BOARD_COREDUMP_FULL
|
||||||
|
dump_core(INVALID_PROCESS_ID);
|
||||||
|
# else
|
||||||
|
dump_core(rtcb->pid);
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data */
|
/* Flush any buffered SYSLOG data */
|
||||||
|
Loading…
Reference in New Issue
Block a user