From b41838fe11ce1d2d994210c2c79582499c53e0ca Mon Sep 17 00:00:00 2001 From: Xiong Nandi Date: Fri, 24 May 2024 12:25:59 +0800 Subject: scripts/decode_stacktrace.sh: wrap nm with UTIL_PREFIX and UTIL_SUFFIX Patch series "scripts/decode_stacktrace.sh: better support to ARM32". This patch (of 2): Since System.map is generated by cross-compile nm tool, we should use it here too. Otherwise host nm may not recognize ARM Thumb-2 instruction address well. Link: https://lkml.kernel.org/r/20240524042600.14738-1-xndchn@gmail.com Link: https://lkml.kernel.org/r/20240524042600.14738-2-xndchn@gmail.com Signed-off-by: Xiong Nandi Reviewed-by: Elliot Berman Cc: Bjorn Andersson Cc: Carlos Llamas Signed-off-by: Andrew Morton --- scripts/decode_stacktrace.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/decode_stacktrace.sh') diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index fa5be6f57b00..2bc3a54ffba5 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -30,6 +30,7 @@ fi READELF=${UTIL_PREFIX}readelf${UTIL_SUFFIX} ADDR2LINE=${UTIL_PREFIX}addr2line${UTIL_SUFFIX} +NM=${UTIL_PREFIX}nm${UTIL_SUFFIX} if [[ $1 == "-r" ]] ; then vmlinux="" @@ -158,7 +159,7 @@ parse_symbol() { if [[ $aarray_support == true && "${cache[$module,$name]+isset}" == "isset" ]]; then local base_addr=${cache[$module,$name]} else - local base_addr=$(nm "$objfile" 2>/dev/null | awk '$3 == "'$name'" && ($2 == "t" || $2 == "T") {print $1; exit}') + local base_addr=$(${NM} "$objfile" 2>/dev/null | awk '$3 == "'$name'" && ($2 == "t" || $2 == "T") {print $1; exit}') if [[ $base_addr == "" ]] ; then # address not found return -- cgit v1.2.3 From 78efbfb5b7675b88d987fda108df0a2f3e07e722 Mon Sep 17 00:00:00 2001 From: Xiong Nandi Date: Fri, 24 May 2024 12:26:00 +0800 Subject: scripts/decode_stacktrace.sh: better support to ARM32 module stack trace Sometimes there are special characters around module names in stack traces, such as ARM32 with BACKTRACE_VERBOSE in "(%pS)" format, such as: [<806e4845>] (dump_stack_lvl) from [<7f806013>] (hello_init+0x13/0x1000 [test]) In this case, $module will be "[test])", the trace can be decoded by stripping the right parenthesis first: (dump_stack_lvl) from hello_init (/foo/test.c:10) test. Link: https://lkml.kernel.org/r/20240524042600.14738-3-xndchn@gmail.com Signed-off-by: Xiong Nandi Suggested-by: Elliot Berman Cc: Bjorn Andersson Cc: Carlos Llamas Signed-off-by: Andrew Morton --- scripts/decode_stacktrace.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts/decode_stacktrace.sh') diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 2bc3a54ffba5..a0f50a5b4f7c 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -283,6 +283,9 @@ handle_line() { if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} + # some traces format is "(%pS)", which like "(foo+0x0/0x1 [bar])" + # so $module may like "[bar])". Strip the right parenthesis firstly + module=${module%\)} module=${module#\[} module=${module%\]} modbuildid=${module#* } -- cgit v1.2.3