From 08e835bd0d8dbc9d22aed56c564a602ed3460abf Mon Sep 17 00:00:00 2001 From: James Antill Date: Thu, 26 May 2022 01:02:12 -0400 Subject: [PATCH] Auto sync2gitlab import of bpftrace-0.12.1-4.el8.src.rpm --- .gitignore | 1 + EMPTY | 1 - ...arch64-fixes-statsnoop-and-opensnoop.patch | 64 +++++++ bpftrace-0.12.1-RHEL-8-fixes.patch | 56 ++++++ ...e-0.12.1-orc-Fix-build-with-clang-13.patch | 132 ++++++++++++++ bpftrace.spec | 171 ++++++++++++++++++ sources | 1 + 7 files changed, 425 insertions(+), 1 deletion(-) create mode 100644 .gitignore delete mode 100644 EMPTY create mode 100644 bpftrace-0.12.1-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch create mode 100644 bpftrace-0.12.1-RHEL-8-fixes.patch create mode 100644 bpftrace-0.12.1-orc-Fix-build-with-clang-13.patch create mode 100644 bpftrace.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a37ed54 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bpftrace-0.12.1.tar.gz diff --git a/EMPTY b/EMPTY deleted file mode 100644 index 0519ecb..0000000 --- a/EMPTY +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/bpftrace-0.12.1-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch b/bpftrace-0.12.1-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch new file mode 100644 index 0000000..54ed64a --- /dev/null +++ b/bpftrace-0.12.1-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch @@ -0,0 +1,64 @@ +From 69f6d7ff04f43451eea2fb028a84a76331bbf6ea Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Thu, 11 Jun 2020 14:56:36 +0200 +Subject: [PATCH] RHEL-8: aarch64: fixes statsnoop and opensnoop + +On aarch64 the open syscall has been dropped. Only openat remains, +wich is called by libc open() function. + +The state of *stat* syscalls, is a mess. They are several generations +of the system calls, and not all arches provides all of them. For +instance, new(l)stat are missing from aarch64. + +The only way I can think of fixing thess is RHEL-8 only arch specific +patches. +--- + tools/opensnoop.bt | 2 -- + tools/statsnoop.bt | 8 ++------ + 2 files changed, 2 insertions(+), 8 deletions(-) + +diff --git a/tools/opensnoop.bt b/tools/opensnoop.bt +index a7de8026..d99db93e 100755 +--- a/tools/opensnoop.bt ++++ b/tools/opensnoop.bt +@@ -21,13 +21,11 @@ BEGIN + printf("%-6s %-16s %4s %3s %s\n", "PID", "COMM", "FD", "ERR", "PATH"); + } + +-tracepoint:syscalls:sys_enter_open, + tracepoint:syscalls:sys_enter_openat + { + @filename[tid] = args->filename; + } + +-tracepoint:syscalls:sys_exit_open, + tracepoint:syscalls:sys_exit_openat + /@filename[tid]/ + { +diff --git a/tools/statsnoop.bt b/tools/statsnoop.bt +index b2d529e2..f612ea94 100755 +--- a/tools/statsnoop.bt ++++ b/tools/statsnoop.bt +@@ -30,17 +30,13 @@ tracepoint:syscalls:sys_enter_statfs + @filename[tid] = args->pathname; + } + +-tracepoint:syscalls:sys_enter_statx, +-tracepoint:syscalls:sys_enter_newstat, +-tracepoint:syscalls:sys_enter_newlstat ++tracepoint:syscalls:sys_enter_statx + { + @filename[tid] = args->filename; + } + + tracepoint:syscalls:sys_exit_statfs, +-tracepoint:syscalls:sys_exit_statx, +-tracepoint:syscalls:sys_exit_newstat, +-tracepoint:syscalls:sys_exit_newlstat ++tracepoint:syscalls:sys_exit_statx + /@filename[tid]/ + { + $ret = args->ret; +-- +2.30.2 + diff --git a/bpftrace-0.12.1-RHEL-8-fixes.patch b/bpftrace-0.12.1-RHEL-8-fixes.patch new file mode 100644 index 0000000..270277b --- /dev/null +++ b/bpftrace-0.12.1-RHEL-8-fixes.patch @@ -0,0 +1,56 @@ +From 3a7f0bf4f506014644cf935332346e3c227123c9 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Tue, 11 Jun 2019 16:41:59 +0200 +Subject: [PATCH] RHEL 8 fixes + +Fixes the following RHEL 8 specific issues: + - library path in gethostlatency and threadsnoop +--- + tools/gethostlatency.bt | 12 ++++++------ + tools/threadsnoop.bt | 2 +- + 2 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/tools/gethostlatency.bt b/tools/gethostlatency.bt +index 9f4ec31e..dd389c6f 100755 +--- a/tools/gethostlatency.bt ++++ b/tools/gethostlatency.bt +@@ -26,17 +26,17 @@ BEGIN + "HOST"); + } + +-uprobe:/lib/x86_64-linux-gnu/libc.so.6:getaddrinfo, +-uprobe:/lib/x86_64-linux-gnu/libc.so.6:gethostbyname, +-uprobe:/lib/x86_64-linux-gnu/libc.so.6:gethostbyname2 ++uprobe:/lib64/libc.so.6:getaddrinfo, ++uprobe:/lib64/libc.so.6:gethostbyname, ++uprobe:/lib64/libc.so.6:gethostbyname2 + { + @start[tid] = nsecs; + @name[tid] = arg0; + } + +-uretprobe:/lib/x86_64-linux-gnu/libc.so.6:getaddrinfo, +-uretprobe:/lib/x86_64-linux-gnu/libc.so.6:gethostbyname, +-uretprobe:/lib/x86_64-linux-gnu/libc.so.6:gethostbyname2 ++uretprobe:/lib64/libc.so.6:getaddrinfo, ++uretprobe:/lib64/libc.so.6:gethostbyname, ++uretprobe:/lib64/libc.so.6:gethostbyname2 + /@start[tid]/ + { + $latms = (nsecs - @start[tid]) / 1e6; +diff --git a/tools/threadsnoop.bt b/tools/threadsnoop.bt +index 3824bc6d..bdc6e4df 100755 +--- a/tools/threadsnoop.bt ++++ b/tools/threadsnoop.bt +@@ -18,7 +18,7 @@ BEGIN + printf("%-10s %-6s %-16s %s\n", "TIME(ms)", "PID", "COMM", "FUNC"); + } + +-uprobe:/lib/x86_64-linux-gnu/libpthread.so.0:pthread_create ++uprobe:/usr/lib64/libpthread.so.0:pthread_create + { + printf("%-10u %-6d %-16s %s\n", elapsed / 1e6, pid, comm, + usym(arg2)); +-- +2.30.2 + diff --git a/bpftrace-0.12.1-orc-Fix-build-with-clang-13.patch b/bpftrace-0.12.1-orc-Fix-build-with-clang-13.patch new file mode 100644 index 0000000..ab1547b --- /dev/null +++ b/bpftrace-0.12.1-orc-Fix-build-with-clang-13.patch @@ -0,0 +1,132 @@ +From 3bde9d98aa48b9c7eba9fe559dee6c66d8b57634 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 4 Sep 2021 17:28:17 -0700 +Subject: [PATCH] orc: Fix build with clang >= 13 + +Fixes errors like +src/ast/bpforc/bpforcv2.cpp:3:9: error: constructor for 'bpftrace::BpfOrc' must explicitly initialize the member 'ES' which does not have a default constructor +BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL) + ^ + +Fixes https://github.com/iovisor/bpftrace/issues/1963 + +Signed-off-by: Khem Raj +--- + src/bpforc.h | 23 ++++++++++++++++++++++- + src/bpforcv2.cpp | 23 +++++++++++++++-------- + 2 files changed, 37 insertions(+), 9 deletions(-) + +diff --git a/src/bpforc.h b/src/bpforc.h +index 5634c544..1900e497 100644 +--- a/src/bpforc.h ++++ b/src/bpforc.h +@@ -20,6 +20,9 @@ + #ifdef LLVM_ORC_V2 + #include + #include ++#if LLVM_VERSION_MAJOR >= 13 ++#include ++#endif + #endif + + #include +@@ -66,8 +69,12 @@ class BpfOrc + std::unique_ptr TM; + DataLayout DL; + #if LLVM_VERSION_MAJOR >= 7 ++#ifdef LLVM_ORC_V2 ++ std::unique_ptr ES; ++#else // LLVM_ORC_V1 + ExecutionSession ES; + #endif ++#endif + #if LLVM_VERSION_MAJOR >= 7 && LLVM_VERSION_MAJOR < 12 + std::shared_ptr Resolver; + #endif +@@ -92,7 +99,21 @@ class BpfOrc + #endif + + public: ++#if LLVM_VERSION_MAJOR >= 13 ++ ~BpfOrc() ++ { ++ if (auto Err = ES->endSession()) ++ ES->reportError(std::move(Err)); ++ } ++#endif ++#ifdef LLVM_ORC_V2 ++ BpfOrc(TargetMachine *TM, ++ DataLayout DL, ++ std::unique_ptr ES); ++#else + BpfOrc(TargetMachine *TM, DataLayout DL); ++#endif ++ + void compile(std::unique_ptr M); + + /* Helper for creating a orc object, responsible for creating internal objects +@@ -125,7 +146,7 @@ class BpfOrc + #ifdef LLVM_ORC_V2 + Expected lookup(StringRef Name) + { +- return ES.lookup({ &MainJD }, Mangle(Name.str())); ++ return ES->lookup({ &MainJD }, Mangle(Name.str())); + } + #endif + }; +diff --git a/src/bpforcv2.cpp b/src/bpforcv2.cpp +index 209e08e5..104213b0 100644 +--- a/src/bpforcv2.cpp ++++ b/src/bpforcv2.cpp +@@ -1,24 +1,26 @@ + // Included by bpforc.cpp + +-BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL) ++BpfOrc::BpfOrc(TargetMachine *TM, ++ DataLayout DL, ++ std::unique_ptr ES) + : TM(std::move(TM)), + DL(std::move(DL)), +- ObjectLayer(ES, ++ ES(std::move(ES)), ++ ObjectLayer(*(this->ES), + [this]() { + return std::make_unique(sections_); + }), +- CompileLayer(ES, ++ CompileLayer(*this->ES, + ObjectLayer, + std::make_unique(*this->TM)), +- Mangle(ES, this->DL), ++ Mangle(*this->ES, this->DL), + CTX(std::make_unique()), +- MainJD(cantFail(ES.createJITDylib("
"))) ++ MainJD(cantFail(this->ES->createJITDylib("
"))) + { + MainJD.addGenerator( + cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( + DL.getGlobalPrefix()))); + } +- + LLVMContext &BpfOrc::getContext() + { + return *CTX.getContext(); +@@ -37,8 +39,13 @@ std::unique_ptr BpfOrc::Create() + // return unique_ptrs + auto DL = cantFail(JTMB.getDefaultDataLayoutForTarget()); + auto TM = cantFail(JTMB.createTargetMachine()); +- +- return std::make_unique(TM.release(), std::move(DL)); ++#if LLVM_VERSION_MAJOR >= 13 ++ auto EPC = SelfExecutorProcessControl::Create(); ++ auto ES = std::make_unique(std::move(*EPC)); ++#else ++ auto ES = std::make_unique(); ++#endif ++ return std::make_unique(TM.release(), std::move(DL), std::move(ES)); + } + + void BpfOrc::compile(std::unique_ptr M) +-- +2.31.1 + diff --git a/bpftrace.spec b/bpftrace.spec new file mode 100644 index 0000000..933d327 --- /dev/null +++ b/bpftrace.spec @@ -0,0 +1,171 @@ +%bcond_without llvm_static + +Name: bpftrace +Version: 0.12.1 +Release: 4%{?dist} +Summary: High-level tracing language for Linux eBPF +License: ASL 2.0 + +URL: https://github.com/iovisor/bpftrace +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch0: %{name}-%{version}-RHEL-8-fixes.patch +Patch1: %{name}-%{version}-orc-Fix-build-with-clang-13.patch + +Patch10: %{name}-%{version}-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch + +# Arches will be included as upstream support is added and dependencies are +# satisfied in the respective arches +ExclusiveArch: x86_64 %{power64} aarch64 s390x + +BuildRequires: gcc-c++ +BuildRequires: bison +BuildRequires: flex +BuildRequires: cmake +BuildRequires: elfutils-libelf-devel +BuildRequires: zlib-devel +BuildRequires: llvm-devel +BuildRequires: clang-devel +BuildRequires: bcc-devel +BuildRequires: libbpf-devel +BuildRequires: libbpf-static +BuildRequires: binutils-devel + +%if %{with llvm_static} +BuildRequires: llvm-static +%endif + +# We don't need kernel-devel to use bpftrace, but some tools need it +Recommends: kernel-devel + +%description +BPFtrace is a high-level tracing language for Linux enhanced Berkeley Packet +Filter (eBPF) available in recent Linux kernels (4.x). BPFtrace uses LLVM as a +backend to compile scripts to BPF-bytecode and makes use of BCC for +interacting with the Linux BPF system, as well as existing Linux tracing +capabilities: kernel dynamic tracing (kprobes), user-level dynamic tracing +(uprobes), and tracepoints. The BPFtrace language is inspired by awk and C, +and predecessor tracers such as DTrace and SystemTap + + +%prep +%autosetup -N +%autopatch -p1 -M 9 + +%ifarch aarch64 +%patch10 -p1 +%endif + +%build +%cmake . \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DBUILD_TESTING:BOOL=OFF \ + -DBUILD_SHARED_LIBS:BOOL=OFF +%make_build + + +%install +# The post hooks strip the binary which removes +# the BEGIN_trigger and END_trigger functions +# which are needed for the BEGIN and END probes +%global __os_install_post %{nil} +%global _find_debuginfo_opts -g + +%make_install + +# Fix shebangs (https://fedoraproject.org/wiki/Packaging:Guidelines#Shebang_lines) +find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \ + sed -i -e '1s=^#!/usr/bin/env %{name}\([0-9.]\+\)\?$=#!%{_bindir}/%{name}=' {} \; + +%files +%doc README.md CONTRIBUTING-TOOLS.md +%doc docs/reference_guide.md docs/tutorial_one_liners.md +%license LICENSE +%dir %{_datadir}/%{name} +%dir %{_datadir}/%{name}/tools +%dir %{_datadir}/%{name}/tools/doc +%{_bindir}/%{name} +%{_mandir}/man8/* +%attr(0755,-,-) %{_datadir}/%{name}/tools/*.bt +%{_datadir}/%{name}/tools/doc/*.txt +# tcp_drop() is inlined on ppc64 +%ifarch %{power64} +%exclude %{_datadir}/%{name}/tools/tcpdrop.bt +%exclude %{_datadir}/%{name}/tools/doc/tcpdrop_example.txt +%exclude %{_mandir}/man8/tcpdrop.8.gz +%endif + +%changelog +* Thu Dec 02 2021 Jerome Marchand - 0.12.1-4 +- Rebuild on LLVM13 +- Small spec cleanup + +* Thu Jun 24 2021 Jerome Marchand - 0.12.1-3 +- Have threadsnoop points to libpthread.so.0 + +* Wed Jun 09 2021 Jerome Marchand - 0.12.1-2 +- Rebuild on LLVM12 + +* Fri Apr 30 2021 Jerome Marchand - 0.12.1-1 +- Rebase on bpftrace 0.12.1 + +* Thu Jan 28 2021 Jerome Marchand - 0.11.1-3 +- Add missing libbpf and binutils-dev dependencies + +* Wed Nov 11 2020 Jerome Marchand - 0.11.1-2 +- Fix statsnoop and opensnoop on aarch64 again + +* Fri Nov 06 2020 Jerome Marchand - 0.11.1-1 +- Rebase on bpftrace 0.11.1 + +* Tue Oct 27 2020 Jerome Marchand - 0.10.0-5 +- Rebuild for bcc 0.16.0 + +* Thu Jun 11 2020 Jerome Marchand - 0.10.0-4 +- Fix KBUILD_MODNAME + +* Thu Jun 11 2020 Jerome Marchand - 0.10.0-3 +- Fix ENOMEM issue on arm64 machine with many cpus +- Fix statsnoop and opensnoop on aarch64 +- Drop tcpdrop on ppc64 + +* Tue May 05 2020 Jerome Marchand - 0.10.0-2 +- Fix libpthread path in threadsnoop + +* Wed Apr 22 2020 Jerome Marchand - 0.10.0-1 +- Rebase on bpftrace 0.10.0 + +* Fri Nov 08 2019 Jerome Marchand - 0.9.2-1 +- Rebase on bpftrace 0.9.2 + +* Tue Jun 18 2019 Jerome Marchand - 0.9-3 +- Don't allow to raw_spin_lock* kprobes that can deadlock the kernel. + +* Wed Jun 12 2019 Jerome Marchand - 0.9-2 +- Fixes gethostlatency +- Fixes a struct definition issue that made several tools fail +- Add CI gating + +* Wed May 15 2019 Jerome Marchand - 0.9.1 +- Original build on RHEL 8 + +* Thu Apr 25 2019 Augusto Caringi - 0.9-3 +- Rebuilt for bcc 0.9.0 + +* Mon Apr 22 2019 Neal Gompa - 0.9-2 +- Fix Source0 reference +- Use make_build macro for calling make + +* Mon Apr 1 2019 Peter Robinson 0.9-1 +- Build on aarch64 and s390x + +* Mon Mar 25 2019 Augusto Caringi - 0.9-0 +- Updated to version 0.9 + +* Thu Jan 31 2019 Fedora Release Engineering - 0.0-2.20181210gitc49b333 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Mon Dec 10 2018 Augusto Caringi - 0.0-1.20181210gitc49b333 +- Updated to latest upstream (c49b333c034a6d29a7ce90f565e27da1061af971) + +* Wed Nov 07 2018 Augusto Caringi - 0.0-1.20181107git029717b +- Initial import diff --git a/sources b/sources new file mode 100644 index 0000000..a6313e1 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (bpftrace-0.12.1.tar.gz) = a578499668bd2eb7342689b6c0ef3db6ca263a971d8e6f1b9a68c502c27170d24ede212a0fc2a72263e72aff58924f488a5c80d447397503a08512dc47b63345