فهرست منبع

Fixed #TASK_GK-2944 横向串联

Carl 2 سال پیش
والد
کامیت
b94f36689a
2فایلهای تغییر یافته به همراه94 افزوده شده و 0 حذف شده
  1. 30 0
      Makefile2
  2. 64 0
      ebpftracer/build_linux.sh

+ 30 - 0
Makefile2

@@ -0,0 +1,30 @@
+FILTER=
+PARAMS=
+ifeq ($(debug),1)
+PARAMS+=debug=-D_DEBUG_MODE
+endif
+
+ifdef pid
+	ifneq ($(pid),0)
+		PARAMS+=pid=$(pid)
+		FILTER=FILTER_PID=${pid}
+	endif
+endif
+
+debug:
+	exit
+build:
+	CGO_ENABLED=1 go build -buildvcs=false -o euspace
+c:
+	#docker exec -it 9d928d96d4d0 sh -c 'cd /opt/github/euspace/ebpftracer && sh build.sh${PARAMS}'
+	docker exec -it 62d0676aa0b7 sh -c 'cd /opt/github/euspace/ebpftracer && sh build_linux.sh${PARAMS}'
+c-build: c
+
+go-build:
+	#ssh [email protected] 'export https_proxy=http://10.0.22.50:4780 && source ~/.g/env && cd /opt/github/euspace && make -f Makefile2 build'
+	docker exec -it 62d0676aa0b7 bash -c 'cd /opt/github/euspace && source ~/.g/env && make -f Makefile2 build'
+go: go-build run
+
+run:
+	ssh [email protected] 'cd /opt/github/euspace && TRACES_ENDPOINT=http://10.0.12.192:18080/docp/api/v2/data/receive ${FILTER} ./euspace --listen="0.0.0.0:8123"'
+all: c go run

+ 64 - 0
ebpftracer/build_linux.sh

@@ -0,0 +1,64 @@
+# 遍历所有参数
+for arg in "$@"
+do
+    # 分割参数名和值
+    key="${arg%%=*}"
+    value="${arg#*=}"
+
+    # 检查参数名并根据需要处理参数值
+    case "$key" in
+        pid)
+            pid="$value"
+            ;;
+        debug)
+            debug="$value"
+            ;;
+        *)
+            echo "Unknown parameter: $key"
+            ;;
+    esac
+done
+
+# 打印解析的参数值
+echo "pid: $pid"
+echo "debug: $debug"
+
+#clang -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include/generated -isystem/usr/src/linux-headers-5.15.0-89-generic/include -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include/uapi -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include/generated/uapi -isystem/usr/src/linux-headers-5.15.0-89-generic/include/uapi -isystem/usr/src/linux-headers-5.15.0-89-generic/include/generated/uapi -include linux/kconfig.h -I./ebpf/c/common -include asm_goto_workaround.h -D__KERNEL__ -D__BPF_TRACING__ "" -fno-stack-protector -g -Wno-unused-value -Wno-pointer-sign -Wno-compare-distinct-pointer-types -Wno-gnu-variable-sized-type-not-at-end -Wno-address-of-packed-member -Wno-tautological-compare -Wno-unknown-warning-option -O2 -target bpf -D__KERNEL_FROM=512 -D__TARGET_ARCH_x86 -c ./ebpf/ebpf.c -o ./ebpf512x86.o
+#clang -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include/generated -isystem/usr/src/linux-headers-5.15.0-89-generic/include -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include/uapi -isystem/usr/src/linux-headers-5.15.0-89-generic/arch/x86/include/generated/uapi -isystem/usr/src/linux-headers-5.15.0-89-generic/include/uapi -isystem/usr/src/linux-headers-5.15.0-89-generic/include/generated/uapi -include linux/kconfig.h -g -O2 -target bpf -D__KERNEL_FROM=512 -D__TARGET_ARCH_x86 -c ./ebpf/ebpf.c -o ebpf512x86.o
+#clang -g -O2 -target bpf -D__KERNEL_FROM=512 -D__TARGET_ARCH_x86 -D__x86_64__ $debug $TAG -c ./ebpf/ebpf.c -o ebpf512x86.o && llvm-strip --strip-debug ebpf512x86.o
+#llvm-strip --strip-debug ./ebpf512x86.o
+#chown 501:dialout ./ebpf512x86.o
+/usr/bin/clang -I. -Ivmlinux -Iinclude -Iebpf/utrace/go/include  -D__BPF_TRACING__ -D GROUP_LEADER_OFFSET_OVERRIDE=0 -DSTART_BOOTTIME_OFFSET_OVERRIDE=0 -DSTART_BOOTTIME_VARNAME=real_start_time  -std=gnu99 -Wimplicit-function-declaration \
+	-ffreestanding -fno-builtin -Wall \
+	-Wno-deprecated-declarations \
+	-Wno-gnu-variable-sized-type-not-at-end \
+	-Wno-pragma-once-outside-header \
+	-Wno-address-of-packed-member \
+	-Wno-unknown-warning-option \
+	-fno-color-diagnostics \
+	-fno-unwind-tables \
+	-fno-stack-protector \
+	-fno-asynchronous-unwind-tables -g -O2 -emit-llvm -D__KERNEL_FROM=512 -D__TARGET_ARCH_x86 -D__x86_64__  $debug -o ebpf.ll -c ./ebpf/ebpf.c && /usr/bin/llc -march=bpf -filetype=obj -mcpu=v2 -o ebpf.elf ebpf.ll
+
+/usr/bin/llvm-strip -g ebpf.elf  && mv ebpf.elf ebpf512x86.o
+
+echo -en '// generated - do not edit\npackage ebpftracer\n\nvar ebpfProg = map[string][]struct {\n' > ebpf.go \
+	&& echo -en '\tv string\n' >> ebpf.go \
+	&& echo -en '\tp []byte\n' >> ebpf.go \
+	&& echo -en '}{\n' >> ebpf.go \
+	&& echo -en '\t"amd64": {\n' >> ebpf.go \
+	&& echo -en '\t\t{"v5.12", []byte("' >> ebpf.go && hexdump -v -e '"\\\x" 1/1 "%02x"' ebpf512x86.o >> ebpf.go && echo '")},' >> ebpf.go \
+	&& echo -en '\t},\n'>> ebpf.go \
+	&& echo -en '\t"arm64": {\n' >> ebpf.go \
+	&& echo -en '\t\t{"v5.12", []byte("' >> ebpf.go && hexdump -v -e '"\\\x" 1/1 "%02x"' ebpf512x86.o >> ebpf.go && echo '")},' >> ebpf.go \
+	&& echo -en '\t},\n'>> ebpf.go \
+	&& echo -en '}\n'>> ebpf.go
+if [ $? -ne 0 ]; then
+  echo "error!"
+  exit 1
+fi
+echo "success!"
+
+
+#apk add bcc-dev
+#apk add musl-dev