Skip to content

Commit dd297ec

Browse files
authored
Merge pull request #588 from ojeda/demangle
scripts: decode_stacktrace: demangle Rust symbols
2 parents 24ed7ed + ea7c86c commit dd297ec

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

scripts/decode_stacktrace.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ usage() {
88
echo " $0 -r <release> | <vmlinux> [<base path>|auto] [<modules path>]"
99
}
1010

11+
# Try to find a Rust demangler
12+
if type llvm-cxxfilt >/dev/null 2>&1 ; then
13+
cppfilt=llvm-cxxfilt
14+
elif type c++filt >/dev/null 2>&1 ; then
15+
cppfilt=c++filt
16+
cppfilt_opts=-i
17+
fi
18+
1119
if [[ $1 == "-r" ]] ; then
1220
vmlinux=""
1321
basepath="auto"
@@ -169,6 +177,12 @@ parse_symbol() {
169177
# In the case of inlines, move everything to same line
170178
code=${code//$'\n'/' '}
171179

180+
# Demangle if the name looks like a Rust symbol and if
181+
# we got a Rust demangler
182+
if [[ $name =~ ^_R && $cppfilt != "" ]] ; then
183+
name=$("$cppfilt" "$cppfilt_opts" "$name")
184+
fi
185+
172186
# Replace old address with pretty line numbers
173187
symbol="$segment$name ($code)"
174188
}

0 commit comments

Comments
 (0)