[Concept,v2,00/29] Malloc debugging and test/py improvements

Message ID 20260103200510.3605009-1-sjg@u-boot.org
Headers
Series Malloc debugging and test/py improvements |

Message

Simon Glass Jan. 3, 2026, 8:04 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

This series adds malloc-debugging features including a traffic log and
file output for dumps, along with video optimisations and test/py
performance improvements.

The overall goal is to speed up pytests and make it easier to debug
memory leaks.

Changes include:
- Sandbox gprof profiling and mcheck runtime-disable support
- Video truetype scratch buffer to reduce malloc pressure
- Malloc traffic logging with 'malloc log' command
- File output for malloc dump and log
- test/py performance improvements reducing CPU usage by ~30%

(no changes since v1)

Simon Glass (29):
  u_boot_pylib: command: Convert output before raising exception
  u_boot_pylib: tout: Add newline parameter to output functions
  buildman: Fix IDE mode to show warnings
  video: Fix memory leak of vidconsole device name
  video: vidconsole: Free cursor save buffer on device removal
  video: truetype: Free allocated buffers on device removal
  test: nand: Free allocated buffers after test
  sandbox: Add gprof profiling support
  sandbox: Add -M option to disable mcheck at runtime
  Update Claude instructions for uman
  video: Update stb_truetype
  video: truetype: Add a scratch buffer to use malloc() less
  video: Optimise video_flush_copy() for full-line damage
  test: Rename dm_test_host()
  sandbox: Increase CONFIG_MCHECK_CALLER_LEN to 64
  malloc: Fix malloc_usable_size() to handle mcheck headers
  test: malloc: Account for mcheck overhead in the large test
  malloc: Refactor malloc_dump() to use output callback
  malloc: Add a log for malloc() traffic
  malloc: Add function to dump the malloc()-traffic log
  cmd: malloc: Add a command to show the malloc log
  malloc: Add an option to disable mcheck-backtrace collection
  malloc: Add file output for heap dump and malloc log
  doc: malloc: Add a section on finding memory leaks
  test/py: Handle a failure during configuration
  test/py: Reduce CPU usage when waiting for console output
  test/py: Speed up VT100-filtering in expect()
  test/py: Add an add option to skip flat-tree tests
  test/py: Add an option to disable the console timeout

 CLAUDE.md                         |  12 +-
 Kconfig                           |  32 ++
 arch/sandbox/config.mk            |   4 +
 arch/sandbox/cpu/start.c          |  13 +
 arch/sandbox/include/asm/state.h  |   1 +
 cmd/Kconfig                       |  10 +
 cmd/malloc.c                      |  41 ++-
 common/dlmalloc.c                 | 485 +++++++++++++++++++++++++++---
 config.mk                         |   4 +
 configs/sandbox_defconfig         |   1 +
 doc/arch/sandbox/sandbox.rst      |   7 +
 doc/develop/malloc.rst            | 115 +++++++
 doc/develop/trace.rst             |  40 +++
 doc/usage/cmd/font.rst            |   9 +
 doc/usage/cmd/malloc.rst          |  30 +-
 drivers/video/Kconfig             |  23 ++
 drivers/video/console_truetype.c  |  73 ++++-
 drivers/video/stb_truetype.h      |  72 ++++-
 drivers/video/vidconsole-uclass.c |  11 +
 drivers/video/video-uclass.c      |  23 +-
 include/malloc.h                  | 102 +++++++
 include/mcheck.h                  |  11 +
 test/cmd/malloc.c                 |  48 +++
 test/common/malloc.c              | 107 ++++++-
 test/dm/host.c                    |   4 +-
 test/dm/nand.c                    |   3 +
 test/py/conftest.py               |   7 +
 test/py/console_base.py           |  36 ++-
 test/py/console_sandbox.py        |   4 +
 tools/buildman/builder.py         |  14 +-
 tools/buildman/builderthread.py   |   4 +-
 tools/u_boot_pylib/command.py     |   3 +-
 tools/u_boot_pylib/tout.py        |  70 +++--
 33 files changed, 1299 insertions(+), 120 deletions(-)