Recent versions of both Binutils (`c++filt`) and LLVM (`llvm-cxxfilt`) provide Rust v0 mangling support.
Showing the changes to scripts/decode_stacktrace.sh (1 of 1 file). Show all
Unified · Split
| @@ -8,6 +8,14 @@ usage() { · 7 unmodified lines | ||
| 8 | 8 | echo " $0 -r <release> | <vmlinux> [<base path>|auto] [<modules path>]" |
| 9 | 9 | } |
| 10 | 10 | |
| 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 | + | |
| 11 | 19 | if [[ $1 == "-r" ]] ; then |
| 12 | 20 | vmlinux="" |
| 13 | 21 | basepath="auto" |
| @@ -180,6 +188,12 @@ parse_symbol() { · 166 unmodified lines | ||
| 180 | 188 | # In the case of inlines, move everything to same line |
| 181 | 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 | 197 | # Replace old address with pretty line numbers |
| 184 | 198 | symbol="$segment$name ($code)" |
| 185 | 199 | } |