jingfei195887 opened a new pull request, #20690:
URL: https://github.com/apache/nuttx/pull/20690

   ## Summary
   
   Related to the footprint discussion in #20414. Two small changes in
   `sched/misc/coredump.c`:
   
   1. **Mark `elf_emit()` and `elf_emit_align()` `noinline_function`.** They are
      called from every part of the dump (ELF header, program headers, notes,
      stacks, memory regions). At `-O2` GCC inlines them into each caller. The
      crash path is not performance sensitive, so one shared copy is enough.
   2. **Look up the dumped task's TCB once.** When a single task is dumped
      (`pid != INVALID_PROCESS_ID`), `coredump()` already looks up the TCB to
      validate the PID, and then `elf_emit_phdr()`, `elf_emit_note()` and
      `elf_emit_stack()` each look it up again. The TCB is now kept in
      `elf_dumpinfo_s` and reused. The whole dump runs inside one critical
      section, so the TCB cannot go away in between.
   
   ## Impact
   
   No functional change. The dump format and content are unchanged.
   
   ## Testing
   
   Host: Ubuntu x86_64, arm-none-eabi-gcc 10.3.1 20210621, master 7d65bf6dde,
   clean CMake builds. Flash = text + data.
   
   | build | master | this PR | delta |
   |---|---:|---:|---:|
   | `stm32f103-minimum:nsh` + `COREDUMP` + `BOARD_COREDUMP_SYSLOG`, `-Os` | 
54199 | 54191 | **-8** |
   | same, `-O2` | 62095 | 61887 | **-208** |
   | `sabre-6quad:coredump` (SMP, `-Os`) | 199088 | 199088 | 0 |
   
   Runtime: `qemu-armv7a:nsh` with `COREDUMP`, `BOARD_COREDUMP_SYSLOG` and
   `SYSTEM_COREDUMP`, master and this PR side by side. `coredump -p 0`,
   `coredump -p 99` (no such task) and `coredump` (all tasks) behave the same
   in both builds: each prints `Start coredump` / `Finish coredump`, the dumps
   have the same number of lines and the leading lines are identical, with no
   assertion or abort.
   
   `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
   
   Not tested on 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]

Reply via email to