public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/decode_stacktrace.sh: fix build ID and PC source parsing
@ 2025-10-30  1:03 Carlos Llamas
  2025-10-30 12:24 ` Matthieu Baerts
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Carlos Llamas @ 2025-10-30  1:03 UTC (permalink / raw)
  To: Andrew Morton, Matthieu Baerts (NGI0), Carlos Llamas,
	Breno Leitao, Luca Ceresoli, Miroslav Benes, Mark Brown,
	Puranjay Mohan, Mark Rutland, Catalin Marinas
  Cc: kernel-team, linux-kernel

Support for parsing PC source info in stacktraces (e.g. '(P)') was
added in commit 2bff77c665ed ("scripts/decode_stacktrace.sh: fix
decoding of lines with an additional info"). However, this logic was
placed after the build ID processing. This incorrect order fails to
parse lines containing both elements, e.g.:

  drm_gem_mmap_obj+0x114/0x200 [drm 03d0564e0529947d67bb2008c3548be77279fd27] (P)

This patch fixes the problem by extracting the PC source info first and
then processing the module build ID. With this change, the line above is
now properly parsed as such:

  drm_gem_mmap_obj (./include/linux/mmap_lock.h:212 ./include/linux/mm.h:811 drivers/gpu/drm/drm_gem.c:1177) drm (P)

While here, also add a brief explanation the build ID section.

Fixes: bdf8eafbf7f5 ("arm64: stacktrace: report source of unwind data")
Fixes: 2bff77c665ed ("scripts/decode_stacktrace.sh: fix decoding of lines with an additional info")
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
 scripts/decode_stacktrace.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index c73cb802a0a3..8d01b741de62 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -277,12 +277,6 @@ handle_line() {
 		fi
 	done
 
-	if [[ ${words[$last]} =~ ^[0-9a-f]+\] ]]; then
-		words[$last-1]="${words[$last-1]} ${words[$last]}"
-		unset words[$last] spaces[$last]
-		last=$(( $last - 1 ))
-	fi
-
 	# Extract info after the symbol if present. E.g.:
 	# func_name+0x54/0x80 (P)
 	#                     ^^^
@@ -295,6 +289,14 @@ handle_line() {
 		last=$(( $last - 1 ))
 	fi
 
+	# Join module name with its build id if present, as these were
+	# split during tokenization (e.g. "[module" and "modbuildid]").
+	if [[ ${words[$last]} =~ ^[0-9a-f]+\] ]]; then
+		words[$last-1]="${words[$last-1]} ${words[$last]}"
+		unset words[$last] spaces[$last]
+		last=$(( $last - 1 ))
+	fi
+
 	if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then
 		module=${words[$last]}
 		# some traces format is "(%pS)", which like "(foo+0x0/0x1 [bar])"
-- 
2.51.1.851.g4ebd6896fd-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-07  0:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30  1:03 [PATCH] scripts/decode_stacktrace.sh: fix build ID and PC source parsing Carlos Llamas
2025-10-30 12:24 ` Matthieu Baerts
2025-10-30 14:50 ` Luca Ceresoli
2025-10-31  3:57 ` Andrew Morton
2025-11-06  0:59   ` Carlos Llamas
2025-11-07  0:48     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox