summaryrefslogtreecommitdiff
path: root/rust-unmangle
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2020-01-12 20:36:45 +0100
committerDennis Kobert <dennis@kobert.dev>2020-01-12 20:36:45 +0100
commit70fa220f7a2b1b2275679547ac21768ab657cea2 (patch)
treed5d618aaac9968a555e59f9bb5df148026de0160 /rust-unmangle
parente3b8e2dadec5009ec1c3de72a202583f65129993 (diff)
Add diagnostic script, prune result evaluation
Diffstat (limited to 'rust-unmangle')
-rwxr-xr-xrust-unmangle32
1 files changed, 32 insertions, 0 deletions
diff --git a/rust-unmangle b/rust-unmangle
new file mode 100755
index 0000000..183f7f9
--- /dev/null
+++ b/rust-unmangle
@@ -0,0 +1,32 @@
+#!/usr/bin/sed -rf
+# Unmangle Rust symbols
+# See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=cae15db74999edb96dd9f5bbd4d55849391dd92b
+# Example, with [FlameGraph](https://github.com/brendangregg/FlameGraph):
+# perf record -g target/debug/bin
+# perf script | stackcollapse-perf | rust-unmangle | flamegraph > perf.svg
+
+# Remove hash and address offset
+s/::h[0-9a-f]{16}//g
+s/\+0x[0-9a-f]+//g
+
+# Convert special characters
+s/\$C\$/,/g
+s/\$SP\$/@/g
+s/\$BP\$/*/g
+s/\$RF\$/\&/g
+s/\$LT\$/</g
+s/\$GT\$/>/g
+s/\$LP\$/(/g
+s/\$RP\$/)/g
+s/\$u20\$/ /g
+s/\$u27\$/'/g
+s/\$u5b\$/[/g
+s/\$u5d\$/]/g
+s/\$u7b\$/{/g
+s/\$u7d\$/}/g
+s/\$u7e\$/~/g
+
+# Fix . and _
+s/\.\./::/g
+s/[^\.]\.[^\.]/./g
+s/([;:])_/\1/g