Skip to content

Commit

Permalink
coredump: fix issue that nvic region overlapped by board memory region
Browse files Browse the repository at this point in the history
Firstly call arm_coredump_add_region in up_initialize to add nvic region, then call
coredump_set_memory_region to add board mem region, at this moment, an overlap occurs.

Signed-off-by: wanggang26 <[email protected]>
  • Loading branch information
gneworld authored and xiaoxiang781216 committed Jan 24, 2025
1 parent ba18502 commit f6b9a8f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
10 changes: 0 additions & 10 deletions include/nuttx/coredump.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ struct coredump_info_s
* Public Function Prototypes
****************************************************************************/

/****************************************************************************
* Name: coredump_set_memory_region
*
* Description:
* Set do coredump memory region.
*
****************************************************************************/

int coredump_set_memory_region(FAR const struct memory_region_s *region);

/****************************************************************************
* Name: coredump_add_memory_region
*
Expand Down
31 changes: 22 additions & 9 deletions sched/misc/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,19 +765,23 @@ static void coredump_dump_dev(pid_t pid)
#endif

/****************************************************************************
* Name: coredump_set_memory_region
* Name: coredump_initialize_memory_region
*
* Description:
* Set do coredump memory region.
* initialize the memory region with board memory range specified in config
*
****************************************************************************/

int coredump_set_memory_region(FAR const struct memory_region_s *region)
static int coredump_initialize_memory_region(void)
{
/* Not free g_regions, because allow call this fun when crash */
#ifdef CONFIG_BOARD_MEMORY_RANGE
if (g_regions == NULL)
{
g_regions = g_memory_region;
}
#endif

g_regions = region;
return 0;
return OK;
}

/****************************************************************************
Expand All @@ -793,6 +797,13 @@ int coredump_add_memory_region(FAR const void *ptr, size_t size,
{
FAR struct memory_region_s *region;
size_t count = 1; /* 1 for end flag */
int ret;

ret = coredump_initialize_memory_region();
if (ret < 0)
{
return ret;
}

if (g_regions != NULL)
{
Expand Down Expand Up @@ -881,9 +892,11 @@ int coredump_initialize(void)
{
int ret = 0;

#ifdef CONFIG_BOARD_MEMORY_RANGE
g_regions = g_memory_region;
#endif
ret = coredump_initialize_memory_region();
if (ret < 0)
{
return ret;
}

#ifdef CONFIG_BOARD_COREDUMP_BLKDEV
ret = lib_blkoutstream_open(&g_devstream,
Expand Down

0 comments on commit f6b9a8f

Please sign in to comment.