Skip to content

Commit 2bff77c

Browse files
lucaceresoliakpm00
authored andcommitted
scripts/decode_stacktrace.sh: fix decoding of lines with an additional info
Since commit bdf8eaf ("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 (discriminator 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. Link: https://lkml.kernel.org/r/20241230-decode_stacktrace-fix-info-v1-1-984910659173@bootlin.com Fixes: bdf8eaf ("arm64: stacktrace: report source of unwind data") Signed-off-by: Luca Ceresoli <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Mark Brown <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Miroslav Benes <[email protected]> Cc: Puranjay Mohan <[email protected]> Cc: Thomas Petazzoni <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 76d5d4c commit 2bff77c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

scripts/decode_stacktrace.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ handle_line() {
286286
last=$(( $last - 1 ))
287287
fi
288288

289+
# Extract info after the symbol if present. E.g.:
290+
# func_name+0x54/0x80 (P)
291+
# ^^^
292+
# The regex assumes only uppercase letters will be used. To be
293+
# extended if needed.
294+
local info_str=""
295+
if [[ ${words[$last]} =~ \([A-Z]*\) ]]; then
296+
info_str=${words[$last]}
297+
unset words[$last]
298+
last=$(( $last - 1 ))
299+
fi
300+
289301
if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then
290302
module=${words[$last]}
291303
# some traces format is "(%pS)", which like "(foo+0x0/0x1 [bar])"
@@ -313,9 +325,9 @@ handle_line() {
313325
# Add up the line number to the symbol
314326
if [[ -z ${module} ]]
315327
then
316-
echo "${words[@]}" "$symbol"
328+
echo "${words[@]}" "$symbol ${info_str}"
317329
else
318-
echo "${words[@]}" "$symbol $module"
330+
echo "${words[@]}" "$symbol $module ${info_str}"
319331
fi
320332
}
321333

0 commit comments

Comments
 (0)