[PATCH v2 1/2] scripts/decode_stacktrace.sh: wrap nm with UTIL_PREFIX and UTIL_SUFFIX

Xiong Nandi posted 2 patches 1 year, 8 months ago
There is a newer version of this series
[PATCH v2 1/2] scripts/decode_stacktrace.sh: wrap nm with UTIL_PREFIX and UTIL_SUFFIX
Posted by Xiong Nandi 1 year, 8 months ago
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.

Signed-off-by: Xiong Nandi <xndchn@gmail.com>
---
 scripts/decode_stacktrace.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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
-- 
2.25.1
Re: [PATCH v2 1/2] scripts/decode_stacktrace.sh: wrap nm with UTIL_PREFIX and UTIL_SUFFIX
Posted by Elliot Berman 1 year, 8 months ago
On Thu, May 23, 2024 at 09:03:17AM +0800, Xiong Nandi wrote:
> 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.
> 
> Signed-off-by: Xiong Nandi <xndchn@gmail.com>

Reviewed-by: Elliot Berman <quic_eberman@quicinc.com>

> ---
>  scripts/decode_stacktrace.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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
> -- 
> 2.25.1
>