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

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

Message

Simon Glass Jan. 3, 2026, 1:18 a.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%


Simon Glass (24):
  u_boot_pylib: command: Convert output before raising exception
  u_boot_pylib: tout: Add newline parameter to output functions
  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 80
  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 |  62 +++-
 drivers/video/stb_truetype.h     |  72 ++++-
 drivers/video/video-uclass.c     |  21 +-
 include/malloc.h                 | 102 +++++++
 include/mcheck.h                 |  11 +
 test/cmd/malloc.c                |  48 +++
 test/common/malloc.c             | 111 ++++++-
 test/dm/host.c                   |   4 +-
 test/py/conftest.py              |   7 +
 test/py/console_base.py          |  36 ++-
 test/py/console_sandbox.py       |   4 +
 tools/u_boot_pylib/command.py    |   3 +-
 tools/u_boot_pylib/tout.py       |  70 +++--
 29 files changed, 1264 insertions(+), 114 deletions(-)