Skip to content

Commit

Permalink
Merge pull request torvalds#588 from ojeda/demangle
Browse files Browse the repository at this point in the history
scripts: decode_stacktrace: demangle Rust symbols
  • Loading branch information
ojeda authored Dec 5, 2021
2 parents 24ed7ed + ea7c86c commit dd297ec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/decode_stacktrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ usage() {
echo " $0 -r <release> | <vmlinux> [<base path>|auto] [<modules path>]"
}

# 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"
Expand Down Expand Up @@ -169,6 +177,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)"
}
Expand Down

0 comments on commit dd297ec

Please sign in to comment.