Bash/Rust 问题:从 Bash 运行火焰图有效,从 Rust 失败

问题描述

过去几天我一直在使用 Rusts 分析器、火焰图,非常成功。当我从 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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)