Using perf:
$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg
NOTE: See @GabrielMajeri's comments below about the
-g
option.
This requires you have flamegraph available in your path. The rust-unmangle
script is optional but nice.
Also check out @dlaehnemann's more detailed walkthrough about generating flamegraphs here.
Using valgrind (massif) and massif-visualiser:
$ valgrind --tool=massif binary
Also check out heaptrack, it's similar to massif
but more useful out-of-the-box. It also has a nice gui experience:
$ heaptrack binary
$ rust-gdb binary
Namespaces are prefixed by the crate name, which is probably also the name of the binary. You can do stuff like:
break
to set breakpointsprint
to print a variablestep
,next
,finish
to step through calls