Skip to content

Commit

Permalink
coredump:coredump_set_memory_region to set memory region
Browse files Browse the repository at this point in the history
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
  • Loading branch information
anjiahao1 authored and xiaoxiang781216 committed Aug 11, 2024
1 parent 8d0d1f7 commit 2ff2b82
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
19 changes: 15 additions & 4 deletions sched/misc/coredump.h → include/nuttx/coredump.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 <nuttx/memoryregion.h>
#include <unistd.h>

/****************************************************************************
* 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
*
Expand All @@ -55,4 +66,4 @@ int coredump_initialize(void);

void coredump_dump(pid_t pid);

#endif /* __SCHED_MISC_COREDUMP_H */
#endif /* __INCLUDE_NUTTX_COREDUMP_H */
2 changes: 1 addition & 1 deletion sched/init/nx_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/coredump.h>
#include <nuttx/fs/fs.h>
#include <nuttx/init.h>
#include <nuttx/nuttx.h>
Expand All @@ -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 <nuttx/drivers/ramdisk.h>
Expand Down
2 changes: 1 addition & 1 deletion sched/misc/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/coredump.h>
#include <nuttx/irq.h>
#include <nuttx/tls.h>
#include <nuttx/signal.h>
Expand All @@ -46,7 +47,6 @@
#include "irq/irq.h"
#include "sched/sched.h"
#include "group/group.h"
#include "misc/coredump.h"

/****************************************************************************
* Pre-processor Definitions
Expand Down
22 changes: 19 additions & 3 deletions sched/misc/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
****************************************************************************/

#include <nuttx/binfmt/binfmt.h>
#include <nuttx/coredump.h>
#include <syslog.h>
#include <debug.h>

#include "misc/coredump.h"

/****************************************************************************
* Private Data
****************************************************************************/
Expand Down Expand Up @@ -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
*
Expand All @@ -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");
Expand Down

0 comments on commit 2ff2b82

Please sign in to comment.