在过去的几天里,我一直在使用 Rust 分析器、火焰图,非常成功。当我从 bash 运行它时,它工作正常。没有 sudo 或任何东西。
~/.cargo/bin/flamegraph -o "$f flamegraph.svg" ./binary
当我使用 process::Command 从 Rust 运行它时,它只是说它无法对折叠的堆栈进行采样。
let svgfilename = format!("{} flamegraph.svg", path);
let execution = std::process::Command::new("/home/arkadiusz/.cargo/bin/flamegraph")
.arg("-o").arg(&svgfilename)
.arg("./binary").arg("solve").arg("real-data").arg("/dev/null")
.output().unwrap();
完整错误:
WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.
Samples in kernel functions may not be resolved if a suitable vmlinux
file is not found in the buildid cache or in the vmlinux path.
Samples in kernel modules won't be resolved at all.
If some relocation was applied (e.g. kexec) symbols may be misresolved
even with a suitable vmlinux or kallsyms file.
Couldn't record kernel reference relocation symbol
Symbol resolution may be skewed if relocation was used (e.g. kexec).
Check /proc/kallsyms permission or run as root.
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0,000 MB (null) ]
thread 'main' panicked at 'unable to generate a flamegraph from the collapsed stack data: Io(Custom { kind: InvalidData, error: "No stack counts found" })', /home/arkadiusz/.cargo/registry/src/github.com-1ecc6299db9ec823/flamegraph-0.4.0/src/lib.rs:315:6
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace