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 (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.
Showing the changes to scripts/decode_stacktrace.sh (1 of 1 file). Show all
Unified · Split
| @@ -286,6 +286,18 @@ handle_line() { · 285 unmodified lines | ||
| 286 | 286 | last=$(( $last - 1 )) |
| 287 | 287 | fi |
| 288 | 288 | |
| 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 | + | |
| 289 | 301 | if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then |
| 290 | 302 | module=${words[$last]} |
| 291 | 303 | # some traces format is "(%pS)", which like "(foo+0x0/0x1 [bar])" |
| @@ -313,9 +325,9 @@ handle_line() { · 21 unmodified lines | ||
| 313 | 325 | # Add up the line number to the symbol |
| 314 | 326 | if [[ -z ${module} ]] |
| 315 | 327 | then |
| 316 | − echo "${words[@]}" "$symbol" | |
| 328 | + echo "${words[@]}" "$symbol ${info_str}" | |
| 317 | 329 | else |
| 318 | − echo "${words[@]}" "$symbol $module" | |
| 330 | + echo "${words[@]}" "$symbol $module ${info_str}" | |
| 319 | 331 | fi |
| 320 | 332 | } |
| 321 | 333 | |