* [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable
@ 2023-12-15 18:26 Elliot Berman
2023-12-15 21:19 ` Justin Stitt
2023-12-18 16:37 ` Nick Desaulniers
0 siblings, 2 replies; 6+ messages in thread
From: Elliot Berman @ 2023-12-15 18:26 UTC (permalink / raw)
To: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Manuel Traut
Cc: linux-arm-msm, linux-kernel, llvm, Elliot Berman
When using LLVM as the compiler, decode_stacktrace should also use
llvm-addr2line. Check if LLVM is set and add the appropriate
suffix/prefix.
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
scripts/decode_stacktrace.sh | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index 564c5632e1a2..189b00f4e120 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -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,
--
Elliot Berman <quic_eberman@quicinc.com>
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable
2023-12-15 18:26 [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable Elliot Berman
@ 2023-12-15 21:19 ` Justin Stitt
2023-12-18 16:37 ` Nick Desaulniers
1 sibling, 0 replies; 6+ messages in thread
From: Justin Stitt @ 2023-12-15 21:19 UTC (permalink / raw)
To: Elliot Berman
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Manuel Traut,
linux-arm-msm, linux-kernel, llvm
Hi,
On Fri, Dec 15, 2023 at 10:27 AM Elliot Berman <quic_eberman@quicinc.com> wrote:
>
> When using LLVM as the compiler, decode_stacktrace should also use
> llvm-addr2line. Check if LLVM is set and add the appropriate
> suffix/prefix.
>
> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> ---
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.
Tested-by: Justin Stitt <justinstitt@google.com>
> scripts/decode_stacktrace.sh | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
> index 564c5632e1a2..189b00f4e120 100755
> --- a/scripts/decode_stacktrace.sh
> +++ b/scripts/decode_stacktrace.sh
> @@ -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,
> --
> Elliot Berman <quic_eberman@quicinc.com>
>
Thanks
Justin
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable
2023-12-15 18:26 [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable Elliot Berman
2023-12-15 21:19 ` Justin Stitt
@ 2023-12-18 16:37 ` Nick Desaulniers
2023-12-19 0:16 ` Justin Stitt
1 sibling, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2023-12-18 16:37 UTC (permalink / raw)
To: Elliot Berman, Masahiro Yamada, Justin Stitt
Cc: Nathan Chancellor, Bill Wendling, Manuel Traut, linux-arm-msm,
linux-kernel, llvm, Will Deacon
On Fri, Dec 15, 2023 at 10:27 AM Elliot Berman <quic_eberman@quicinc.com> wrote:
This patch looks familiar...
https://lore.kernel.org/lkml/20230929034836.403735-1-cmllamas@google.com/
Masahiro, can you please pick up that patch?
Elliot, Justin, can you help test/review that patch?
>
> When using LLVM as the compiler, decode_stacktrace should also use
> llvm-addr2line. Check if LLVM is set and add the appropriate
> suffix/prefix.
>
> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> ---
> scripts/decode_stacktrace.sh | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
> index 564c5632e1a2..189b00f4e120 100755
> --- a/scripts/decode_stacktrace.sh
> +++ b/scripts/decode_stacktrace.sh
> @@ -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,
> --
> Elliot Berman <quic_eberman@quicinc.com>
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable
2023-12-18 16:37 ` Nick Desaulniers
@ 2023-12-19 0:16 ` Justin Stitt
2023-12-19 16:49 ` Nick Desaulniers
0 siblings, 1 reply; 6+ messages in thread
From: Justin Stitt @ 2023-12-19 0:16 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Elliot Berman, Masahiro Yamada, Nathan Chancellor, Bill Wendling,
Manuel Traut, linux-arm-msm, linux-kernel, llvm, Will Deacon
Hi,
On Mon, Dec 18, 2023 at 8:37 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Fri, Dec 15, 2023 at 10:27 AM Elliot Berman <quic_eberman@quicinc.com> wrote:
>
> This patch looks familiar...
> https://lore.kernel.org/lkml/20230929034836.403735-1-cmllamas@google.com/
>
> 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.
> >
> > When using LLVM as the compiler, decode_stacktrace should also use
> > llvm-addr2line. Check if LLVM is set and add the appropriate
> > suffix/prefix.
> >
> > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> > ---
> > scripts/decode_stacktrace.sh | 12 +++++++++++-
> > 1 file changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
> > index 564c5632e1a2..189b00f4e120 100755
> > --- a/scripts/decode_stacktrace.sh
> > +++ b/scripts/decode_stacktrace.sh
> > @@ -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,
> > --
> > Elliot Berman <quic_eberman@quicinc.com>
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers
Thanks
Justin
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable
2023-12-19 0:16 ` Justin Stitt
@ 2023-12-19 16:49 ` Nick Desaulniers
2023-12-19 21:12 ` Justin Stitt
0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2023-12-19 16:49 UTC (permalink / raw)
To: Justin Stitt
Cc: Elliot Berman, Masahiro Yamada, Nathan Chancellor, Bill Wendling,
Manuel Traut, linux-arm-msm, linux-kernel, llvm, Will Deacon
On Mon, Dec 18, 2023 at 4:17 PM Justin Stitt <justinstitt@google.com> wrote:
>
> 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).
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable
2023-12-19 16:49 ` Nick Desaulniers
@ 2023-12-19 21:12 ` Justin Stitt
0 siblings, 0 replies; 6+ messages in thread
From: Justin Stitt @ 2023-12-19 21:12 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Elliot Berman, Masahiro Yamada, Nathan Chancellor, Bill Wendling,
Manuel Traut, linux-arm-msm, linux-kernel, llvm, Will Deacon
On Tue, Dec 19, 2023 at 8:49 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Mon, Dec 18, 2023 at 4:17 PM Justin Stitt <justinstitt@google.com> wrote:
> >
> > 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.
> --
> Thanks,
> ~Nick Desaulniers
Cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-12-19 21:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-15 18:26 [PATCH] scripts/decode_stacktrace.sh: Use LLVM environment variable Elliot Berman
2023-12-15 21:19 ` Justin Stitt
2023-12-18 16:37 ` Nick Desaulniers
2023-12-19 0:16 ` Justin Stitt
2023-12-19 16:49 ` Nick Desaulniers
2023-12-19 21:12 ` Justin Stitt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox