From patchwork Sat Jan 3 01:18:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 84 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=1767403162; bh=JLXQQnjV4nsQDTJ5wAv1uEIXQOz6yj8PxDxyJBRz2Hk=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=ZAxpulxwkM2PKhuy1u2s0oRnluum5z3jnQ0WPFB7aeWN95e78VTiXhdNxsjhCaae2 hpyjlxjbtvrcpX5EKVq/PguSSEq0zF+5cmZRb6/w4s0bw42dX76qillu2zhdBhBhsb J4f3W8hThrAQWSaUF0DqPUnJtPMx8Ve+mEP1VafFx9cvmWWdzZ/1z9ZIPR8PxFCy/4 aFEvaU2rszbDgal0anVZonOlcJjmvdp/DGsaqQFSrJem3K6a/jRI7iwE64wiaO+wM0 DYfs/O2H4WZkemcY9JLFyaof8Wb2zKYqiy4fc/B9mqK/VMUIaMebO4FOMnZgRgTYmP vkYLzp5SC3/lg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C1CCE69052 for ; Fri, 2 Jan 2026 18:19:22 -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 YXbzcNSzq5H2 for ; Fri, 2 Jan 2026 18:19:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403162; bh=JLXQQnjV4nsQDTJ5wAv1uEIXQOz6yj8PxDxyJBRz2Hk=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=ZAxpulxwkM2PKhuy1u2s0oRnluum5z3jnQ0WPFB7aeWN95e78VTiXhdNxsjhCaae2 hpyjlxjbtvrcpX5EKVq/PguSSEq0zF+5cmZRb6/w4s0bw42dX76qillu2zhdBhBhsb J4f3W8hThrAQWSaUF0DqPUnJtPMx8Ve+mEP1VafFx9cvmWWdzZ/1z9ZIPR8PxFCy/4 aFEvaU2rszbDgal0anVZonOlcJjmvdp/DGsaqQFSrJem3K6a/jRI7iwE64wiaO+wM0 DYfs/O2H4WZkemcY9JLFyaof8Wb2zKYqiy4fc/B9mqK/VMUIaMebO4FOMnZgRgTYmP vkYLzp5SC3/lg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AEC2D6904D for ; Fri, 2 Jan 2026 18:19:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403160; bh=yk6obbYhE3UUeNIxXz1QaKOtrf9hyO8+jRW0tdwuIvM=; h=From:To:Cc:Subject:Date:From; b=IDQDM9X7oB1g87MkX1RH328hG+Z4Rmqg4MuTzSHDOgjyH57HPaAiUxKNJSxWzfJVI nYxiXeS+mh0Z36yusjwhNdD1NXXiTkBF4rgjpK4Y7qk+O87fHUi9tb3F6g456XQIpY 55Tw3KQIPY5jWlos9xURjPIF87aMdLg7PBtorqnaDreS+SaEGJqK6XxIp5dVc9AXup Eb9kb3JiptBx0PY031nnqqThvfDfaGyp6jFzWKkwcys/pv8EBUObL0VSgtPSPQ8lmi xnj7y9o3n/2KOH96COznitYtR/xX/XcplhjF9qw8HHlSKXBAWEPqqinE+zj2QN4xOo I7ejTPNMR6gtw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3243869034; Fri, 2 Jan 2026 18:19:20 -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 CN5h-Lp6GvWa; Fri, 2 Jan 2026 18:19:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403155; bh=f+NWjntEShyHGabETaFJ7Z+WM3lVS2fIi2nLumE/+oM=; h=From:To:Cc:Subject:Date:From; b=S1uAShKkj0l6xFP6zf20MVMYIrksQwIbGr3S5iTHMYGj/sTXnqv+RQBxINy0QSZAD NymYis3GZefm3P1FhzsCJpnGiQH/BfmZJZHdqaT3vaLIfLXlZAy6IEvnHSoDQmFeb6 Xf6007+0QLlZp5uzqridXZcEO5KkQ8cTpD1hTgTeRsPDWCo2QSzUQtj79CvTiyyrN5 uswojNZpX64WhAZMdArBt7A4Z9Z0D18l8SpNUmlRqd5NbfeFOAC1Yu0loXc2Nb3p4r BMsxIj4jMqeNqz7K7qVOTN7mEG+6slUDcx1EzeaPSQOajA+rZDjTASTdDwwMuvMAAM w54NPP+tHKADQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A65F468F5F; Fri, 2 Jan 2026 18:19:15 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 2 Jan 2026 18:18:36 -0700 Message-ID: <20260103011908.149445-1-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: 2P5O6BITSPDP2V7URQW4I3N6HCXVIMQS X-Message-ID-Hash: 2P5O6BITSPDP2V7URQW4I3N6HCXVIMQS 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 00/24] 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% 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(-)