From nobody Wed Sep 10 01:55:23 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7344F30FC19 for ; Mon, 8 Sep 2025 15:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757346153; cv=none; b=EwigQOTviIZFK0OUA9voHr+Tr3CaaRmy4BFK3YZMFJSitY9AQIdJvpSgUxiJj1p/luYUyplJJA1UzsPOwNlouALxLwV5Kv1/GdzI3gXKoD6jetCaeRt5eQAVoLHETOooFJ3BkGLoHj24IHNeV5qrr1loxn8QAija8Tq9YilFHXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757346153; c=relaxed/simple; bh=HUX79U9sbM5RM/b7aDn1DdwQrXQY0K+KyM3Zg8wGFQE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BFICUYI2woTSsMwdgqQ+pNoiStwngDqgT7cOSkZjJrmPY2EHLvRAgllS6//cenxHZs4zENEh/HWVMFqUYD/Sb9mOsKgFtYyUK4wJlUkn5WC481zMzDFSG/vJ5gfnEX7gC4Jcx0JZk6WcyCUSH5pw8uQJJVBMhnLr7zKydxpFvnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aivIXE1H; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aivIXE1H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93FEBC4CEF5; Mon, 8 Sep 2025 15:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757346153; bh=HUX79U9sbM5RM/b7aDn1DdwQrXQY0K+KyM3Zg8wGFQE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aivIXE1HmxcYU0GvuBGa6Y9bOpbaKqsQUN5YkewYObJl20spT3KUtijPxbok3TUIX 3ElF62QfLuisXjqu7NWOMOLNpJaJXu+vt0mQyuGVaa+cgTB/OY0XJoY744QGReBw6g A/r0n7kymHsqVe/8SBZ0GGWviSPwHmVlnOFLsy4yC0xMlLJLce0ykiWuJMNABxxCcw vewACWQaqfWuBP+yorjDZSUFzb2hhpAXmLbcEHGKzkusWGAjsojcQvzLS3+MQb5mSZ gb61Ckvqkuydjic2cOTxwvFziUW9hW3xnHe0XwN866VZ2yYe43USfAEhhjhI3cC1vG kcwLEFaTLRJ9Q== From: "Matthieu Baerts (NGI0)" Date: Mon, 08 Sep 2025 17:41:57 +0200 Subject: [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces 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: <20250908-decode_strace_indent-v1-1-28e5e4758080@kernel.org> References: <20250908-decode_strace_indent-v1-0-28e5e4758080@kernel.org> In-Reply-To: <20250908-decode_strace_indent-v1-0-28e5e4758080@kernel.org> To: Andrew Morton Cc: Carlos Llamas , Elliot Berman , Stephen Boyd , Breno Leitao , Luca Ceresoli , linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1275; i=matttbe@kernel.org; h=from:subject:message-id; bh=HUX79U9sbM5RM/b7aDn1DdwQrXQY0K+KyM3Zg8wGFQE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDL2/Uz6u8552az8zoWlH1azrNxmzTXjdHOkkrb63D8TG ndMvWW0v6OUhUGMi0FWTJFFui0yf+bzKt4SLz8LmDmsTCBDGLg4BWAiu2IZfjE/n1j3r+Wfd9dO 9S0l/7Suvut49/ZgU+NMl4DwdTevB3szMhwVaLVOtHI13GKhffDoBh1fb1nBfVfDtWwWB2xWMJ7 wnxsA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Lines having a symbol to decode might not always have info after this symbol. It means ${info_str} might not be set, but it will always be printed after a space, causing trailing whitespaces. That's a detail, but when the output is opened with an editor marking these trailing whitespaces, that's a bit disturbing. It is easy to remove them by printing this variable with a space only if it is set. While at it, do the same with ${module} and print everything in one line. Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Carlos Llamas --- scripts/decode_stacktrace.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 17abc4e7a9855b10e76acfdb92847e1671d6c2bd..c6b5c14412f0f6f78fb60b0b042= d6e22bbb46b79 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -323,12 +323,7 @@ handle_line() { parse_symbol # modifies $symbol =20 # Add up the line number to the symbol - if [[ -z ${module} ]] - then - echo "${words[@]}" "$symbol ${info_str}" - else - echo "${words[@]}" "$symbol $module ${info_str}" - fi + echo "${words[@]}" "${symbol}${module:+ ${module}}${info_str:+ ${info_str= }}" } =20 while read line; do --=20 2.51.0 From nobody Wed Sep 10 01:55:23 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 71E5F30FC3F for ; Mon, 8 Sep 2025 15:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757346155; cv=none; b=sQgkgjPv5vsn0uSrzjJaswUFz0wo17zvFTypDuiEGTtGbN79m7TWPPwM4UqyRKA2F9L4/zJFTj5hVYs87ssLcZzaepyw2N4XUbPlkFXH6tIS1pVgCjSiwfuVnnInAJIlIAziPePxtoA/lueOY1vzDaZkgS3sKkpf8hBQnKE39Ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757346155; c=relaxed/simple; bh=QMfWFEcxtesZWCLxtNH+3FIBjKsP9cVYMB+YWbCzGto=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kt1QG8ZEkZrtNZuZY+WdalMVF6dFXtTs0HQoRRwZTfiLPmSUNZgJa7P9TWLO8nFYaKCL8UnEI9Sa5S6xV0e9p4Z/BsmLVrctT/tvzQkcNdufzZHBkdZ4/NQcT+K2yj6AUqjWjy6xmU64/lryCxkwIdoPVTRKnYhRCzlM7Zhq2Hs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f+oy4xKY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f+oy4xKY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71513C4CEF7; Mon, 8 Sep 2025 15:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757346154; bh=QMfWFEcxtesZWCLxtNH+3FIBjKsP9cVYMB+YWbCzGto=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=f+oy4xKYtgjX092rF+4IlYSUJe8NrUVCsZR0NuNWoXFGz20iZTSx1QgM8UNplV8MR JFeDa6GqVr3ikveLL6NSYm+FjKq9PBhb9aG8jc6P75h1gZVVcPPlJOn5ljA33fKI1x UP2sfV+ao+ApaYZWT7gIUhdbaoOVhVyjqzgDB5yAQwFI2A6I5c74zo70AYljvEfBmK AF4S26KNVs75bK2uujGUfFwbKgJwgQ1dLsFU5xEYP+2sUeBFL91KplhOZSpomMENRa Z1YW9fAdamRyP4jY3Wv2roTC0lF0p+6usHwgOmRtqWZ+CPf3NDas2pL9URqqdNub++ xTSUP+aLutEEw== From: "Matthieu Baerts (NGI0)" Date: Mon, 08 Sep 2025 17:41:58 +0200 Subject: [PATCH 2/3] scripts/decode_stacktrace.sh: symbol: preserve alignment 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: <20250908-decode_strace_indent-v1-2-28e5e4758080@kernel.org> References: <20250908-decode_strace_indent-v1-0-28e5e4758080@kernel.org> In-Reply-To: <20250908-decode_strace_indent-v1-0-28e5e4758080@kernel.org> To: Andrew Morton Cc: Carlos Llamas , Elliot Berman , Stephen Boyd , Breno Leitao , Luca Ceresoli , linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4143; i=matttbe@kernel.org; h=from:subject:message-id; bh=QMfWFEcxtesZWCLxtNH+3FIBjKsP9cVYMB+YWbCzGto=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDL2/Ux+VPll9csF1qFpeSGHo4xMTXxOdD7QdLPi/Bu84 otjo8LRjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgInkv2f4w32u9umX+w+sD91e I1K6ukxUedGfhKNHFriLlGT7HFxvep2RYdfDNz9vpc9kF330y9SruldwKsvFdzUcXpNm3VVy2O7 3igcA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 With lines having a symbol to decode, the script was only trying to preserve the alignment for the timestamps, but not the rest, nor when the caller was set (CONFIG_PRINTK_CALLER=3Dy). With this sample ... [ 52.080924] Call Trace: [ 52.080926] [ 52.080931] dump_stack_lvl+0x6f/0xb0 ... the script was producing the following output: [ 52.080924] Call Trace: [ 52.080926] [ 52.080931] dump_stack_lvl (arch/x86/include/asm/irqflags.h:19) (dump_stack_lvl is no longer aligned with : one missing space) With this other sample ... [ 52.080924][ T48] Call Trace: [ 52.080926][ T48] [ 52.080931][ T48] dump_stack_lvl+0x6f/0xb0 ... the script was producing the following output: [ 52.080924][ T48] Call Trace: [ 52.080926][ T48] [ 52.080931][ T48] dump_stack_lvl (arch/x86/include/asm/irqflags.h:19) (the misalignment is clearer here) That's because the script had a workaround for CONFIG_PRINTK_TIME=3Dy only, see the previous comment called "Format timestamps with tabs". To always preserve spaces, they need to be recorded along the words. That is what is now done with the new 'spaces' array. Some notes: - 'extglob' is needed only for this operation, and that's why it is set in a dedicated subshell. - 'read' is used with '-r' not to treat a character in any special way, e.g. when followed by a space. - When a word is removed from the 'words' array, the corresponding space needs to be removed from the 'spaces' array as well. With the last sample, we now have: [ 52.080924][ T48] Call Trace: [ 52.080926][ T48] [ 52.080931][ T48] dump_stack_lvl (arch/x86/include/asm/irqflags.h:1= 9) (the alignment is preserved) Signed-off-by: Matthieu Baerts (NGI0) Tested-by: Carlos Llamas --- scripts/decode_stacktrace.sh | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index c6b5c14412f0f6f78fb60b0b042d6e22bbb46b79..0c92d6a7f777e1b2d5452dd894a= 13a71e3d58051 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -255,10 +255,11 @@ handle_line() { basepath=3D${basepath%/init/main.c:*)} fi =20 - local words + local words spaces =20 - # Tokenize - read -a words <<<"$1" + # Tokenize: words and spaces to preserve the alignment + read -ra words <<<"$1" + IFS=3D'#' read -ra spaces <<<"$(shopt -s extglob; echo "${1//+([^[:space:= ]])/#}")" =20 # Remove hex numbers. Do it ourselves until it happens in the # kernel @@ -270,19 +271,13 @@ handle_line() { for i in "${!words[@]}"; do # Remove the address if [[ ${words[$i]} =3D~ \[\<([^]]+)\>\] ]]; then - unset words[$i] - fi - - # Format timestamps with tabs - if [[ ${words[$i]} =3D=3D \[ && ${words[$i+1]} =3D=3D *\] ]]; then - unset words[$i] - words[$i+1]=3D$(printf "[%13s\n" "${words[$i+1]}") + unset words[$i] spaces[$i] fi done =20 if [[ ${words[$last]} =3D~ ^[0-9a-f]+\] ]]; then words[$last-1]=3D"${words[$last-1]} ${words[$last]}" - unset words[$last] + unset words[$last] spaces[$last] last=3D$(( $last - 1 )) fi =20 @@ -294,7 +289,7 @@ handle_line() { local info_str=3D"" if [[ ${words[$last]} =3D~ \([A-Z]*\) ]]; then info_str=3D${words[$last]} - unset words[$last] + unset words[$last] spaces[$last] last=3D$(( $last - 1 )) fi =20 @@ -311,7 +306,7 @@ handle_line() { modbuildid=3D fi symbol=3D${words[$last-1]} - unset words[$last-1] + unset words[$last-1] spaces[$last-1] else # The symbol is the last element, process it symbol=3D${words[$last]} @@ -323,7 +318,10 @@ handle_line() { parse_symbol # modifies $symbol =20 # Add up the line number to the symbol - echo "${words[@]}" "${symbol}${module:+ ${module}}${info_str:+ ${info_str= }}" + for i in "${!words[@]}"; do + echo -n "${spaces[i]}${words[i]}" + done + echo "${spaces[$last]}${symbol}${module:+ ${module}}${info_str:+ ${info_s= tr}}" } =20 while read line; do --=20 2.51.0 From nobody Wed Sep 10 01:55:23 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D932230FF39 for ; Mon, 8 Sep 2025 15:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757346156; cv=none; b=Eoq0gtfVkcLwnb+ATUery/6tQX3EkWYmZ9rZDXbcRKA+tLaRthKIhW6dVhQg/YdbWgmrjajF55D+rvDuXkVgcYcGZPZPu4FWF05fInJfkm9VfEPw5yMc6Yl6qFNovkEXyAXRzezyAdqkBahsxAZiRvxAzjemef4AIqc1Z19Miwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757346156; c=relaxed/simple; bh=eXbgX0A48sO54B6uJSzEg/a+xGkMY4dc5ZXyPrbO1ec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o9HNfkExit1Ra3G6OfIdtD8oMRP40TqpFu6LptOuBbSOrg7jwNGNcRdKqbRk6wB5Z3qFU9gyuNRlntowQRlRvsyUPr3/x/CLsjQFFLbF2Uk2G/fXuXb22HyfxAgrVNU0BeajX6fEoYZ7PpjlOxZVPEKBHiDqWMefrUgm8J+yuUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fNLTRDO0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fNLTRDO0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EBE8C4CEF5; Mon, 8 Sep 2025 15:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757346156; bh=eXbgX0A48sO54B6uJSzEg/a+xGkMY4dc5ZXyPrbO1ec=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fNLTRDO0AqUVSrD7dbA1PfjpK+UdipNbg64hkJJszkoDNOFQ9SsmA+ZZcw0y+9e1O dx4hBbWwRqi24hWaMzevjdVfwuRB0+iRQxBYxHh/jSrGAgGRTn7anX73cpd7wOtoNs juvtoXFNMe6zMiEMYAV2C4fy5Fy4wmGL3EInvZCgBOsear5o6PrfP1fNslRPnp5hnT GkBVmUM4wdkA4GteK5/Pfbio1YDJMX/F6hkPuUPJxXHiuX4TUt3C3ZMxY38S5zazn9 x11eBYNJxKZYubQnFMirB9VehYbVoM8DINone6mLNBC3RBBnCRq6C6RSlZYm6xS0Yc 6gWmSKpDzNHrQ== From: "Matthieu Baerts (NGI0)" Date: Mon, 08 Sep 2025 17:41:59 +0200 Subject: [PATCH 3/3] scripts/decode_stacktrace.sh: code: preserve alignment 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: <20250908-decode_strace_indent-v1-3-28e5e4758080@kernel.org> References: <20250908-decode_strace_indent-v1-0-28e5e4758080@kernel.org> In-Reply-To: <20250908-decode_strace_indent-v1-0-28e5e4758080@kernel.org> To: Andrew Morton Cc: Carlos Llamas , Elliot Berman , Stephen Boyd , Breno Leitao , Luca Ceresoli , linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1502; i=matttbe@kernel.org; h=from:subject:message-id; bh=eXbgX0A48sO54B6uJSzEg/a+xGkMY4dc5ZXyPrbO1ec=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDL2/UyxDzp6QrhS/0Xl9mT2gATbvyXzr5+pcyn9ayC4/ cy258bnO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACbSrsTIMLG4J4WFi33FNd+0 ptqMcldeXsZ1W21Vm9TWHrjGc++aKsM/5drTbK9PPjBNfly51oL3yJnpEX8E84t3zUs+sdN+v74 4DwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 With lines having a code to decode, the alignment was not preserved for the first line. With this sample ... [ 52.238089][ T55] RIP: 0010:__ip_queue_xmit+0x127c/0x1820 [ 52.238401][ T55] Code: c1 83 e0 07 48 c1 e9 03 83 c0 03 (...) ... the script was producing the following output: [ 52.238089][ T55] RIP: 0010:__ip_queue_xmit (...) [ 52.238401][ T55] Code: c1 83 e0 07 48 c1 e9 03 83 c0 03 (...) That's because scripts/decodecode doesn't preserve the alignment. No need to modify it, it is enough to give only the "Code: (...)" part to this script, and print the prefix without modifications. With the same sample, we now have: [ 52.238089][ T55] RIP: 0010:__ip_queue_xmit (...) [ 52.238401][ T55] Code: c1 83 e0 07 48 c1 e9 03 83 c0 03 (...) Signed-off-by: Matthieu Baerts (NGI0) Tested-by: Carlos Llamas --- scripts/decode_stacktrace.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 0c92d6a7f777e1b2d5452dd894a13a71e3d58051..c73cb802a0a3fc6559c5f53ff84= 4e5cc6e433615 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -242,8 +242,10 @@ debuginfod_get_vmlinux() { =20 decode_code() { local scripts=3D`dirname "${BASH_SOURCE[0]}"` + local lim=3D"Code: " =20 - echo "$1" | $scripts/decodecode + echo -n "${1%%${lim}*}" + echo "${lim}${1##*${lim}}" | $scripts/decodecode } =20 handle_line() { --=20 2.51.0