From patchwork Mon Jan 19 20:40:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1633 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=1768855333; bh=YCtgCUzrgS7tq4O6FGZymxgx362aj+9AxnHejl4BhoQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=iA0lE6N49DpMKkUYuiyxE0sFwlH0qsMwqVVdxKoZJ+ahEPqKK1b0BTYJo7UGeuzk9 /FVHK122y3d6he1NMOoQLR19iyt8F58/KEZ1W6z7qg7pvxH2GEYzqO38+KFBfUp/TM ZC5kgkDvzcRjsKOmlJs/R+qPBNLlV3ZZlnIkSbTWrD+IO4mWCPj168/fwYfZdkZMDh 7PBYJ+frhfEnrVnXf3KuuKn2FOmeEGRQHGN/2E+o2czerk0tCHR26EO8Cr/GM8BmGK wiOFo4PlsYWeALTzhb5LjvjWgv+iw73lvW/Q0qK+J44TAu+fTsQPEpXl6m737gNTCF tgQWliqZTFcuA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BFD1469513 for ; Mon, 19 Jan 2026 13:42:13 -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 JgIbLUAijlI4 for ; Mon, 19 Jan 2026 13:42:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855333; bh=YCtgCUzrgS7tq4O6FGZymxgx362aj+9AxnHejl4BhoQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=iA0lE6N49DpMKkUYuiyxE0sFwlH0qsMwqVVdxKoZJ+ahEPqKK1b0BTYJo7UGeuzk9 /FVHK122y3d6he1NMOoQLR19iyt8F58/KEZ1W6z7qg7pvxH2GEYzqO38+KFBfUp/TM ZC5kgkDvzcRjsKOmlJs/R+qPBNLlV3ZZlnIkSbTWrD+IO4mWCPj168/fwYfZdkZMDh 7PBYJ+frhfEnrVnXf3KuuKn2FOmeEGRQHGN/2E+o2czerk0tCHR26EO8Cr/GM8BmGK wiOFo4PlsYWeALTzhb5LjvjWgv+iw73lvW/Q0qK+J44TAu+fTsQPEpXl6m737gNTCF tgQWliqZTFcuA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE11A694CE for ; Mon, 19 Jan 2026 13:42:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855331; bh=5C0ICCeblOCxV6DwFZK3s2C0S3lG4iiHEKKH51YKnXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HnFc2wFO+NpOA+m4HIN8VkRQ3knzE3FXnqKZHFECNvuQLm2XiTVU84wpXuLaNWUq6 yk9uMZn1GLH22U58XWtp0w3jabuBCpnuOuT3mv6EsrgPWk5WyvoTViT626JHH8Wfak i+NQ7CAsgic3OqStldvcitl/SWi22Jx81oAw68CrdGsTOtLQgpmW39jQMVfVhHHGL7 oT+Oqza9mARUwEfBhUWQsgik7iF+iJwzcRXuIcZ+50ufo1lOx2whm8Yc5i/DwTdwem oZxc0+hWx+CNXLnNu4a7wpN12PsKVug/GDuE6j2q+d+0wBQ2j3thwt3K5WIQk2ZDgY 6/jituEJjvQ4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3A352693E3; Mon, 19 Jan 2026 13:42:11 -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 oUt-PuOAXovJ; Mon, 19 Jan 2026 13:42:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855317; bh=cHHQ+7BtROgumH8aqOxXt1gAqGYCLdXY+Z4DLBtFh4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0c3Od5Q2f718B0NCgYDniUp8GWOCccbDCsVtGjjV6kzxhxPCa1HHCZMXoK+BwdJH 8N0BCVZeJ0DmsCcN9l2JlyhE+TrgceAGYhj4vfIQpiRg+zAqvnPvNgLWCErcS4qqVj p12fCkXSvrUCWaS7TGZSXi3AI+egWxNZ5asRIAXAYLNcZCQiBgMdscPLgo0j+GjsK4 JRkD+iH9PvV2mdiJI4tMvD03+KXOFnwQShq3PWJ4U4ovizBABTVHEGel3J3Z/M5IgG it43ctpRHwi1SEtBK577q7HUn31heZDtI+1QLCRGMKaz2be3VlDcxE/FAECfEvJDJw AXPqC4Qafg4rg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 41AE5694CE; Mon, 19 Jan 2026 13:41:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 19 Jan 2026 13:40:56 -0700 Message-ID: <20260119204130.3972647-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119204130.3972647-1-sjg@u-boot.org> References: <20260119204130.3972647-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: H4PABLHXJKCOLUG4YVPYIJISLGKFZUVN X-Message-ID-Hash: H4PABLHXJKCOLUG4YVPYIJISLGKFZUVN 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/27] proftool: Fix funcgraph depth for exit records 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 The funcgraph format requires entry and exit records for the same function to have matching depth values. Currently, exit records have their depth written before decrementing, causing trace-cmd to display incorrect or missing function exits. Move the depth decrement and stack handling to before writing the exit record. This ensures entry at depth N writes depth=N, and exit for the same function also writes depth=N. Fixes: b54d8cf0b5b8 ("trace: Support output of funcgraph records") Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/proftool.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/proftool.c b/tools/proftool.c index c7b427f3078..1f7df6d1973 100644 --- a/tools/proftool.c +++ b/tools/proftool.c @@ -1435,6 +1435,21 @@ static int write_pages(struct twriter *tw, enum out_format_t out_format, tw->ptr += tputq(fout, text_offset + caller_func->offset); } else { + ulong func_duration = 0; + + /* + * For funcgraph, entry and exit of a function must + * have the same depth. Decrement before writing the + * exit record. + */ + if (!entry) { + depth--; + if (stack_ptr && stack_ptr <= MAX_STACK_DEPTH) { + ulong start = func_stack[--stack_ptr]; + + func_duration = timestamp - start; + } + } tw->ptr += tputl(fout, rec_words | delta << 5); tw->ptr += tputh(fout, entry ? TRACE_GRAPH_ENT : TRACE_GRAPH_RET); @@ -1449,14 +1464,6 @@ static int write_pages(struct twriter *tw, enum out_format_t out_format, func_stack[stack_ptr] = timestamp; stack_ptr++; } else { - ulong func_duration = 0; - - depth--; - if (stack_ptr && stack_ptr <= MAX_STACK_DEPTH) { - ulong start = func_stack[--stack_ptr]; - - func_duration = timestamp - start; - } tw->ptr += tputl(fout, 0); /* overrun */ tw->ptr += tputq(fout, 0); /* calltime */ /* rettime (nanoseconds) */