From patchwork Fri Dec 13 12:45:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 850120 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp1476712wry; Fri, 13 Dec 2024 04:46:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUkhYnxNlkn6EA4QXOdyzGEtzCXNWiG8hpmFeRN7xdcRG/tccnl7GJ+/1LUMoNYN8WeT3WV2g==@linaro.org X-Google-Smtp-Source: AGHT+IE0HzuSngVEzh6KXT+THHBOs0iO20BI5oASCJZXq1t0lo4OV/yhcc+i2CTuuUwNPG/1C+Ex X-Received: by 2002:a17:907:2d1e:b0:aa6:832b:8d76 with SMTP id a640c23a62f3a-aab778bf03cmr222656566b.12.1734093976259; Fri, 13 Dec 2024 04:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734093976; cv=none; d=google.com; s=arc-20240605; b=Qj4Z9t4duX1/2Nrediws69aFQv+tYSyGZBGPTzUXp59n1Po5f5+8gr/s/2vU25fPCP n1PyHnNtCGE4D9wWmlbQVdIFAxDEsYmLcnvmqlZjIPORprvsQCw35BZE5eQn5HUgEc0Z uGVS2blj5/V9C0BcEZFZhRANZDQhDUsHBcZ4QQzFVvv733yUR++1YCgMbiFdsfRmWNqr IdLeCYi8VvktIoQe1SGQ1EtIBgDLtxeiGHq/+WMhFvueu87oDKcWIzSqAGCTTJ0DhBxr Dc0R4TH4xfp2HF1bEppEYdRFYT45Y9QOP+7UQl4dzcqYIvuN1Kko0isv6hI0HBu5a7XJ LWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=boCSn63MQk4H2nOFl/fq2eo2ButnEUWv4XSM+n6NXi0=; fh=WT3jtk3at6WmKReA45F3Pjm/eW8LbZQ48Fvog3PFe6s=; b=J2RAmh6T6aIvawq8vgKaO0+acB4zi62WQ4h+yvQtBZi/NGOdKiROj1elCKkqDMB9+l hwg5gBA5faPtjHPbe1zRKkTjk9bLvDQ32jMyafc9bozl4vJey2NvMtuto1KoWs8pQ0fC po4FMFQfhuikpPStvb6412BMa5CFr895C+1uxwyCf+6JVkSbK9fsJLL42mt1tACGAYNq 5QYZKlCkfMNz2iE9YxJvynKn7zyE8Raqy8at23YYGVO2WPumiF5U6rBTCmzdSEfoBiin 5HAlx9zg7sYoxbkk3Us6VrloPsjAPIGQCpNMJp0F+7HbjImcFTKHbEMY6ZXy7V/64x+7 5pbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kG7/zT3g"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-aa626141a14si1328468266b.604.2024.12.13.04.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 04:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kG7/zT3g"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E7E7A80214; Fri, 13 Dec 2024 13:46:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kG7/zT3g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 958DC801E7; Fri, 13 Dec 2024 13:46:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 83D0680137 for ; Fri, 13 Dec 2024 13:46:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-385df53e559so1358132f8f.3 for ; Fri, 13 Dec 2024 04:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734093962; x=1734698762; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=boCSn63MQk4H2nOFl/fq2eo2ButnEUWv4XSM+n6NXi0=; b=kG7/zT3g0bbKlpEtAlSC/yOJaFnD5Nd70sRpQ5+4smwoVVbnsZ7bX3xZ0jQuaooBoZ 6VxJ1j9ef8tnrEye7QOD7DiyRG/coPORbplK5XPMXHavjTOsW24/Tzg4+l3K53k2f9tI TMqPlGTjuuy/GH6+uogSdm1jivl5SrYIjKXU572NaeXxW8/G9fDQjQarPYzahskgo9bw +zMl9j5lNqaNZFpVxoTLgGQSLDRE9QHssn7+UifTYwz3sZDRmci7LUCjjRGaFp8CXmfd ht1mQ4xIoQ52h000N9CVvjAHrEpkr0vjW4hgjaYwv1mokn3VSgOuROmJLZPQ/pkT2zHF A52w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734093962; x=1734698762; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=boCSn63MQk4H2nOFl/fq2eo2ButnEUWv4XSM+n6NXi0=; b=Ytlb70sQW9whw2H0IqYToN/KE8yLeiPRHJA7ckWqZVk/T75/5m0wvDihtQdLJ5xNhY msbyRX1HzjCW7WYDVRexYnV91JVtfkyKtSf/FjOZ9X+yj2eqPm4FfKkH7GRKuTg5rum7 6nw/Zi8OpT7qb+HS7D/ULT773re382ecf1+ynRsgHZJ2WjJuq/Wi/CZhsY+TfBLXAGf3 B6YvzuULjk5pZxx58j0dmpGYSyo1piEPTRN0Z0PBnjvbQ2vVHC4QF/pSd2rRUKLAYJkA z/3VLrnK1uYVU6qZPnS/qp0Ca8DRQo9UZdmOCkkOK58SxBeDrzSsSbhwfal6VE11sEu/ Fkow== X-Gm-Message-State: AOJu0YzJKbZvqWafnfgkmlVYSIPu5niprh+6GhG3fMeoAEC3PsLC8sF5 SoN2y57j0s6rM6fM2EwDJmLUEGM0yCd5eateUv9TQub2CQQu5Ls0xxDxOKw1Mm2RrcOXxwVtb8K tYvg= X-Gm-Gg: ASbGnctG5J8Ch2nHMNgsp4OIm9DFMdzv9OrpX1TTtRlUn1PxsPtZsCJv6WDsKGMdgPK Epk7nUcs9+qZccE8xlw8HiUmQAux5NsDyRzTYyE6rWPnoiZFHt65cKYJYwRwiDpvd7vPTulu6x8 0iQQCAIZiSeiA2hj66KCZhhMO9OKYuA13++hYcnXPlqreqo4pBj7EieF+vJa183cdta8VGu20qe 2Ry93f5CrhY6/jHPLQ/692luRSVkaq09h+O40EeKbyHshr48ijJ+GJuXrNaVroJtQ== X-Received: by 2002:a05:6000:18ac:b0:386:1cd3:8a08 with SMTP id ffacd0b85a97d-38880af13edmr1875798f8f.5.1734093961740; Fri, 13 Dec 2024 04:46:01 -0800 (PST) Received: from builder.. ([2a01:e0a:3cb:7bb0:3390:8f2f:2eb7:90a7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3878248e54dsm7050988f8f.19.2024.12.13.04.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 04:46:01 -0800 (PST) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Tom Rini , Simon Glass , Jerome Forissier Subject: [PATCH v2 1/3] trace: add support for 'trace wipe' Date: Fri, 13 Dec 2024 13:45:36 +0100 Message-ID: <8d7a88c7d11d820527d4909557a2af25be53fbbc.1734093566.git.jerome.forissier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement a 'trace wipe' command to delete the currently accumulated trace data. This comes handy when someone needs to trace a particular command. For example: => trace pause; trace wipe => trace resume; dhcp; trace pause => trace stats => trace calls 0x02100000 0x10000000 => tftpput $profbase $profoffset 192.168.0.16:trace.bin Signed-off-by: Jerome Forissier Reviewed-by: Ilias Apalodimas --- cmd/trace.c | 5 +++++ include/trace.h | 2 ++ lib/trace.c | 47 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/cmd/trace.c b/cmd/trace.c index 937e6a682ad..d36008720db 100644 --- a/cmd/trace.c +++ b/cmd/trace.c @@ -100,6 +100,10 @@ int do_trace(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) case 's': trace_print_stats(); break; + case 'w': + if (trace_wipe()) + return CMD_RET_FAILURE; + break; default: return CMD_RET_USAGE; } @@ -113,6 +117,7 @@ U_BOOT_CMD( "stats - display tracing statistics\n" "trace pause - pause tracing\n" "trace resume - resume tracing\n" + "trace wipe - wipe traces\n" "trace funclist [ ] - dump function list into buffer\n" "trace calls [ ] " "- dump function call trace into buffer" diff --git a/include/trace.h b/include/trace.h index 763d6d1255a..782eaae2fc2 100644 --- a/include/trace.h +++ b/include/trace.h @@ -100,6 +100,8 @@ void trace_set_enabled(int enabled); int trace_early_init(void); +int trace_clear(void); + /** * Init the trace system * diff --git a/lib/trace.c b/lib/trace.c index cabbe47b58a..def9f912c92 100644 --- a/lib/trace.c +++ b/lib/trace.c @@ -351,14 +351,8 @@ static int get_func_count(void) return gd->mon_len / FUNC_SITE_SIZE; } -/** - * trace_init() - initialize the tracing system and enable it - * - * @buff: Pointer to trace buffer - * @buff_size: Size of trace buffer - * Return: 0 if ok - */ -int notrace trace_init(void *buff, size_t buff_size) +static int notrace trace_init_(void *buff, size_t buff_size, bool copy_early, + bool enable) { int func_count = get_func_count(); size_t needed; @@ -368,7 +362,7 @@ int notrace trace_init(void *buff, size_t buff_size) return func_count; trace_save_gd(); - if (!was_disabled) { + if (copy_early) { #ifdef CONFIG_TRACE_EARLY ulong used, count; char *end; @@ -394,9 +388,6 @@ int notrace trace_init(void *buff, size_t buff_size) } puts("\n"); memcpy(buff, hdr, used); -#else - puts("trace: already enabled\n"); - return -EALREADY; #endif } hdr = (struct trace_hdr *)buff; @@ -419,13 +410,41 @@ int notrace trace_init(void *buff, size_t buff_size) hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace); hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT; - puts("trace: enabled\n"); - trace_enabled = 1; + printf("trace: initialized, %senabled\n", enable ? "" : "not "); + trace_enabled = enable; trace_inited = 1; return 0; } +/** + * trace_init() - initialize the tracing system and enable it + * + * @buff: Pointer to trace buffer + * @buff_size: Size of trace buffer + * Return: 0 if ok + */ +int notrace trace_init(void *buff, size_t buff_size) +{ + /* If traces are enabled already, we may have early traces to copy */ + return trace_init_(buff, buff_size, trace_enabled, true); +} + +/** + * trace_clear() - clear accumulated traced data + * + * May be called with tracing enabled or disabled. + */ +int notrace trace_clear(void) +{ + bool was_enabled = trace_enabled; + + if (trace_enabled) + trace_enabled = 0; + return trace_init_(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE, + false, was_enabled); +} + #ifdef CONFIG_TRACE_EARLY /** * trace_early_init() - initialize the tracing system for early tracing From patchwork Fri Dec 13 12:45:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 850121 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp1476780wry; Fri, 13 Dec 2024 04:46:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWk8Vnpcv8F6BfVKEr79E5mf6vsPtQtYC/p5BopmMlfAujAVSW/iBevXjVxyhhi65KoP0IZ+w==@linaro.org X-Google-Smtp-Source: AGHT+IHg0JF3Q4ww4Xvy3gu6NMCqIxSGggptkF7lCt5AeSsq2GRWjbqJIpJx4L117dqiP5JWp71q X-Received: by 2002:a17:907:1c1a:b0:aa6:9540:5714 with SMTP id a640c23a62f3a-aa6c427589emr548397766b.25.1734093985423; Fri, 13 Dec 2024 04:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734093985; cv=none; d=google.com; s=arc-20240605; b=kubthatR9ccIHJl+jOsFT3rzyoh3uO1wPPzHJMvtzzY7FBRtrD6BT1eDWQFwhN8aUw +Qe9qEgr1BYULrtALoqnsuA/LH9TcrzzAbRpWamNWV6wyxKToXQpVSBcIQZmr6C6+U1x C/c/8AQ03kbDFNZTGlLWBum15E0iDrrsRSukLeTCqacOGxZyKWG+JuRdIeWnPuHQPA6N 6siZM2X8+/LY0FIHlIj6wPiZ6Yb4xU+9l8rETIGysos0O/WSVpb2Hw8/NKQRxdQ9FvZW QAM3xTqVKZbzn7+e6ghaAyiC5lyzjnKfHCT5e/RYwhzJ8bT9vO3w/nu0034oMtJQb61d 34gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s11seQ0nBLmcmLQyb1bjkuKWamubsNqeB+LsSfF85K8=; fh=Ab4BXxZ8dAoub0u38NNan+YNb/8M1XUTG00P6IJB64E=; b=XhRYkbD0UrhWvcICRpzKpltCrXATXFRMdjcy8VXUV055PKp8Yo58icguHEi0zLuJyp uw1eccChVSTudeoBf3PAuStNJ6hIYs45pll3UftX9yw6pj7OqH9aCfnYn8j7Kf/XxIRw pnvS41RQT04N1g670hhGcNW7NCONZDUulGFwZiOS4OaVidOkgHjR2meirNCiHTaluEZi Ia0/aJ9v5IKtswKgU2RTBXAHTK1NALKddSdTptb6RhBpZUX0rIduCbbU+DZCCyrqF6tZ T2a6RKhK81oUFExtZOKrgv4mnrJrusGNCMew0ajYPbBZtVEpnh4qC5F8yr/JjbomS8wM MVQA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YEfj2VGF; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-aa67f8a73c0si804357066b.890.2024.12.13.04.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 04:46:25 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YEfj2VGF; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 61D9A8012C; Fri, 13 Dec 2024 13:46:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YEfj2VGF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EC284801BF; Fri, 13 Dec 2024 13:46:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 70113801BF for ; Fri, 13 Dec 2024 13:46:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4361b6f9faeso10635215e9.1 for ; Fri, 13 Dec 2024 04:46:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734093963; x=1734698763; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s11seQ0nBLmcmLQyb1bjkuKWamubsNqeB+LsSfF85K8=; b=YEfj2VGFpK7DksECl1rNC0wlA2vW9++Ru91vij2HAzVKhccZdDMKpg/Yy4b+MFD82q +54hTvFlX1V3zZO1QiHBMSGBh7yWf92czeVU6SajlLiNXScM2ST5U8mlVyPKbb5y+/iq SskAU40YC8qQ+r7dCl07qcBSOOJcIrxTMPRKfZsohlNoVcsHqw3/uss9b5sMNXQPUOLo A/XnG2836GTKzsWfDCBluCdQbmhvzJX9Xayz+xftdsTcuL9qCE0dniumOetjNuuQjE/o ygodtN+jsAT0LIinPopcxAzaMantITDiiE/63c8+aQ4Occnz8KJdFYBVhEayeSIlyB+a MzBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734093963; x=1734698763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s11seQ0nBLmcmLQyb1bjkuKWamubsNqeB+LsSfF85K8=; b=tXDlXVOfI+mgT99ujbDitFm6EW7ui+KWzCWzHQ5llSbCFtZVJ55cNh4zXCECe0QE7F Fs41gbkHzmdU7X2WTqwmJ7IeSj0QfMO1BvgbPSmRy0Fx2IuZgYX99PCGQmHtpdQa07Au DDZ8Rz6QJdO4VlsxVzKNcUSlMN6hbPaiCyWTP8M2aWZkHALgO252Uap+1GGiqlyOJnu6 egiFRH+AGJXGwCD/93lwH6qd8hb/eI1Zciw360/y6oupX8VFEZXVl5ruJMPCbM9HVXjG OJNqNSXtZlr4LMMkBDfElXjkAGWJSMsFWrrkIoqyja/J4BAe9Q+OLSALqtEKA2itTciY L+Iw== X-Gm-Message-State: AOJu0Yyn2SO+2rURvTOmpzImO1alPN825Ajze6nQVLGpvcOf44GsXnro gpoQaKsOMk6MUTUWiS4pFnWeTcYGT/g+pgGeeajCL4SrNbuPlDgOwMw8kfKomP1pnsxHGv7R3MY VmQ4= X-Gm-Gg: ASbGncv7/+oqliZ+u59epDEJPPoWWeEmV7D9vHS6PP17I6yGg/LRN7r+LrPiOHjaPiz R0xUQ+Z3LdZdPTZuqr3aqmqPL480Z7ekuNZF2wQohsKFAR9UYyvzgjoD6iczP1R+LDgHbI0KQQO TAhFXJf6GgnfcHlXDPE/+AUuOnV0+DdHuPO5V2V8LJxQ7GAgFIJnqjqiozXSdyr8/gXbjGVmyEZ 4WqO42UPinMwUWigq6MOJjrR3BNk6CMvcS3UeuKaiF6oaONQsE08s4SkL7g/hTx2Q== X-Received: by 2002:a05:600c:1c19:b0:434:f2af:6e74 with SMTP id 5b1f17b1804b1-4362b16beb1mr17913255e9.15.1734093962706; Fri, 13 Dec 2024 04:46:02 -0800 (PST) Received: from builder.. ([2a01:e0a:3cb:7bb0:3390:8f2f:2eb7:90a7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3878248e54dsm7050988f8f.19.2024.12.13.04.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 04:46:02 -0800 (PST) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Tom Rini , Simon Glass , Jerome Forissier , Caleb Connolly Subject: [PATCH v2 2/3] test: test_trace.py: test 'trace wipe' Date: Fri, 13 Dec 2024 13:45:37 +0100 Message-ID: <0e06e3326cc28d8a88eb3f88fa9dccf4bab5bede.1734093566.git.jerome.forissier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Test the newly added 'trace wipe' command. Signed-off-by: Jerome Forissier Acked-by: Ilias Apalodimas --- test/py/tests/test_trace.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py index ec1e624722c..44239da5280 100644 --- a/test/py/tests/test_trace.py +++ b/test/py/tests/test_trace.py @@ -70,6 +70,32 @@ def collect_trace(cons): return fname, int(dm_f_time[0]) +def wipe_and_collect_trace(cons): + """Pause and wipe traces, return the number of calls (should be zero) + + Args: + cons (ConsoleBase): U-Boot console + + Returns: + int: the number of traced function calls reported by 'trace stats' + """ + cons.run_command('trace pause') + cons.run_command('trace wipe') + out = cons.run_command('trace stats') + + # The output is something like this: + # 117,221 function sites + # 0 function calls + # 0 untracked function calls + # 0 traced function calls + + # Get a dict of values from the output + lines = [line.split(maxsplit=1) for line in out.splitlines() if line] + vals = {key: val.replace(',', '') for val, key in lines} + + return int(vals['traced function calls']) + + def check_function(cons, fname, proftool, map_fname, trace_dat): """Check that the 'function' output works @@ -304,3 +330,7 @@ def test_trace(u_boot_console): # This allows for CI being slow to run diff = abs(fg_time - dm_f_time) assert diff / dm_f_time < 0.3 + + # Check that the trace buffer can be wiped + numcalls = wipe_and_collect_trace(cons) + assert numcalls == 0 From patchwork Fri Dec 13 12:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 850122 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp1476889wry; Fri, 13 Dec 2024 04:46:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU3OW4EGyhtDSfeXk1+8Tpc4Fu8nfIx9VJmrQF30Z1Mq5lM3pZpZ97QrNYKZMj9uLu2ZoqGjg==@linaro.org X-Google-Smtp-Source: AGHT+IH61IN/zLVw5lMP9ENLGPpeAdH7yHXt9A6BlPx/SFGuayxzN99NURU6vVrGA1XJbRANuTIh X-Received: by 2002:a17:906:2931:b0:aa6:85d0:1486 with SMTP id a640c23a62f3a-aab77ee9688mr212581466b.54.1734093998657; Fri, 13 Dec 2024 04:46:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734093998; cv=none; d=google.com; s=arc-20240605; b=XWFmDydzqFJvswx5xK8s1lNnd2VhgPwXYEKJDVRkSbDnbvs8AOIIj58IWio7dL25Jg t3z5POp9iANArbQSV91yjDSoMyTX/di1ta2Tw3PK19GbRzBbmAGyu4t6BkezP+K5LPky wn1f1BWMyTcLYLS2Xgu3PYLBOOtjvrnY94LgR0hlzhdBHbgC/ZawVwA22fbQ9nLk9Bza j7INmvd0yTTFFOsRQteiDVw+TnOxUFPe1F+o59EAyS+JHptjVyt8XB977E4yCQOJIZ+g rAT7larKRQpCPEIk7dEdlhxfHoDT4Lbw8Q32icLctz51k3TJtffcWHGuoe4h+oWm/UJo fLFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FemKKIYzALdLpYA70zP6qxDBZOd7zFXuN0pcldeuz44=; fh=WT3jtk3at6WmKReA45F3Pjm/eW8LbZQ48Fvog3PFe6s=; b=ByUmoJKSDDJ14CxqLBFnphBJAelLNyy/yyKjH2DdN8eHACz/1iAwQn3wtriaVJHjpE zK3DBjwK1BvfNKw33Ii79wnjLUfngrCtYBjarEgLXIWptITa1Uj0rqwk162rlM111RnQ HM6A0yCFrIkR1HBpjA7KQKec3+at6Jb79poVCJ6NUnundSjHO1XE55IkgSe6OyVjgrb3 Wetx1wGX9iwjAa9yoi4HLERipoCOK4ngco0VMfdQmuHqdg/2WWzdVKjo+ja4Pt0F1cUT g6JoDzkwFmj2hYcOCAl4MO+LRlTefWjIUJfpgMcqTSp1LlEo9yiYrXoYLDERa7xNGJgH lvcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YoMHb8zm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-aa6559ac872si948656566b.67.2024.12.13.04.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 04:46:38 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YoMHb8zm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8B4E80224; Fri, 13 Dec 2024 13:46:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YoMHb8zm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DEF080219; Fri, 13 Dec 2024 13:46:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 746F880083 for ; Fri, 13 Dec 2024 13:46:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361d5dcf5bso17931705e9.3 for ; Fri, 13 Dec 2024 04:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734093964; x=1734698764; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FemKKIYzALdLpYA70zP6qxDBZOd7zFXuN0pcldeuz44=; b=YoMHb8zmUTgadcgBGfCaTNYsY8cou6PyYHVGa+C4GUQULLJ4t5YmEs0tTYKzWlQSSF Hv/32sd0HMiV7ZQA6yRLlKWEYwVapepqaPu4nq4GkpgwqG6++NbDKzGSI6WzGnxzRh2G qHO2+5FlQllQaVA7mxPmsBr7HNr7RpUWiNtYHm6jJfZoVogME7y/DpryaE1p83pj16Ka QZcbaSLXdJ/vG7WLMT7BPh59DCShz49km6RKQ4jEgPk0ahkQKXs6cTpdLjYXoMhU39vw QUyj+p8CI18PoTmglRHYU1VLgmxONytnZXxV2eiFtHyb5ratWhkMWhVH8roEkkyKaP+4 XVpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734093964; x=1734698764; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FemKKIYzALdLpYA70zP6qxDBZOd7zFXuN0pcldeuz44=; b=ZP4aXPrVRZQOmWVGyy81LOYxAdcpA0QFofC7flxNOcAliHTNBelEg/pBTRU0XTrSlu r/JbyDfQ0OtBNy/lNkcHAEXwvXWsYLHvc5icOePTE4F88n7HODT79bHWXkVpWsrWXtWZ UPIbsHzBaCKRDlrl72lWffBtIZpcvN+jLHCOV4xJeldAoWAvlKtj5Pkj/gCe/8IwToM3 OtQvM2Ydg4f99SNZzU1F4pqjkawcinmCmFnLuPf8q8wblbWfIFGenFq8HpIIQvlw5Koz mmNF5eVTR8I3iiNip9R7rA5uGC9S45yuAR/aktm4qy7x5FGPEWAOLlaNgfpz0SfAPXJY xokw== X-Gm-Message-State: AOJu0YzjljzrSKt6jc0rmn3Xt8DzkqrU8/zdUVhGLJ15H5rxq1aUC6ul OeLnrVYkiQZPexGPH4dRtgnXfTYZ7Z3J48HwA4Tjw4E+mahw0C4xoIZB2rzBlWOZMUC6BzvkxdW hLqo= X-Gm-Gg: ASbGncsiYsqW7f4GHEfV7pMvgM+TGKmEGdiDV6lR1jGHgxOQMNYq3ZzPSnF/Qhxqwmd +DRehMgy7ojfGSVoXfB8mydiZpuflZsTe58x6d0RQ/wNx4cS20ou6bpDElJ2RGNs/jYa54tnCJK qiyYkdXkgjVm656rIVShh3wYfwpVTSDlW03J6731Nnq29Pvv/4ya1JxQX49T29hLXqYn0ZXZdkq Chbj0l4FpEgI+cdT8MBksNCvWGvP5ucjaoNAYgLJwr6ySO7IEaKaDLTVnn6aMFZHQ== X-Received: by 2002:a05:600c:1da6:b0:434:a7e3:db5c with SMTP id 5b1f17b1804b1-4362aa27ef1mr19202095e9.11.1734093963765; Fri, 13 Dec 2024 04:46:03 -0800 (PST) Received: from builder.. ([2a01:e0a:3cb:7bb0:3390:8f2f:2eb7:90a7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3878248e54dsm7050988f8f.19.2024.12.13.04.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 04:46:03 -0800 (PST) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Tom Rini , Simon Glass , Jerome Forissier Subject: [PATCH v2 3/3] trace: document 'trace wipe' Date: Fri, 13 Dec 2024 13:45:38 +0100 Message-ID: <1833d3884f623ef66b81443be87b773b1e896498.1734093566.git.jerome.forissier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add documentation for the 'trace wipe' command. Signed-off-by: Jerome Forissier Acked-by: Ilias Apalodimas --- doc/develop/trace.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/develop/trace.rst b/doc/develop/trace.rst index 546862020b1..d3c8628d124 100644 --- a/doc/develop/trace.rst +++ b/doc/develop/trace.rst @@ -163,6 +163,17 @@ you will see the time taken by each function shown against its exit record. u-boot-1 [000] 3.116466: funcgraph_entry: 0.063 us | memset(); u-boot-1 [000] 3.116539: funcgraph_exit: 0.143 us | } +The `trace wipe` command may be used to clear the trace buffer. It leaves +tracing in its current enable state. This command is convenient when tracing a +single command, for example: + +.. code-block:: console + + => trace pause; trace wipe + => trace resume; dhcp; trace pause + => trace stats + ... + Flame graph -----------