代码拉取完成,页面将自动刷新
同步操作将从 openEuler/X-diagnosis 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
PRJ_DIR=$(dirname $(readlink -f "$0"))
PAHOLE=/usr/bin/pahole
BPFTOOL=/usr/sbin/bpftool
SRC_DIR=${PRJ_DIR}/xdiagnose
VMLINUX_DIR=${SRC_DIR}/common/include
VMLINUX_H=${VMLINUX_DIR}/vmlinux.h
KN_HEAD_DIR=${SRC_DIR}/cmdfile/kernel
DEBUGVERSION=""
VMLINUX=""
function print_help()
{
echo "Usage: $0 OPERATOR OPTIONS"
echo "OPERATOR: "
echo " -i build and install"
echo " -b build"
echo " -c clean"
}
function clean()
{
cd ${SRC_DIR}
make clean
}
function check_env()
{
[ ! -f $BPFTOOL ] && {
echo "bpftool is not install, please install it first"
exit 1
}
[ ! -f $BPFTOOL ] && {
echo "pahole is not install, please install dwarves first"
exit 1
}
kernel_debuginfo=`rpm -q kernel-debuginfo`
[ $? != 0 ] && {
echo "kernel-debuginfo is not install, please install it first"
exit 1
}
DEBUGVERSION=`rpm -q --qf '%{version}-%{release}.%{arch}' kernel-debuginfo`
VMLINUX="/usr/lib/debug/lib/modules/$DEBUGVERSION/vmlinux"
[ ! -f ${VMLINUX} ] && {
echo "${VMLINUX} is not exist"
exit 1
}
}
function gen_vmlinux_h()
{
[ ! -f ${VMLINUX_H} ]&& {
echo "go to generate vmlinux.h"
[ ! -d ${VMLINUX_DIR} ]&& {
mkdir -p ${VMLINUX_DIR}
}
cp ${VMLINUX} vmlinux_tmp
bpf_support=`objdump -h vmlinux_tmp |grep '\.BTF'`
[ "f${bpf_support}" == "f" ] && {
pahole -J vmlinux_tmp
}
bpftool btf dump file vmlinux_tmp format c > ${VMLINUX_H}
[ $? != 0 ] && {
echo "generate vmlinux.h failed, ${VMLINUX} is not supported"
rm -rf vmlinux_tmp ${VMLINUX_H}
exit 1
}
rm -rf vmlinux_tmp
}
mkdir -p ${KN_HEAD_DIR}
[ ! -f ${KN_HEAD_DIR}/${DEBUGVERSION}.f ]&& {
gdb --batch --ex "info functions" ${VMLINUX} > ${KN_HEAD_DIR}/${DEBUGVERSION}.f
}
[ ! -f ${KN_HEAD_DIR}/${DEBUGVERSION}.h ]&& {
pahole ${VMLINUX} > ${KN_HEAD_DIR}/${DEBUGVERSION}.h
}
}
function build()
{
check_env
gen_vmlinux_h
echo "start compile"
cd ${SRC_DIR}
make
}
function install()
{
cd ${SRC_DIR}
export DESTDIR=$1
make install
}
[ "$1" == "-c" ] && {
clean
exit 0
}
[ "$1" == "-b" ] && {
build
exit 0
}
[ "$1" == "-i" ] && {
INTALL_DIR=$2
[ -z $2 ] && {
INTALL_DIR=/usr/bin/xdiag/ebpf
mkdir -p ${INTALL_DIR}
}
install ${INTALL_DIR}
exit 0
}
if [ -z $1 ] || [ $1 == "-h" ]
then
print_help
exit 0
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。