huojianchaoyy opened a new pull request, #21788: URL: https://github.com/apache/nuttx/pull/21788
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary Two fixes for core dumps written to the syslog: - **sched/coredump: write a valid PID for the idle task**: GDB treats a process ID of 0 as invalid. For a core file it assigns an unused ID instead and warns `found thread with pid 0, assigned replacement Target Id`, and for the GDB stub 0 means "any thread". The NT_PRSTATUS note of the task with PID 0 now carries `PID0_REPLACE` (`INT32_MAX`), so the idle task of CPU 0 always gets the same, known ID and scripts that post-process the core file can rely on it. - **sched/coredump: print the end marker that tools/coredump.py expects**: since 10aad938345 ("coredump.py:synchronous coredump end flag"), `tools/coredump.py` looks for "Coredump finish" to find the end of a core dump in a log, but `coredump_dump_syslog()` and `coredump_dump_dev()` still print "Finish coredump". The script then takes the log lines after the dump as dump data and cannot convert a syslog core dump at all. The end marker is now "Coredump finish". ## Impact - Only the `pr_pid` of the NT_PRSTATUS note of the task with PID 0 changes. The TCB and the live system are not affected. - The end-of-dump line now reads "Coredump finish. hex formatted" (or "base64 formatted", or "Coredump finish, write N bytes to ..."). Anything that matched the old "Finish coredump" text has to match the new one; in tree that is only `tools/coredump.py`, which already does. - No API or Kconfig change. ## Testing Host: Ubuntu 22.04 x86_64, Arm GNU Toolchain 13.2.rel1, GCC 13.4.0 aarch64-none-elf, CMake 3.23 + Ninja, QEMU 6.2, gdb-multiarch. Base: master dc9481383ed. `./tools/checkpatch.sh -c -u -m -g HEAD~2..HEAD` passes. Builds: `mps2-an500:nsh` and `qemu-armv8a:nsh` with `CONFIG_COREDUMP=y CONFIG_BOARD_COREDUMP_SYSLOG=y`, `sim:nsh`. `mps2-an500:nsh` on QEMU with `CONFIG_COREDUMP=y CONFIG_BOARD_COREDUMP_SYSLOG=y CONFIG_DEBUG_SYMBOLS=y CONFIG_NSH_DISABLE_MW=n`; `mw 0xf0000000=1` takes a bus fault and writes the core dump to the console. Before, `tools/coredump.py` cannot convert the log: ``` $ python3 tools/coredump.py nsh.log -o nsh.core Found 18890 lines of coredump data Error: none hex or base64 content in nsh.log. ``` Converted by hand, the dump shows the idle task as "process 1" in GDB, next to hpwork, which really is PID 1: ``` [New LWP 3] [New process 1] [New LWP 1] ``` After: ``` $ python3 tools/coredump.py nsh.log -o nsh.core Found Coredump finish marker at 'coredump_dump_syslog: Coredump finish. hex formatted' Found 18872 lines of coredump data Core file conversion completed: nsh.core $ gdb-multiarch -q -batch -ex 'info threads' nuttx nsh.core [New LWP 3] [New LWP 2147483647] [New LWP 1] * 1 LWP 3 0x000322f0 in cmd_mw (vtbl=0x60006438, argc=2, argv=0x60008834) at apps/nshlib/nsh_dbgcmds.c:261 2 LWP 2147483647 __gnu_mcount_nc () at libs/libc/machine/arm/arch_mcount.S:52 3 LWP 1 nxsem_wait_slow (sem=0x600002f0 <g_hpwork+16>) at sched/semaphore/sem_wait.c:302 ``` -- 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]
