bpftrace报:Could not resolve symbol: /proc/self/exe:BEGIN_trigger解决方案

在ubuntu上使用bpftrace时,如果脚本中包含"BEGIN"或者"END"这些符号就会报如下的错误:

Could not resolve symbol: /proc/self/exe:BEGIN_trigger

这是因为apt安装的bpftrace是strip过的,没有debug symbol,而BEGIN/END存在于debug symbol中。解决的办法是安装bpftrace的debug symbol。

首先要引入debug symbol源。

echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \
sudo tee -a /etc/apt/sources.list.d/ddebs.list

然后更新源,安装debug symbol

apt update
sudo apt-get install bpftrace-dbgsym

如果你的机器不能连外网,可以在一台可以联网的机器上安装好bpftrace-dbgsym之后将其打成deb包,再迁移到目标机器上。

posted on 2025-05-21 14:14  半山随笔  阅读(80)  评论(0)    收藏  举报

导航