scripts/decode_stacktrace.sh: Use LLVM environment variable
PATCH 1/1 scripts/decode_stacktrace.sh: Use LLVM environment variable
When using LLVM as the compiler, decode_stacktrace should also use llvm-addr2line. Check if LLVM is set and add the appropriate suffix/prefix.
--- scripts/decode_stacktrace.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
scripts/decode_stacktrace.sh +11 -1
@@ -16,6 +16,16 @@ elif type c++filt >/dev/null 2>&1 ; then cppfilt_opts=-i fi +if [[ "${LLVM}" == "1" ]] ; then + addr2line="llvm-addr2line" +elif [[ "${LLVM}" == */ ]] ; then + addr2line="${LLVM}llvm-addr2line" +elif [[ "${LLVM}" == -* ]] ; then + addr2line="llvm-addr2line${LLVM}" +else + addr2line="${CROSS_COMPILE}addr2line" +fi + if [[ $1 == "-r" ]] ; then vmlinux="" basepath="auto"
@@ -169,7 +179,7 @@ parse_symbol() { if [[ $aarray_support == true && "${cache[$module,$address]+isset}" == "isset" ]]; then local code=${cache[$module,$address]} else - local code=$(${CROSS_COMPILE}addr2line -i -e "$objfile" "$address" 2>/dev/null) + local code=$(${addr2line} -i -e "$objfile" "$address" 2>/dev/null) if [[ $aarray_support == true ]]; then cache[$module,$address]=$code fi
---
base-commit: 3f7168591ebf7bbdb91797d02b1afaf00a4289b1
change-id: 20231214-llvm-decode-stacktrace-09538979006d
Best regards,
Signature · 1 line
Elliot Berman <[email protected]>
Hi,
Quoted 7 lines · Elliot Berman
When using LLVM as the compiler,
decode_stacktraceshould also use llvm-addr2line. Check if LLVM is set and add the appropriate suffix/prefix.Signed-off-by Elliot Berman <[email protected]>---
I tried it out by dropping a random dump_stack() call into the init phase of the kernel and redirecting the serial console output to a log file. Using the pre-(this patch) and post-(this patch) script yields good stack trace results. It seems llvm-addr2line is a drop-in replacement.
Quoted 38 lines
scripts/decode_stacktrace.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)scripts/decode_stacktrace.sh +11
-2@@ -16,6 +16,16 @@ elif type c++filt >/dev/null 2>&1 ; then cppfilt_opts=-i fi +if [[ "${LLVM}" == "1" ]] ; then + addr2line="llvm-addr2line" +elif [[ "${LLVM}" == */ ]] ; then + addr2line="${LLVM}llvm-addr2line" +elif [[ "${LLVM}" == -* ]] ; then + addr2line="llvm-addr2line${LLVM}" +else + addr2line="${CROSS_COMPILE}addr2line" +fi + if [[ $1 == "-r" ]] ; then vmlinux="" basepath="auto"@@ -169,7 +179,7 @@ parse_symbol() { if [[ $aarray_support == true && "${cache[$module,$address]+isset}" == "isset" ]]; then local code=${cache[$module,$address]} else - local code=$(${CROSS_COMPILE}addr2line -i -e "$objfile" "$address" 2>/dev/null) + local code=$(${addr2line} -i -e "$objfile" "$address" 2>/dev/null) if [[ $aarray_support == true ]]; then cache[$module,$address]=$code fi ---base-commit:
3f7168591ebf7bbdb91797d02b1afaf00a4289b1
change-id: 20231214-llvm-decode-stacktrace-09538979006d
Quoted 4 lines
Best regards,
--
Elliot Berman <[email protected]>
Thanks
Justin
On Fri, Dec 15, 2023 at 10:27 AM Elliot Berman <[email protected]> wrote:
This patch looks familiar...
https://lore.kernel.org/lkml/[email protected]/
Masahiro, can you please pick up that patch?
Elliot, Justin, can you help test/review that patch?
Quoted 49 lines
When using LLVM as the compiler,
decode_stacktraceshould also use llvm-addr2line. Check if LLVM is set and add the appropriate suffix/prefix.Signed-off-by Elliot Berman <[email protected]>--- scripts/decode_stacktrace.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)scripts/decode_stacktrace.sh +11
-2@@ -16,6 +16,16 @@ elif type c++filt >/dev/null 2>&1 ; then cppfilt_opts=-i fi +if [[ "${LLVM}" == "1" ]] ; then + addr2line="llvm-addr2line" +elif [[ "${LLVM}" == */ ]] ; then + addr2line="${LLVM}llvm-addr2line" +elif [[ "${LLVM}" == -* ]] ; then + addr2line="llvm-addr2line${LLVM}" +else + addr2line="${CROSS_COMPILE}addr2line" +fi + if [[ $1 == "-r" ]] ; then vmlinux="" basepath="auto"@@ -169,7 +179,7 @@ parse_symbol() { if [[ $aarray_support == true && "${cache[$module,$address]+isset}" == "isset" ]]; then local code=${cache[$module,$address]} else - local code=$(${CROSS_COMPILE}addr2line -i -e "$objfile" "$address" 2>/dev/null) + local code=$(${addr2line} -i -e "$objfile" "$address" 2>/dev/null) if [[ $aarray_support == true ]]; then cache[$module,$address]=$code fi ---base-commit:
3f7168591ebf7bbdb91797d02b1afaf00a4289b1
change-id: 20231214-llvm-decode-stacktrace-09538979006dBest regards,
--
Elliot Berman <[email protected]>
Signature · 2 lines
Thanks, ~Nick Desaulniers
Hi,
Quoted 10 lines · Nick Desaulniers
On Fri, Dec 15, 2023 at 10:27 AM Elliot Berman <[email protected]> wrote:
This patch looks familiar...
https://lore.kernel.org/lkml/[email protected]/Masahiro, can you please pick up that patch?
Elliot, Justin, can you help test/review that patch?
Interestingly, I am getting good stack traces on mainline with a LLVM-built kernel -- both with and without that patch.
It may help others, so I'll go to that patch and add my tested-by.
Quoted 45 lines
Quoted 45 lines
When using LLVM as the compiler,
decode_stacktraceshould also use llvm-addr2line. Check if LLVM is set and add the appropriate suffix/prefix.Signed-off-by Elliot Berman <[email protected]>--- scripts/decode_stacktrace.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)scripts/decode_stacktrace.sh +11
-2@@ -16,6 +16,16 @@ elif type c++filt >/dev/null 2>&1 ; then cppfilt_opts=-i fi +if [[ "${LLVM}" == "1" ]] ; then + addr2line="llvm-addr2line" +elif [[ "${LLVM}" == */ ]] ; then + addr2line="${LLVM}llvm-addr2line" +elif [[ "${LLVM}" == -* ]] ; then + addr2line="llvm-addr2line${LLVM}" +else + addr2line="${CROSS_COMPILE}addr2line" +fi + if [[ $1 == "-r" ]] ; then vmlinux="" basepath="auto"@@ -169,7 +179,7 @@ parse_symbol() { if [[ $aarray_support == true && "${cache[$module,$address]+isset}" == "isset" ]]; then local code=${cache[$module,$address]} else - local code=$(${CROSS_COMPILE}addr2line -i -e "$objfile" "$address" 2>/dev/null) + local code=$(${addr2line} -i -e "$objfile" "$address" 2>/dev/null) if [[ $aarray_support == true ]]; then cache[$module,$address]=$code fi ---base-commit:
3f7168591ebf7bbdb91797d02b1afaf00a4289b1
change-id: 20231214-llvm-decode-stacktrace-09538979006d
Quoted 9 lines
Quoted 4 lines
Best regards,
--
Elliot Berman <[email protected]>--
Thanks,
~Nick Desaulniers
Thanks
Justin
Quoted 3 lines · Justin Stitt
Interestingly, I am getting good stack traces on mainline with a LLVM-built kernel -- both with and without that patch.
Probably because:
1. you have GNU binutils installed.
2. you're not testing .o files from an LTO build (which GNU binutils cannot decode).
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 11 lines · Nick Desaulniers
Quoted 3 lines · Justin Stitt
Interestingly, I am getting good stack traces on mainline with a LLVM-built kernel -- both with and without that patch.
Probably because:
1. you have GNU binutils installed.
2. you're not testing .o files from an LTO build (which GNU binutils cannot decode).
Yes, and yes. Makes sense.
Quoted 3 lines
--
Thanks,
~Nick Desaulniers
Cheers