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 50fc54e7e9e5ec9d84fb24bb260ad317ef243753
Author: xuxingliang <[email protected]>
AuthorDate: Fri Nov 21 10:56:49 2025 +0800

    tools/coredump: fix unicode decode error
    
    
    Need to ignore decode errors in files and continue to parse next line, 
instead of exit directly.
    Added log to make it easier to debug.
    
    Signed-off-by: xuxingliang <[email protected]>
---
 tools/coredump.py | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/tools/coredump.py b/tools/coredump.py
index e858b054444..7763af24eff 100755
--- a/tools/coredump.py
+++ b/tools/coredump.py
@@ -46,26 +46,28 @@ def try_extract(filepath) -> io.BytesIO:
     in_coredump = False
     bas64 = False
     coredump = []
-    with open(filepath, "r") as f:
-        try:
-            for line in f.readlines():
-                if "Start coredump" in line:
-                    in_coredump = True
-                    if coredump:
-                        print("Warning: multiple core dump found.")
-                        break
-                elif "Finish coredump" in line:
-                    bas64 = "base64 formatted" in line
-                    in_coredump = False
-                elif in_coredump:
-                    index = line.rfind(" ")
-                    if index > 0:
-                        line = line[index + 1 :]
-                    line = line.rstrip("\n\r")
-                    if line:
-                        coredump += line
-        except (UnicodeDecodeError, UnicodeError):
-            pass
+    with open(filepath, "r", errors="ignore") as f:
+        for line in f.readlines():
+            line = line.rstrip("\n\r")
+            if "Start coredump" in line:
+                in_coredump = True
+                print(f"Found coredump start marker at '{line}'")
+                if coredump:
+                    print("Warning: multiple core dump found.")
+                    break
+            elif "Finish coredump" in line:
+                bas64 = "base64 formatted" in line
+                line = line.strip("\n\r")
+                print(f"Found finish coredump marker at '{line}'")
+                in_coredump = False
+            elif in_coredump:
+                index = line.rfind(" ")
+                if index > 0:
+                    line = line[index + 1 :]
+                if line:
+                    coredump += line
+
+    print(f"Found {len(coredump)} lines of coredump data")
 
     try:
         return coredump and io.BytesIO(

Reply via email to