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
8 echo " $0 -r <release> | <vmlinux> [<base path>|auto] [<modules path>]"8 echo " $0 -r <release> | <vmlinux> [<base path>|auto] [<modules path>]"
9}9}
10 10
11# Try to find a Rust demangler
12if type llvm-cxxfilt >/dev/null 2>&1 ; then
13 cppfilt=llvm-cxxfilt
14elif type c++filt >/dev/null 2>&1 ; then
15 cppfilt=c++filt
16 cppfilt_opts=-i
17fi
18
11if [[ $1 == "-r" ]] ; then19if [[ $1 == "-r" ]] ; then
12 vmlinux=""20 vmlinux=""
13 basepath="auto"21 basepath="auto"
@@ -180,6 +188,12 @@ parse_symbol() { · 166 unmodified lines
180 # In the case of inlines, move everything to same line188 # In the case of inlines, move everything to same line
181 code=${code//$'\n'/' '}189 code=${code//$'\n'/' '}
182 190
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
183 # Replace old address with pretty line numbers197 # Replace old address with pretty line numbers
184 symbol="$segment$name ($code)"198 symbol="$segment$name ($code)"
185}199}