History

scripts: decode_stacktrace: demangle Rust symbols

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

Miguel Ojeda committed 4 years ago

Commit 99115db1 parent d1d84b51 file · +14 −0Browse files

Showing the changes to scripts/decode_stacktrace.sh (1 of 1 file). Show all

Unified · Split

scripts/decode_stacktrace.sh+14−0
@@ -8,6 +8,14 @@ usage() { · 7 unmodified lines
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"
@@ -180,6 +188,12 @@ parse_symbol() { · 166 unmodified lines
180188 # In the case of inlines, move everything to same line
181189 code=${code//$'\n'/' '}
182190
191+ # Demangle if the name looks like a Rust symbol and if
192+ # we got a Rust demangler
193+ if [[ $name =~ ^_R && $cppfilt != "" ]] ; then
194+ name=$("$cppfilt" "$cppfilt_opts" "$name")
195+ fi
196+
183197 # Replace old address with pretty line numbers
184198 symbol="$segment$name ($code)"
185199 }