From patchwork Sat Jan 3 20:04:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 85 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470733; bh=Pn1glkX7U00SfB49A70MXH7+oE+l5IsFGoRPdEfqXJk=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=J8y1cj/tTrzIjzVaBnv8zL3qNTV6AsLXvLg9WiY63FwIm+1aeEft9BvEProB3urvr kZkhsfwiQv1JHUs5pdnKjryG6rIoPqaBuvIrDRp3+36OQ/fge+n6ZkKIia8ru96kiu RGxQqRz1O2/3/ZOMeOnCCPfbpPZsVBcUO3Z30Ae7HkCo8JysJJJXt+GR7ztyhRVCFj YdDRNmo+LwWzK6ZA+FUk99+O5MRzj8RRLM7Kmj2whD9iBHvj5ubMMWpETI5rAvCoxx GLIfraYetJ87rvnJ58cKBzt8rc9/4Le440YX61yAx0ZXfyGEZv1TKspBK6+VIzlZMq vriivUykymEdw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 28F5E69090 for ; Sat, 3 Jan 2026 13:05:33 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id dk-3tm69VfTB for ; Sat, 3 Jan 2026 13:05:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470733; bh=Pn1glkX7U00SfB49A70MXH7+oE+l5IsFGoRPdEfqXJk=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=J8y1cj/tTrzIjzVaBnv8zL3qNTV6AsLXvLg9WiY63FwIm+1aeEft9BvEProB3urvr kZkhsfwiQv1JHUs5pdnKjryG6rIoPqaBuvIrDRp3+36OQ/fge+n6ZkKIia8ru96kiu RGxQqRz1O2/3/ZOMeOnCCPfbpPZsVBcUO3Z30Ae7HkCo8JysJJJXt+GR7ztyhRVCFj YdDRNmo+LwWzK6ZA+FUk99+O5MRzj8RRLM7Kmj2whD9iBHvj5ubMMWpETI5rAvCoxx GLIfraYetJ87rvnJ58cKBzt8rc9/4Le440YX61yAx0ZXfyGEZv1TKspBK6+VIzlZMq vriivUykymEdw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 170CA69060 for ; Sat, 3 Jan 2026 13:05:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470729; bh=jGB42LieuG8HTzJvLXvkf3PuXYANF17aNd/0IQCdyDg=; h=From:To:Cc:Subject:Date:From; b=jZxvwZxqoRGcwKPHpDmymcHgrukEwL8o4FZxxb95BnybJvZdxR3EyCveY2i1m9q3c qby5NCUe2P3k6ycJGpE7neREkkm//dlJPj30zaJPdyhxDlRpQN5bqzoQ5ZwTvjZelk lW36LJIb6ogujE/jyjA3aOihy3KLMtXxbwjuy+g9JwOaHALYJCMJ5gt6WuvpbpGROo g6OG2nnif2Rxn3Xy3mQZ5yQ9Kw1cvwD6KDmx7c+dA+hVm3V/R7yn2qz7A0YrzcqFdV Kyc51Zcry7V5ShPBVqGU8pXfGhJ2ORKrIHnoJx19rZZkddlV6GnDlAhR8ErABqA1OX Sy96Iy98953aA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7EC4F69060; Sat, 3 Jan 2026 13:05:29 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 557WCU7b7CR9; Sat, 3 Jan 2026 13:05:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470725; bh=cO5OSYW0UoS0C/AIV2L6XqqObVMOz6WtrZUQ9mvts7o=; h=From:To:Cc:Subject:Date:From; b=NrmkfvdTbSjKA2C+MRKhDUnIfAsi3s1QJFiLRjEE29hA7h655ytPKPyEjemRoriQe Kd+iVrVnVK0evGiRhS1+4mfnqXdx56dXJY3YVfBBBEcH6dNpbBGt2wmWvgjC1pMxSc cjMj5yJnwGnGp+NmDixVOR9NHjAsFAMoW6IXWe4DY3DL6vfmKYYkQ4IYb6NxbDsO67 d7MVbiSfwlp/5lduNcQV3wjRZawgTyjjW1fleZRAxCBuvZSyKoIh5EnnJMlWfuiGM6 1/oririCoqA6A6sbS7gdqEOBbTL4PLCcvPHrN9gk9G6jfbJ+xUKabJaSe/K2XRl5ME higu7XWZH4k2g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B07E168FCC; Sat, 3 Jan 2026 13:05:24 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 3 Jan 2026 13:04:31 -0700 Message-ID: <20260103200510.3605009-1-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: QYGCQOG2KMO5R5NAB5N7FRVYXTUI4AEY X-Message-ID-Hash: QYGCQOG2KMO5R5NAB5N7FRVYXTUI4AEY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 00/29] Malloc debugging and test/py improvements List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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(-)