From nobody Sun May 10 06:27:24 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A2E915853B for ; Mon, 30 Dec 2024 21:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735595786; cv=none; b=BzfUBK1kFohCjLftGzxLwc0PrzcQBMBEytQ8+3ZUDo/SjoMppiHX1eTMXs9LgjmckAMcuvqAh7lyLhawgXCld6AbxoVIYfcwICbEwElJrux0/DmbxWbV0w+m233hBz8O7+MnrBFIaoGX/6b9PLEbQ0LHz4O7Nz0VzpGLtGtPhzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735595786; c=relaxed/simple; bh=QEp1Lrz97qNfRJKA5HO506yuvxqErccTu0xjGGZPVyA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=XtiOX1JkAG9plzoteB1wv2yZu8ed9N8WLtkxGMIVpN5cfzS5iAsowAQy5tebCR6s+xwUFXwKzXgTZqHi/UgT84fODmaXOg89bbE9PpYU6oAdm6LEpaLDNY6R4bCRNhCzLacObjCY4vJjK0kX9ymMkcgqi3zRlpGUEv6gNE4ZlGQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=I4zTp0rz; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="I4zTp0rz" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8EED5240003; Mon, 30 Dec 2024 21:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735595782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eUS2LBHCm+hvBmS63+p2+DlKIYTO18rWrCYpZU1BsDc=; b=I4zTp0rz8anTiCcdpciie1E1w6k3V6OBMMD46+Q0cn2U/cihbc4R1YFJRyEHvXzmAQd0b2 pk+y9owj2FGIxItyrmrclZaXOKq2uwzUz/1c6Ws0CFZmRqCwZBh/Yq1gM5kJL9uZBiV4V4 WMFBduiy9M7iZSo4gL9ZRNjQUWAKSPif9r4Bvoc6UcMgaVZKgxdTISPxlZFMJ4UCKlxG4t Dpk+moj8RiSP5adUL5L4vLcVIRZqLJOph2l5KjuTe9mfAxU2R+t3HrkeAp+cxgEpmd225X CCdYrx+eiLJId4FdepfP9yKmYcfX33gziwotOvFIBXGQ+aXhISPj9529aS1DkQ== From: Luca Ceresoli Date: Mon, 30 Dec 2024 22:55:10 +0100 Subject: [PATCH] scripts/decode_stacktrace.sh: fix decoding of lines with an additional info Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241230-decode_stacktrace-fix-info-v1-1-984910659173@bootlin.com> X-B4-Tracking: v=1; b=H4sIAL0Wc2cC/x3MWwqDMBBG4a3IPDuQS2nRrRSRmPxpByEpiRRB3 LvBx48D56CKIqg0dgcV/KVKTg2678h/XfqAJTSTUeahjVUc4HPAXDfn1604D46ys6SYGTbal34 qPSygNvgVtHbP39N5XkZi5iFsAAAA X-Change-ID: 20241230-decode_stacktrace-fix-info-e3f3716019be To: akpm@linux-foundation.org, Miroslav Benes , Puranjay Mohan , Catalin Marinas , Mark Brown , Mark Rutland Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-Sasl: luca.ceresoli@bootlin.com Since commit bdf8eafbf7f5 ("arm64: stacktrace: report source of unwind data") a stack trace line can contain an additional info field that was not present before, in the form of one or more letters in parentheses. E.g.: [ 504.517915] led_sysfs_enable+0x54/0x80 (P) ^^^ When this is present, decode_stacktrace decodes the line incorrectly: [ 504.517915] led_sysfs_enable+0x54/0x80 P Extend parsing to decode it correctly: [ 504.517915] led_sysfs_enable (drivers/leds/led-core.c:455 (discriminat= or 7)) (P) The regex to match such lines assumes the info can be extended in the future to other uppercase characters, and will need to be extended in case other characters will be used. Using a much more generic regex might incur in false positives, so this looked like a good tradeoff. Fixes: bdf8eafbf7f5 ("arm64: stacktrace: report source of unwind data") Signed-off-by: Luca Ceresoli --- scripts/decode_stacktrace.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 46fa18b80fc1bc40734fcc9c8752af591e4e2737..17abc4e7a9855b10e76acfdb928= 47e1671d6c2bd 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -286,6 +286,18 @@ handle_line() { last=3D$(( $last - 1 )) fi =20 + # Extract info after the symbol if present. E.g.: + # func_name+0x54/0x80 (P) + # ^^^ + # The regex assumes only uppercase letters will be used. To be + # extended if needed. + local info_str=3D"" + if [[ ${words[$last]} =3D~ \([A-Z]*\) ]]; then + info_str=3D${words[$last]} + unset words[$last] + last=3D$(( $last - 1 )) + fi + if [[ ${words[$last]} =3D~ \[([^]]+)\] ]]; then module=3D${words[$last]} # some traces format is "(%pS)", which like "(foo+0x0/0x1 [bar])" @@ -313,9 +325,9 @@ handle_line() { # Add up the line number to the symbol if [[ -z ${module} ]] then - echo "${words[@]}" "$symbol" + echo "${words[@]}" "$symbol ${info_str}" else - echo "${words[@]}" "$symbol $module" + echo "${words[@]}" "$symbol $module ${info_str}" fi } =20 --- base-commit: fc033cf25e612e840e545f8d5ad2edd6ba613ed5 change-id: 20241230-decode_stacktrace-fix-info-e3f3716019be Best regards, --=20 Luca Ceresoli