This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 24464956e32944a5f3771b9122c0004b2e918abb Author: yangao1 <[email protected]> AuthorDate: Fri Jul 11 22:37:37 2025 +0800 sched/coredump: add an option to print the memory regions before dumping Add BOARD_COREDUMP_PRINT_REGIONS. When it is enabled, coredump_dump() logs the memory regions that go into the core dump (from BOARD_MEMORY_RANGE and coredump_add_memory_region()) before writing it, or a note when no region is defined: Memory regions will be printed: Region[0] start=0x900241ec, end=0x900241f4 Region[1] start=0x90024750, end=0x900249d0 This shows which ranges a dump is expected to hold. The option is off by default, as it only adds diagnostics and code size. Co-authored-by: xuxingliang <[email protected]> Co-authored-by: hujun5 <[email protected]> Signed-off-by: yangao1 <[email protected]> Signed-off-by: xuxingliang <[email protected]> Signed-off-by: hujun5 <[email protected]> --- Documentation/debugging/coredump.rst | 3 +++ boards/Kconfig | 10 ++++++++++ sched/misc/coredump.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/Documentation/debugging/coredump.rst b/Documentation/debugging/coredump.rst index 9b68c755cc0..1573d604351 100644 --- a/Documentation/debugging/coredump.rst +++ b/Documentation/debugging/coredump.rst @@ -29,6 +29,9 @@ Enable Kconfig CONFIG_BOARD_COREDUMP_FULL=y /* Default y, save all task information */ +Set ``CONFIG_BOARD_COREDUMP_PRINT_REGIONS=y`` to log the memory regions that +go into the core dump before it is written. + 2. Run Coredump on nsh (CONFIG_SYSTEM_COREDUMP=y) Parameters of coredump tool diff --git a/boards/Kconfig b/boards/Kconfig index 99574af6b65..075b599fe1a 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -5955,6 +5955,16 @@ config BOARD_COREDUMP_BASE64STREAM ---help--- Enable based64 encoded stream instead of default hexstream. +config BOARD_COREDUMP_PRINT_REGIONS + bool "Print memory regions before core dump" + default n + depends on COREDUMP && DEBUG_ALERT + ---help--- + Print the list of memory regions that will be dumped to the + syslog before the core dump is generated. This is only a + diagnostic aid and is not required for a valid core dump, so it + is disabled by default to save code size. + config BOARD_ENTROPY_POOL bool "Enable Board level storing of entropy pool structure" default n diff --git a/sched/misc/coredump.c b/sched/misc/coredump.c index 5a0e2a22aa8..83d86b1ed81 100644 --- a/sched/misc/coredump.c +++ b/sched/misc/coredump.c @@ -711,6 +711,35 @@ static void elf_emit_phdr(FAR struct elf_dumpinfo_s *cinfo, elf_emit(cinfo, &phdr, sizeof(phdr)); } +/**************************************************************************** + * Name: coredump_print_memory_regions + * + * Description: + * Print out the memory range when coredump is generated. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_COREDUMP_PRINT_REGIONS +static void +coredump_print_memory_regions(FAR const struct memory_region_s *regions) +{ + int i; + + if (regions == NULL) + { + _alert("No memory regions defined.\n"); + return; + } + + _alert("Memory regions will be printed:\n"); + for (i = 0; regions[i].start < regions[i].end; i++) + { + _alert("Region[%d] start=0x%" PRIxPTR ", end=0x%" PRIxPTR "\n", + i, regions[i].start, regions[i].end); + } +} +#endif + /**************************************************************************** * Name: coredump_dump_syslog * @@ -970,6 +999,10 @@ int coredump_initialize(void) void coredump_dump(pid_t pid) { +#ifdef CONFIG_BOARD_COREDUMP_PRINT_REGIONS + coredump_print_memory_regions(g_regions); +#endif + #ifdef CONFIG_BOARD_COREDUMP_SYSLOG coredump_dump_syslog(pid); #endif
