This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit c693b3064e8a6f93ceaa5435c1c058389b84b84f
Author: anjiahao <anjia...@xiaomi.com>
AuthorDate: Thu Sep 5 16:55:48 2024 +0800

    system/coredump:support coredump can save board memory
    
    Signed-off-by: anjiahao <anjia...@xiaomi.com>
---
 system/coredump/coredump.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/system/coredump/coredump.c b/system/coredump/coredump.c
index ba90d5ce6..bdcc6e05b 100644
--- a/system/coredump/coredump.c
+++ b/system/coredump/coredump.c
@@ -299,6 +299,7 @@ blkfd_err:
 
 static int coredump_now(int pid, FAR char *filename)
 {
+  FAR const struct memory_region_s *region;
   FAR struct lib_stdoutstream_s *outstream;
   FAR struct lib_hexdumpstream_s *hstream;
 #ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
@@ -351,8 +352,15 @@ static int coredump_now(int pid, FAR char *filename)
   /* Initialize hex output stream */
 
   lib_stdoutstream(outstream, file);
-  lib_hexdumpstream(hstream, (FAR void *)outstream);
-  stream = hstream;
+  if (file == stdout)
+    {
+      lib_hexdumpstream(hstream, (FAR void *)outstream);
+      stream = hstream;
+    }
+  else
+    {
+      stream = outstream;
+    }
 
 #ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
 
@@ -365,7 +373,8 @@ static int coredump_now(int pid, FAR char *filename)
 
   /* Do core dump */
 
-  coredump(NULL, stream, pid);
+  region = alloc_memory_region(CONFIG_BOARD_MEMORY_RANGE);
+  coredump(region, stream, pid);
   setlogmask(logmask);
 #  ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
   printf("Finish coredump (Compression Enabled).\n");
@@ -379,6 +388,11 @@ static int coredump_now(int pid, FAR char *filename)
       fclose(file);
     }
 
+  if (region != NULL)
+    {
+      free_memory_region(region);
+    }
+
   return 0;
 }
 

Reply via email to