From 2ff2b8243773df3a56d535635b898a06f3f8c0f6 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 30 Jan 2024 16:08:04 +0800 Subject: [PATCH] coredump:coredump_set_memory_region to set memory region Signed-off-by: anjiahao --- {sched/misc => include/nuttx}/coredump.h | 19 +++++++++++++++---- sched/init/nx_bringup.c | 2 +- sched/misc/assert.c | 2 +- sched/misc/coredump.c | 22 +++++++++++++++++++--- 4 files changed, 36 insertions(+), 9 deletions(-) rename {sched/misc => include/nuttx}/coredump.h (80%) diff --git a/sched/misc/coredump.h b/include/nuttx/coredump.h similarity index 80% rename from sched/misc/coredump.h rename to include/nuttx/coredump.h index 32dc3a6c2c..8d2cf207a3 100644 --- a/sched/misc/coredump.h +++ b/include/nuttx/coredump.h @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/misc/coredump.h + * include/nuttx/coredump.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,19 +18,30 @@ * ****************************************************************************/ -#ifndef __SCHED_MISC_COREDUMP_H -#define __SCHED_MISC_COREDUMP_H +#ifndef __INCLUDE_NUTTX_COREDUMP_H +#define __INCLUDE_NUTTX_COREDUMP_H /**************************************************************************** * Included Files ****************************************************************************/ +#include #include /**************************************************************************** * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: coredump_set_memory_region + * + * Description: + * Set do coredump memory region. + * + ****************************************************************************/ + +int coredump_set_memory_region(FAR struct memory_region_s *region); + /**************************************************************************** * Name: coredump_initialize * @@ -55,4 +66,4 @@ int coredump_initialize(void); void coredump_dump(pid_t pid); -#endif /* __SCHED_MISC_COREDUMP_H */ +#endif /* __INCLUDE_NUTTX_COREDUMP_H */ diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c index 152dcc8ab2..1affea836e 100644 --- a/sched/init/nx_bringup.c +++ b/sched/init/nx_bringup.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -49,7 +50,6 @@ #include "sched/sched.h" #include "wqueue/wqueue.h" #include "init/init.h" -#include "misc/coredump.h" #ifdef CONFIG_ETC_ROMFS # include diff --git a/sched/misc/assert.c b/sched/misc/assert.c index fa9b8c8916..2500b0c2bb 100644 --- a/sched/misc/assert.c +++ b/sched/misc/assert.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -46,7 +47,6 @@ #include "irq/irq.h" #include "sched/sched.h" #include "group/group.h" -#include "misc/coredump.h" /**************************************************************************** * Pre-processor Definitions diff --git a/sched/misc/coredump.c b/sched/misc/coredump.c index 74c25fa9a3..c8c4f920db 100644 --- a/sched/misc/coredump.c +++ b/sched/misc/coredump.c @@ -23,11 +23,10 @@ ****************************************************************************/ #include +#include #include #include -#include "misc/coredump.h" - /**************************************************************************** * Private Data ****************************************************************************/ @@ -165,6 +164,22 @@ static void coredump_dump_blkdev(pid_t pid) } #endif +/**************************************************************************** + * Name: coredump_set_memory_region + * + * Description: + * Set do coredump memory region. + * + ****************************************************************************/ + +int coredump_set_memory_region(FAR struct memory_region_s *region) +{ + /* Not free g_regions, because allow call this fun when crash */ + + g_regions = region; + return 0; +} + /**************************************************************************** * Name: coredump_initialize * @@ -180,7 +195,8 @@ int coredump_initialize(void) if (CONFIG_BOARD_MEMORY_RANGE[0] != '\0') { - g_regions = alloc_memory_region(CONFIG_BOARD_MEMORY_RANGE); + coredump_set_memory_region( + alloc_memory_region(CONFIG_BOARD_MEMORY_RANGE)); if (g_regions == NULL) { _alert("Coredump memory region alloc fail\n");