diff --git a/Makefile b/Makefile index b5a25658..fef7998a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ .DEFAULT_GOAL=test +SHELL := /bin/bash GO_SRC := $(shell find . -type f -not -path './_fixtures/*' -not -path './vendor/*' -not -path './_scripts/*' -not -path './localtests/*' -name '*.go') check-cert: @@ -29,4 +30,10 @@ test-integration-run: vendor: @go run _scripts/make.go vendor -.PHONY: vendor test-integration-run test-proc-run test check-cert install build vet uninstall +build-ebpf-image: + ./pkg/proc/internal/ebpf/build/build-ebpf-builder-img.sh + +build-ebpf-object: build-ebpf-image + ./pkg/proc/internal/ebpf/build/build-ebpf-objects.sh + +.PHONY: vendor test-integration-run test-proc-run test check-cert install build vet uninstall build-ebpf-image build-ebpf-object diff --git a/cmd/dlv/dlv_test.go b/cmd/dlv/dlv_test.go index b3f9b6d3..eb1f0b6e 100644 --- a/cmd/dlv/dlv_test.go +++ b/cmd/dlv/dlv_test.go @@ -208,7 +208,6 @@ func getDlvBin(t *testing.T) (string, string) { } func getDlvBinEBPF(t *testing.T) (string, string) { - os.Setenv("CGO_LDFLAGS", "/usr/lib/libbpf.a") return getDlvBinInternal(t, "-tags", "ebpf") } diff --git a/pkg/proc/internal/ebpf/build/build-ebpf-builder-img.sh b/pkg/proc/internal/ebpf/build/build-ebpf-builder-img.sh new file mode 100755 index 00000000..c308363f --- /dev/null +++ b/pkg/proc/internal/ebpf/build/build-ebpf-builder-img.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +sudo docker build \ + -t delve-ebpf-builder:v0.0.1 \ + -f pkg/proc/internal/ebpf/build/ebpf-Dockerfile ./pkg/proc/internal/ebpf/build diff --git a/pkg/proc/internal/ebpf/build/build-ebpf-objects.sh b/pkg/proc/internal/ebpf/build/build-ebpf-objects.sh new file mode 100755 index 00000000..05efa784 --- /dev/null +++ b/pkg/proc/internal/ebpf/build/build-ebpf-objects.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e + +# The go generate command seems to not like being run from +# the vendor directory. Remove it and restore it after. +rm -rf vendor + +restore_vendor() { + git checkout vendor +} + +trap restore_vendor EXIT + +docker run \ + -it \ + --rm \ + -v "$(pwd)":/delve-bpf \ + delve-ebpf-builder:v0.0.1 diff --git a/pkg/proc/internal/ebpf/build/ebpf-Dockerfile b/pkg/proc/internal/ebpf/build/ebpf-Dockerfile new file mode 100644 index 00000000..67306763 --- /dev/null +++ b/pkg/proc/internal/ebpf/build/ebpf-Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:21.04 + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y \ + build-essential \ + gcc-multilib \ + git \ + wget \ + clang \ + linux-headers-5.11.0-40 \ + libbpf-dev + +RUN wget https://golang.org/dl/go1.17.3.linux-amd64.tar.gz +RUN tar -C /usr/local -xzf go1.17.3.linux-amd64.tar.gz +RUN cp /usr/local/go/bin/go /usr/bin/go + +WORKDIR /delve-bpf/pkg/proc/internal/ebpf/ + +CMD [ "go", "generate", "./..." ] diff --git a/pkg/proc/internal/ebpf/trace_bpfel_x86.o b/pkg/proc/internal/ebpf/trace_bpfel_x86.o index a93baa7d..33ac3f00 100644 Binary files a/pkg/proc/internal/ebpf/trace_bpfel_x86.o and b/pkg/proc/internal/ebpf/trace_bpfel_x86.o differ