scripts/decode_stacktrace.sh: better support to ARM32 module stack trace
PATCH 1/1 scripts/decode_stacktrace.sh: better support to ARM32 module stack trace
Since System.map is generated by cross-compile nm tool, we should use it here too. Otherwise host nm may not recognize thumb2 function address well.
Beside, sometimes special characters around module name, such as ARM32 with BACKTRACE_VERBOSE in "(%pS)" format, such as:
[<806e4845>] (dump_stack_lvl) from [<7f806013>] (hello_init+0x13/0x1000 [test])
After stripping other characters around "[module]", it can be finally decoded:
(dump_stack_lvl) from hello_init (/foo/test.c:10) test
--- scripts/decode_stacktrace.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
scripts/decode_stacktrace.sh +4 -3
@@ -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
@@ -282,8 +283,8 @@ handle_line() { if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} - module=${module#\[} - module=${module%\]} + module=${module#*\[} + module=${module%\]*} modbuildid=${module#* } module=${module% *} if [[ $modbuildid == $module ]]; then
Signature · 1 line
2.25.1
Sorry about the name, it is some kind of abbreviation. So I re-post here:
---
Since System.map is generated by cross-compile nm tool, we should use it here too. Otherwise host nm may not recognize thumb2 function address well.
Beside, sometimes special characters around module name, such as ARM32 with BACKTRACE_VERBOSE in "(%pS)" format, such as:
[<806e4845>] (dump_stack_lvl) from [<7f806013>] (hello_init+0x13/0x1000 [test])
After stripping other characters around "[module]", it can be finally decoded:
(dump_stack_lvl) from hello_init (/foo/test.c:10) test
--- scripts/decode_stacktrace.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
scripts/decode_stacktrace.sh +4 -3
@@ -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
@@ -282,8 +283,8 @@ handle_line() { if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} - module=${module#\[} - module=${module%\]} + module=${module#*\[} + module=${module%\]*} modbuildid=${module#* } module=${module% *} if [[ $modbuildid == $module ]]; then
Signature · 1 line
2.25.1
Quoted 30 lines · Xiong Nandi
Sorry about the name, it is some kind of abbreviation. So I re-post here:
---
Since System.map is generated by cross-compile nm tool, we should use it here too. Otherwise host nm may not recognize thumb2 function address well.Beside, sometimes special characters around module name, such as ARM32 with
BACKTRACE_VERBOSEin "(%pS)" format, such as:
[<806e4845>] (dump_stack_lvl) from [<7f806013>] (hello_init+0x13/0x1000[test])After stripping other characters around "[module]", it can be finally decoded:
(dump_stack_lvl) fromhello_init(/foo/test.c:10) testSigned-off-by Xiong Nandi <[email protected]>--- scripts/decode_stacktrace.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)scripts/decode_stacktrace.sh +1
-0@@ -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=""
scripts/decode_stacktrace.sh parse_symbol() { · line 162
Quoted 5 lines
scripts/decode_stacktrace.sh +1
-1@@ -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}')
The nm parts should be a separate patch.
scripts/decode_stacktrace.sh handle_line() { · line 287
Quoted 11 lines
scripts/decode_stacktrace.sh +2
-2if [[ $base_addr == "" ]] ; then # address not found return@@ -282,8 +283,8 @@ handle_line() { if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} - module=${module#\[} - module=${module%\]} + module=${module#*\[} + module=${module%\]*}
I need to get a moment to play with it. Is my understanding correct that the problem is that the last word ($module) is:
[test])
and after the existing strip logic, $module becomes test]) whereas expecting just "test"? Your change is to strip any leading/trailing characters before/after the [ / ] respectively? Isn't this a problem for $symbol as well -- it would be "(hello_init+0x13/0x1000" in the example.
- Elliot
Quoted 6 lines
scripts/decode_stacktrace.sh +0
-0modbuildid=${module#* } module=${module% *} if [[ $modbuildid == $module ]]; thenSignature · 1 line
2.25.1
Thanks, I'll split it into 2 patches later.
Quoted 1 line
Your change is to strip any leading/trailing characters before/after the [ / ] respectively?
Yes, exactly.
Quoted 1 line
Isn't this a problem for $symbol as well
there is already a strip logic in "parse_symbol()", which seems introduced by #e260fe01, also for ARM.
Quoted 3 lines
# Remove the englobing parenthesis
symbol=${symbol#\(}
symbol=${symbol%\)}
Quoted 70 lines · Elliot Berman
Quoted 30 lines · Xiong Nandi
Sorry about the name, it is some kind of abbreviation. So I re-post here:
---
Since System.map is generated by cross-compile nm tool, we should use it here too. Otherwise host nm may not recognize thumb2 function address well.Beside, sometimes special characters around module name, such as ARM32 with
BACKTRACE_VERBOSEin "(%pS)" format, such as:
[<806e4845>] (dump_stack_lvl) from [<7f806013>] (hello_init+0x13/0x1000[test])After stripping other characters around "[module]", it can be finally decoded:
(dump_stack_lvl) fromhello_init(/foo/test.c:10) testSigned-off-by Xiong Nandi <[email protected]>--- scripts/decode_stacktrace.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)scripts/decode_stacktrace.sh +1
-0@@ -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=""scripts/decode_stacktrace.sh parse_symbol() { · line 162
Quoted 5 lines
scripts/decode_stacktrace.sh +1
-1@@ -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}')The nm parts should be a separate patch.
scripts/decode_stacktrace.sh handle_line() { · line 287
Quoted 11 lines
scripts/decode_stacktrace.sh +2
-2if [[ $base_addr == "" ]] ; then # address not found return@@ -282,8 +283,8 @@ handle_line() { if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} - module=${module#\[} - module=${module%\]} + module=${module#*\[} + module=${module%\]*}I need to get a moment to play with it. Is my understanding correct that the problem is that the last word ($module) is:
[test])
and after the existing strip logic, $module becomes test]) whereas expecting just "test"? Your change is to strip any leading/trailing characters before/after the [ / ] respectively? Isn't this a problem for $symbol as well -- it would be "(
hello_init+0x13/0x1000" in the example.- Elliot
Quoted 6 lines
scripts/decode_stacktrace.sh +0
-1modbuildid=${module#* } module=${module% *} if [[ $modbuildid == $module ]]; then --2.25.1
v2 cover scripts/decode_stacktrace.sh: better support to ARM32
In reply to Elliot Bermanv2:
- Split the patch into two.
Xiong Nandi (2):
scripts/decode_stacktrace.sh: better support to ARM32 module stack trace scripts/decode_stacktrace.sh: wrap nm with UTIL_PREFIX and UTIL_SUFFIX
scripts/decode_stacktrace.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 scripts/decode_stacktrace.sh: wrap nm with UTIL_PREFIX and UTIL_SUFFIX
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.
--- scripts/decode_stacktrace.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/decode_stacktrace.sh +2 -1
@@ -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
Signature · 1 line
2.25.1
PATCH v2 2/2 scripts/decode_stacktrace.sh: better support to ARM32 module stack trace
In reply to Xiong NandiSometimes there is special characters around module name in stack trace, such as ARM32 with BACKTRACE_VERBOSE in "(%pS)" format, such as:
[<806e4845>] (dump_stack_lvl) from [<7f806013>] (hello_init+0x13/0x1000 [test])
After stripping other characters around "[module]", it can be finally decoded:
(dump_stack_lvl) from hello_init (/foo/test.c:10) test
--- scripts/decode_stacktrace.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/decode_stacktrace.sh +2 -2
@@ -283,8 +283,8 @@ handle_line() { if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} - module=${module#\[} - module=${module%\]} + module=${module#*\[} + module=${module%\]*} modbuildid=${module#* } module=${module% *} if [[ $modbuildid == $module ]]; then
Signature · 1 line
2.25.1
Re: [PATCH v2 1/2] scripts/decode_stacktrace.sh: wrap nm with UTIL_PREFIX and UTIL_SUFFIX
In reply to Xiong NandiQuoted 4 lines · Xiong Nandi
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 <[email protected]>
Quoted 28 lines
--- scripts/decode_stacktrace.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)scripts/decode_stacktrace.sh +2
-1@@ -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 returnSignature · 1 line
2.25.1
Quoted 17 lines · Xiong Nandi
Sometimes there is special characters around module name in stack trace, such as ARM32 with
BACKTRACE_VERBOSEin "(%pS)" format, such as:
[<806e4845>] (dump_stack_lvl) from [<7f806013>] (hello_init+0x13/0x1000[test])After stripping other characters around "[module]", it can be finally decoded:
(dump_stack_lvl) fromhello_init(/foo/test.c:10) testSigned-off-by Xiong Nandi <[email protected]>--- scripts/decode_stacktrace.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)scripts/decode_stacktrace.sh +0
-0
scripts/decode_stacktrace.sh handle_line() { · line 287
Quoted 7 lines
scripts/decode_stacktrace.sh +2
-2@@ -283,8 +283,8 @@ handle_line() { if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} - module=${module#\[} - module=${module%\]} + module=${module#*\[} + module=${module%\]*}
I think it'd be better to just remove the parenthesis similar to how is done in the symbol name.
That is:
module=${words[$last]}
module=${module#\[}
module=${module%\]}
# some nice comment explaining only the closing paren is
# need to be stripped
module=${module%\)}
modbuildid=${module#* }Quoted 6 lines
scripts/decode_stacktrace.sh +0
-0modbuildid=${module#* } module=${module% *} if [[ $modbuildid == $module ]]; thenSignature · 1 line
2.25.1