huojianchaoyy opened a new pull request, #4122: URL: https://github.com/apache/nuttx-apps/pull/4122
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary coredump and dumpstack fixes from Xiaomi Vela. - **[stability]:Fixed bug that validity of coredump**: `dumpfile_is_valid()` returned true for the files that do *not* end with the core file suffix, so `coredump -s` counted the other files of the save path against `-m` and removed them, and never removed the old core files. - **system/coredump: fix core file size mismatch**: the restore reads exactly the size recorded in the core info instead of whole swap buffers. - **coredump: fix coverity warning**: `strncmp()` on the note name, which is not NUL-terminated if the device holds garbage. - **dumpstack: use printf instead of syslog for backtrace output**: `dumpstack` prints the backtraces with `printf()` (`sched_backtrace()` + `backtrace_format()`), so they can be redirected. - **apps/coredump:Unify finish marker to "Coredump finish"**: `coredump` prints "Coredump finish." like `sched/misc/coredump.c`, the marker that `tools/coredump.py` looks for. One commit first: **system/coredump: align the nhdr initializer as nxstyle wants**. nxstyle does not take `Elf_Nhdr` for a type and reports the braces of the `nhdr` initializer in `coredump_restore()`; the check runs on the whole of `coredump.c`, which this PR touches. ## Impact - `coredump -s <savepath>` no longer removes the files of the save path that are not core files. - `dumpstack` writes to stdout instead of syslog, as `backtrace|<pid>: <addresses>`. - The last line of `coredump` is "Coredump finish." instead of "Finish coredump.". ## Testing Host: Ubuntu 22.04 x86_64, GCC 13.4.0 (sim), Arm GNU Toolchain 13.2.rel1, CMake 3.23 + Ninja 1.10, QEMU 10.2.1. nuttx master c8907860837, apps base 8ff87439bf4. `./tools/checkpatch.sh -c -u -m -g HEAD~6..HEAD` (nuttx master's) passes. Builds: `qemu-armv7a:nsh` with `COREDUMP`, `SYSTEM_COREDUMP`, `SYSTEM_COREDUMP_RESTORE`, `SCHED_BACKTRACE` and `SYSTEM_DUMPSTACK` (CMake and Make); `sim:nsh` with `SCHED_BACKTRACE` and `SYSTEM_DUMPSTACK`. No new warning. `sim:nsh`, `dumpstack 1`: ``` before: sched_dumpstack: backtrace| 1: 0x0000000040031a5e (syslog) after: backtrace|1: 0x0000000040031a8c (stdout) ``` `qemu-armv7a:nsh`, `coredump -p 1`: the hex dump ends with "Finish coredump." before and "Coredump finish." after. Not tested: the restore from a block device (`coredump -s`), real hardware. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
