]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scripts: decode_stacktrace: demangle Rust symbols
authorMiguel Ojeda <ojeda@kernel.org>
Sun, 5 Dec 2021 18:00:43 +0000 (19:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Feb 2024 07:42:31 +0000 (08:42 +0100)
[ Upstream commit 99115db4ecc87af73415939439ec604ea0531e6f ]

Recent versions of both Binutils (`c++filt`) and LLVM (`llvm-cxxfilt`)
provide Rust v0 mangling support.

Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Stable-dep-of: efbd63983533 ("scripts/decode_stacktrace.sh: optionally use LLVM utilities")
Signed-off-by: Sasha Levin <sashal@kernel.org>
scripts/decode_stacktrace.sh

index 51d48bf65fd76e4166341f4bfb2fb7a81c1757c0..2157332750d5b17f97be8e9c34679d0203d45d8e 100755 (executable)
@@ -9,6 +9,14 @@ if [[ $# < 1 ]]; then
        exit 1
 fi
 
+# Try to find a Rust demangler
+if type llvm-cxxfilt >/dev/null 2>&1 ; then
+       cppfilt=llvm-cxxfilt
+elif type c++filt >/dev/null 2>&1 ; then
+       cppfilt=c++filt
+       cppfilt_opts=-i
+fi
+
 if [[ $1 == "-r" ]] ; then
        vmlinux=""
        basepath="auto"
@@ -157,6 +165,12 @@ parse_symbol() {
        # In the case of inlines, move everything to same line
        code=${code//$'\n'/' '}
 
+       # Demangle if the name looks like a Rust symbol and if
+       # we got a Rust demangler
+       if [[ $name =~ ^_R && $cppfilt != "" ]] ; then
+               name=$("$cppfilt" "$cppfilt_opts" "$name")
+       fi
+
        # Replace old address with pretty line numbers
        symbol="$segment$name ($code)"
 }