Skip to contentSkip to conversation

scripts/decode_stacktrace: Strip basepath from all paths.

PATCH Applied Pi-Hsun Shih 2 participants 2 messages Jul 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/decode_stacktrace: Strip basepath from all paths.

Currently the basepath is removed only from the beginning of the string. When the symbol is inlined and there's multiple line outputs of addr2line, only the first line would have basepath removed.

Change to remove the basepath prefix from all lines.

Fixes 31013836a71e ("scripts/decode_stacktrace: match basepath using shell prefix operator, not regex")
---
 scripts/decode_stacktrace.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/decode_stacktrace.sh +2 -2
index 66a6d511b524..0869def435ee 100755
@@ -87,8 +87,8 @@ parse_symbol() {
 		return
 	fi
 
-	# Strip out the base of the path
-	code=${code#$basepath/}
+	# Strip out the base of the path on each line
+	code=$(while read -r line; do echo "${line#$basepath/}"; done <<< "$code")
 
 	# In the case of inlines, move everything to same line
 	code=${code//$'\n'/' '}

base-commit: 5714ee50bb4375bd586858ad800b1d9772847452

Signature · 1 line
2.28.0.rc0.105.gf9edc3c819-goog
Reviewed-by on v1 1/1
#1 lore raw

Quoting Pi-Hsun Shih (2020-07-20 01:27:07)

Quoted 10 lines

Currently the basepath is removed only from the beginning of the string. When the symbol is inlined and there's multiple line outputs of addr2line, only the first line would have basepath removed.

Change to remove the basepath prefix from all lines.

Fixes 31013836a71e ("scripts/decode_stacktrace: match basepath using shell prefix operator, not regex")

I thought Co-developed-by and the other SoB came before your SoB.

Quoted 3 lines
---
 scripts/decode_stacktrace.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
scripts/decode_stacktrace.sh +0 -0
index 66a6d511b524..0869def435ee 100755

scripts/decode_stacktrace.sh parse_symbol() { · line 94

Quoted 10 lines
scripts/decode_stacktrace.sh +2 -2
@@ -87,8 +87,8 @@ parse_symbol() {
                return
        fi
 
-       # Strip out the base of the path
-       code=${code#$basepath/}
+       # Strip out the base of the path on each line
+       code=$(while read -r line; do echo "${line#$basepath/}"; done <<< "$code")
 
        # In the case of inlines, move everything to same line
        code=${code//$'\n'/' '}

Given that there's a while loop now maybe this line above could be removed and the echo above replaced with a printf.