* [PATCH 0/3] scripts/decode_stacktrace.sh: preserve alignment
@ 2025-09-08 15:41 Matthieu Baerts (NGI0)
2025-09-08 15:41 ` [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces Matthieu Baerts (NGI0)
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-09-08 15:41 UTC (permalink / raw)
To: Andrew Morton
Cc: Carlos Llamas, Elliot Berman, Stephen Boyd, Breno Leitao,
Luca Ceresoli, linux-kernel, Matthieu Baerts (NGI0)
Here are a few patches slightly improving the output generated by
decode_stacktrace.sh script.
- Patch 1: avoid trailing whitespaces when printing symbols.
- Patch 2: preserve alignment when printing symbols.
- Patch 3: preserve alignment when printing code.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Matthieu Baerts (NGI0) (3):
scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces
scripts/decode_stacktrace.sh: symbol: preserve alignment
scripts/decode_stacktrace.sh: code: preserve alignment
scripts/decode_stacktrace.sh | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)
---
base-commit: 76eeb9b8de9880ca38696b2fb56ac45ac0a25c6c
change-id: 20250908-decode_strace_indent-04f69b1f9b14
Best regards,
--
Matthieu Baerts (NGI0) <matttbe@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces 2025-09-08 15:41 [PATCH 0/3] scripts/decode_stacktrace.sh: preserve alignment Matthieu Baerts (NGI0) @ 2025-09-08 15:41 ` Matthieu Baerts (NGI0) 2025-09-08 16:18 ` Carlos Llamas ` (2 more replies) 2025-09-08 15:41 ` [PATCH 2/3] scripts/decode_stacktrace.sh: symbol: preserve alignment Matthieu Baerts (NGI0) 2025-09-08 15:41 ` [PATCH 3/3] scripts/decode_stacktrace.sh: code: " Matthieu Baerts (NGI0) 2 siblings, 3 replies; 9+ messages in thread From: Matthieu Baerts (NGI0) @ 2025-09-08 15:41 UTC (permalink / raw) To: Andrew Morton Cc: Carlos Llamas, Elliot Berman, Stephen Boyd, Breno Leitao, Luca Ceresoli, linux-kernel, Matthieu Baerts (NGI0) 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) <matttbe@kernel.org> --- 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..c6b5c14412f0f6f78fb60b0b042d6e22bbb46b79 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -323,12 +323,7 @@ handle_line() { parse_symbol # modifies $symbol # 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}}" } while read line; do -- 2.51.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces 2025-09-08 15:41 ` [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces Matthieu Baerts (NGI0) @ 2025-09-08 16:18 ` Carlos Llamas 2025-09-10 9:15 ` Luca Ceresoli 2025-09-10 13:07 ` Breno Leitao 2 siblings, 0 replies; 9+ messages in thread From: Carlos Llamas @ 2025-09-08 16:18 UTC (permalink / raw) To: Matthieu Baerts (NGI0) Cc: Andrew Morton, Elliot Berman, Stephen Boyd, Breno Leitao, Luca Ceresoli, linux-kernel On Mon, Sep 08, 2025 at 05:41:57PM +0200, Matthieu Baerts (NGI0) wrote: > 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) <matttbe@kernel.org> > --- > 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..c6b5c14412f0f6f78fb60b0b042d6e22bbb46b79 100755 > --- a/scripts/decode_stacktrace.sh > +++ b/scripts/decode_stacktrace.sh > @@ -323,12 +323,7 @@ handle_line() { > parse_symbol # modifies $symbol > > # 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}}" > } > > while read line; do > > -- > 2.51.0 > LGTM, Reviewed-by: Carlos Llamas <cmllamas@google.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces 2025-09-08 15:41 ` [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces Matthieu Baerts (NGI0) 2025-09-08 16:18 ` Carlos Llamas @ 2025-09-10 9:15 ` Luca Ceresoli 2025-09-10 13:07 ` Breno Leitao 2 siblings, 0 replies; 9+ messages in thread From: Luca Ceresoli @ 2025-09-10 9:15 UTC (permalink / raw) To: Matthieu Baerts (NGI0) Cc: Andrew Morton, Carlos Llamas, Elliot Berman, Stephen Boyd, Breno Leitao, linux-kernel On Mon, 08 Sep 2025 17:41:57 +0200 "Matthieu Baerts (NGI0)" <matttbe@kernel.org> wrote: > 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) <matttbe@kernel.org> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces 2025-09-08 15:41 ` [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces Matthieu Baerts (NGI0) 2025-09-08 16:18 ` Carlos Llamas 2025-09-10 9:15 ` Luca Ceresoli @ 2025-09-10 13:07 ` Breno Leitao 2 siblings, 0 replies; 9+ messages in thread From: Breno Leitao @ 2025-09-10 13:07 UTC (permalink / raw) To: Matthieu Baerts (NGI0) Cc: Andrew Morton, Carlos Llamas, Elliot Berman, Stephen Boyd, Luca Ceresoli, linux-kernel On Mon, Sep 08, 2025 at 05:41:57PM +0200, Matthieu Baerts (NGI0) wrote: > 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) <matttbe@kernel.org> Reviewed-by: Breno Leitao <leitao@debian.org> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] scripts/decode_stacktrace.sh: symbol: preserve alignment 2025-09-08 15:41 [PATCH 0/3] scripts/decode_stacktrace.sh: preserve alignment Matthieu Baerts (NGI0) 2025-09-08 15:41 ` [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces Matthieu Baerts (NGI0) @ 2025-09-08 15:41 ` Matthieu Baerts (NGI0) 2025-09-08 16:22 ` Carlos Llamas 2025-09-08 15:41 ` [PATCH 3/3] scripts/decode_stacktrace.sh: code: " Matthieu Baerts (NGI0) 2 siblings, 1 reply; 9+ messages in thread From: Matthieu Baerts (NGI0) @ 2025-09-08 15:41 UTC (permalink / raw) To: Andrew Morton Cc: Carlos Llamas, Elliot Berman, Stephen Boyd, Breno Leitao, Luca Ceresoli, linux-kernel, Matthieu Baerts (NGI0) 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=y). With this sample ... [ 52.080924] Call Trace: [ 52.080926] <TASK> [ 52.080931] dump_stack_lvl+0x6f/0xb0 ... the script was producing the following output: [ 52.080924] Call Trace: [ 52.080926] <TASK> [ 52.080931] dump_stack_lvl (arch/x86/include/asm/irqflags.h:19) (dump_stack_lvl is no longer aligned with <TASK>: one missing space) With this other sample ... [ 52.080924][ T48] Call Trace: [ 52.080926][ T48] <TASK> [ 52.080931][ T48] dump_stack_lvl+0x6f/0xb0 ... the script was producing the following output: [ 52.080924][ T48] Call Trace: [ 52.080926][ T48] <TASK> [ 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=y 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 <backslash> 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] <TASK> [ 52.080931][ T48] dump_stack_lvl (arch/x86/include/asm/irqflags.h:19) (the alignment is preserved) Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> --- 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..0c92d6a7f777e1b2d5452dd894a13a71e3d58051 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -255,10 +255,11 @@ handle_line() { basepath=${basepath%/init/main.c:*)} fi - local words + local words spaces - # Tokenize - read -a words <<<"$1" + # Tokenize: words and spaces to preserve the alignment + read -ra words <<<"$1" + IFS='#' read -ra spaces <<<"$(shopt -s extglob; echo "${1//+([^[:space:]])/#}")" # 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]} =~ \[\<([^]]+)\>\] ]]; then - unset words[$i] - fi - - # Format timestamps with tabs - if [[ ${words[$i]} == \[ && ${words[$i+1]} == *\] ]]; then - unset words[$i] - words[$i+1]=$(printf "[%13s\n" "${words[$i+1]}") + unset words[$i] spaces[$i] fi done if [[ ${words[$last]} =~ ^[0-9a-f]+\] ]]; then words[$last-1]="${words[$last-1]} ${words[$last]}" - unset words[$last] + unset words[$last] spaces[$last] last=$(( $last - 1 )) fi @@ -294,7 +289,7 @@ handle_line() { local info_str="" if [[ ${words[$last]} =~ \([A-Z]*\) ]]; then info_str=${words[$last]} - unset words[$last] + unset words[$last] spaces[$last] last=$(( $last - 1 )) fi @@ -311,7 +306,7 @@ handle_line() { modbuildid= fi symbol=${words[$last-1]} - unset words[$last-1] + unset words[$last-1] spaces[$last-1] else # The symbol is the last element, process it symbol=${words[$last]} @@ -323,7 +318,10 @@ handle_line() { parse_symbol # modifies $symbol # 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_str}}" } while read line; do -- 2.51.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] scripts/decode_stacktrace.sh: symbol: preserve alignment 2025-09-08 15:41 ` [PATCH 2/3] scripts/decode_stacktrace.sh: symbol: preserve alignment Matthieu Baerts (NGI0) @ 2025-09-08 16:22 ` Carlos Llamas 0 siblings, 0 replies; 9+ messages in thread From: Carlos Llamas @ 2025-09-08 16:22 UTC (permalink / raw) To: Matthieu Baerts (NGI0) Cc: Andrew Morton, Elliot Berman, Stephen Boyd, Breno Leitao, Luca Ceresoli, linux-kernel On Mon, Sep 08, 2025 at 05:41:58PM +0200, Matthieu Baerts (NGI0) wrote: > 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=y). > > With this sample ... > > [ 52.080924] Call Trace: > [ 52.080926] <TASK> > [ 52.080931] dump_stack_lvl+0x6f/0xb0 > > ... the script was producing the following output: > > [ 52.080924] Call Trace: > [ 52.080926] <TASK> > [ 52.080931] dump_stack_lvl (arch/x86/include/asm/irqflags.h:19) > > (dump_stack_lvl is no longer aligned with <TASK>: one missing space) > > With this other sample ... > > [ 52.080924][ T48] Call Trace: > [ 52.080926][ T48] <TASK> > [ 52.080931][ T48] dump_stack_lvl+0x6f/0xb0 > > ... the script was producing the following output: > > [ 52.080924][ T48] Call Trace: > [ 52.080926][ T48] <TASK> > [ 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=y > 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 <backslash> 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] <TASK> > [ 52.080931][ T48] dump_stack_lvl (arch/x86/include/asm/irqflags.h:19) > > (the alignment is preserved) > > Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> > --- > 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..0c92d6a7f777e1b2d5452dd894a13a71e3d58051 100755 > --- a/scripts/decode_stacktrace.sh > +++ b/scripts/decode_stacktrace.sh > @@ -255,10 +255,11 @@ handle_line() { > basepath=${basepath%/init/main.c:*)} > fi > > - local words > + local words spaces > > - # Tokenize > - read -a words <<<"$1" > + # Tokenize: words and spaces to preserve the alignment > + read -ra words <<<"$1" > + IFS='#' read -ra spaces <<<"$(shopt -s extglob; echo "${1//+([^[:space:]])/#}")" > > # 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]} =~ \[\<([^]]+)\>\] ]]; then > - unset words[$i] > - fi > - > - # Format timestamps with tabs > - if [[ ${words[$i]} == \[ && ${words[$i+1]} == *\] ]]; then > - unset words[$i] > - words[$i+1]=$(printf "[%13s\n" "${words[$i+1]}") > + unset words[$i] spaces[$i] > fi > done > > if [[ ${words[$last]} =~ ^[0-9a-f]+\] ]]; then > words[$last-1]="${words[$last-1]} ${words[$last]}" > - unset words[$last] > + unset words[$last] spaces[$last] > last=$(( $last - 1 )) > fi > > @@ -294,7 +289,7 @@ handle_line() { > local info_str="" > if [[ ${words[$last]} =~ \([A-Z]*\) ]]; then > info_str=${words[$last]} > - unset words[$last] > + unset words[$last] spaces[$last] > last=$(( $last - 1 )) > fi > > @@ -311,7 +306,7 @@ handle_line() { > modbuildid= > fi > symbol=${words[$last-1]} > - unset words[$last-1] > + unset words[$last-1] spaces[$last-1] > else > # The symbol is the last element, process it > symbol=${words[$last]} > @@ -323,7 +318,10 @@ handle_line() { > parse_symbol # modifies $symbol > > # 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_str}}" > } > > while read line; do > > -- > 2.51.0 > I just tried this and it works for me. From this... [ 51.711528][ T6914] ================================================================== [ 51.712906][ T6914] BUG: KASAN: double-free in __kmem_cache_free (mm/slub.c:3875) [ 51.713765][ T6914] Free of addr 85ffff8912b19f80 by task sh/6914 [...] [ 51.717788][ T6914] Call trace: [ 51.718182][ T6914] dump_backtrace (arch/arm64/kernel/stacktrace.c:236) [ 51.718734][ T6914] show_stack (arch/arm64/kernel/stacktrace.c:244) [ 51.719219][ T6914] dump_stack_lvl (lib/dump_stack.c:107) ... to now this: [ 51.711528][ T6914] ================================================================== [ 51.712906][ T6914] BUG: KASAN: double-free in __kmem_cache_free (mm/slub.c:3875) [ 51.713765][ T6914] Free of addr 85ffff8912b19f80 by task sh/6914 [...] [ 51.717788][ T6914] Call trace: [ 51.718182][ T6914] dump_backtrace (arch/arm64/kernel/stacktrace.c:236) [ 51.718734][ T6914] show_stack (arch/arm64/kernel/stacktrace.c:244) [ 51.719219][ T6914] dump_stack_lvl (lib/dump_stack.c:107) Tested-by: Carlos Llamas <cmllamas@google.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] scripts/decode_stacktrace.sh: code: preserve alignment 2025-09-08 15:41 [PATCH 0/3] scripts/decode_stacktrace.sh: preserve alignment Matthieu Baerts (NGI0) 2025-09-08 15:41 ` [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces Matthieu Baerts (NGI0) 2025-09-08 15:41 ` [PATCH 2/3] scripts/decode_stacktrace.sh: symbol: preserve alignment Matthieu Baerts (NGI0) @ 2025-09-08 15:41 ` Matthieu Baerts (NGI0) 2025-09-08 16:33 ` Carlos Llamas 2 siblings, 1 reply; 9+ messages in thread From: Matthieu Baerts (NGI0) @ 2025-09-08 15:41 UTC (permalink / raw) To: Andrew Morton Cc: Carlos Llamas, Elliot Berman, Stephen Boyd, Breno Leitao, Luca Ceresoli, linux-kernel, Matthieu Baerts (NGI0) 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) <matttbe@kernel.org> --- 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..c73cb802a0a3fc6559c5f53ff844e5cc6e433615 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -242,8 +242,10 @@ debuginfod_get_vmlinux() { decode_code() { local scripts=`dirname "${BASH_SOURCE[0]}"` + local lim="Code: " - echo "$1" | $scripts/decodecode + echo -n "${1%%${lim}*}" + echo "${lim}${1##*${lim}}" | $scripts/decodecode } handle_line() { -- 2.51.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] scripts/decode_stacktrace.sh: code: preserve alignment 2025-09-08 15:41 ` [PATCH 3/3] scripts/decode_stacktrace.sh: code: " Matthieu Baerts (NGI0) @ 2025-09-08 16:33 ` Carlos Llamas 0 siblings, 0 replies; 9+ messages in thread From: Carlos Llamas @ 2025-09-08 16:33 UTC (permalink / raw) To: Matthieu Baerts (NGI0) Cc: Andrew Morton, Elliot Berman, Stephen Boyd, Breno Leitao, Luca Ceresoli, linux-kernel On Mon, Sep 08, 2025 at 05:41:59PM +0200, Matthieu Baerts (NGI0) wrote: > 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) <matttbe@kernel.org> > --- > 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..c73cb802a0a3fc6559c5f53ff844e5cc6e433615 100755 > --- a/scripts/decode_stacktrace.sh > +++ b/scripts/decode_stacktrace.sh > @@ -242,8 +242,10 @@ debuginfod_get_vmlinux() { > > decode_code() { > local scripts=`dirname "${BASH_SOURCE[0]}"` > + local lim="Code: " > > - echo "$1" | $scripts/decodecode > + echo -n "${1%%${lim}*}" > + echo "${lim}${1##*${lim}}" | $scripts/decodecode > } > > handle_line() { > > -- > 2.51.0 > This also worked for me. From this: [ 143.815379][ T5218] kernel BUG at rust/helpers/bug.c:7! [ 143.815970][ T5218] Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI [...] [ 143.842198][ T5218] RIP: 0010:rust_helper_BUG (rust/helpers/bug.c:7 (discriminator 4)) [ 143.842231][ T5218] Code: cc cc cc cc cc 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 b8 (...) ... to now: [ 143.815379][ T5218] kernel BUG at rust/helpers/bug.c:7! [ 143.815970][ T5218] Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI [...] [ 143.842198][ T5218] RIP: 0010:rust_helper_BUG (rust/helpers/bug.c:7 (discriminator 4)) [ 143.842231][ T5218] Code: cc cc cc cc cc 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 b8 (...) Tested-by: Carlos Llamas <cmllamas@google.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-09-10 13:07 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-09-08 15:41 [PATCH 0/3] scripts/decode_stacktrace.sh: preserve alignment Matthieu Baerts (NGI0) 2025-09-08 15:41 ` [PATCH 1/3] scripts/decode_stacktrace.sh: symbol: avoid trailing whitespaces Matthieu Baerts (NGI0) 2025-09-08 16:18 ` Carlos Llamas 2025-09-10 9:15 ` Luca Ceresoli 2025-09-10 13:07 ` Breno Leitao 2025-09-08 15:41 ` [PATCH 2/3] scripts/decode_stacktrace.sh: symbol: preserve alignment Matthieu Baerts (NGI0) 2025-09-08 16:22 ` Carlos Llamas 2025-09-08 15:41 ` [PATCH 3/3] scripts/decode_stacktrace.sh: code: " Matthieu Baerts (NGI0) 2025-09-08 16:33 ` Carlos Llamas
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.