From cb3401f95828c6cb7e370a4787d2bda5046ef6b8 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 18 2021 06:45:25 +0000 Subject: import bpftrace-0.11.1-3.el8 --- diff --git a/.bpftrace.metadata b/.bpftrace.metadata index 97a8f2e..86fabde 100644 --- a/.bpftrace.metadata +++ b/.bpftrace.metadata @@ -1 +1 @@ -1b1d4e5058e07f82904971e65733791b25ef5263 SOURCES/bpftrace-0.10.0.tar.gz +6bb8d682de04ffd47d565eb2542bc7c7d7b5da84 SOURCES/bpftrace-0.11.1.tar.gz diff --git a/.gitignore b/.gitignore index 03fef87..7ac4fc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/bpftrace-0.10.0.tar.gz +SOURCES/bpftrace-0.11.1.tar.gz diff --git a/SOURCES/bpftrace-0.10.0-Add-s390x-register-support.patch b/SOURCES/bpftrace-0.10.0-Add-s390x-register-support.patch deleted file mode 100644 index 8b162b4..0000000 --- a/SOURCES/bpftrace-0.10.0-Add-s390x-register-support.patch +++ /dev/null @@ -1,126 +0,0 @@ -From 3516f05627b33cb2e6e74965650c6d6c043f78f9 Mon Sep 17 00:00:00 2001 -From: Sumanth Korikkar -Date: Mon, 6 Apr 2020 09:23:34 +0200 -Subject: [PATCH] bpftrace: Add s390x register support - -Add s390x specific registers. This is needed for bpftrace builtins like argX, -regs(), retval etc. This commit provides various functions to perform proper -offset calculation from the pt_regs context. The builtin functions of -bpftrace uses these offset functions to generate the proper bytecode for s390x - -Signed-off-by: Sumanth Korikkar -Acked-by: Ilya Leoshkevich ---- - src/arch/CMakeLists.txt | 3 ++ - src/arch/s390.cpp | 85 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 88 insertions(+) - create mode 100644 src/arch/s390.cpp - -diff --git a/src/arch/CMakeLists.txt b/src/arch/CMakeLists.txt -index 7156276..51707cb 100644 ---- a/src/arch/CMakeLists.txt -+++ b/src/arch/CMakeLists.txt -@@ -3,6 +3,9 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR - CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") - add_library(arch ppc64.cpp) -+elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390" OR -+ CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x") -+ add_library(arch s390.cpp) - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - add_library(arch x86_64.cpp) - else() -diff --git a/src/arch/s390.cpp b/src/arch/s390.cpp -new file mode 100644 -index 0000000..a2278c8 ---- /dev/null -+++ b/src/arch/s390.cpp -@@ -0,0 +1,85 @@ -+#include "arch.h" -+ -+#include -+#include -+ -+#define REQ_REGISTERS 19 -+#define ARG_REGISTERS 5 -+ -+namespace bpftrace { -+namespace arch { -+ -+// clang-format off -+static std::array registers = { -+ // Breakpoint event address -+ "arg", -+ "pswmask", -+ // Instruction address -+ "pswaddr", -+ "r0", -+ "r1", -+ "r2", -+ "r3", -+ "r4", -+ "r5", -+ "r6", -+ "r7", -+ "r8", -+ "r9", -+ "r10", -+ "r11", -+ "r12", -+ "r13", -+ "r14", -+ "r15", -+}; -+ -+static std::array arg_registers = { -+ "r2", -+ "r3", -+ "r4", -+ "r5", -+ "r6", -+}; -+// clang-format on -+ -+int offset(std::string reg_name) -+{ -+ auto it = find(registers.begin(), registers.end(), reg_name); -+ if (it == registers.end()) -+ return -1; -+ return distance(registers.begin(), it); -+} -+ -+int max_arg() -+{ -+ return arg_registers.size() - 1; -+} -+ -+int arg_offset(int arg_num) -+{ -+ return offset(arg_registers.at(arg_num)); -+} -+ -+int ret_offset() -+{ -+ return offset("r2"); -+} -+ -+int pc_offset() -+{ -+ return offset("pswaddr"); -+} -+ -+int sp_offset() -+{ -+ return offset("r15"); -+} -+ -+std::string name() -+{ -+ return std::string("s390x"); -+} -+ -+} // namespace arch -+} // namespace bpftrace --- -2.25.3 - diff --git a/SOURCES/bpftrace-0.10.0-Fix-KBUILD_MODNAME.patch b/SOURCES/bpftrace-0.10.0-Fix-KBUILD_MODNAME.patch deleted file mode 100644 index 420e7ba..0000000 --- a/SOURCES/bpftrace-0.10.0-Fix-KBUILD_MODNAME.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 042675755d1ec2446105af700cd9cfb1bace905c Mon Sep 17 00:00:00 2001 -From: Masanori Misono -Date: Wed, 27 May 2020 17:54:52 +0900 -Subject: [PATCH] Fix KBUILD_MODNAME - -Use "bpftrace" instead of '"bpftrace"'. Previously this causes build -error if included header files use KBUILD_MODNAME. ---- - src/utils.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/utils.cpp b/src/utils.cpp -index dc82689..cec77cf 100644 ---- a/src/utils.cpp -+++ b/src/utils.cpp -@@ -363,7 +363,7 @@ std::vector get_kernel_cflags( - cflags.push_back("-D__HAVE_BUILTIN_BSWAP16__"); - cflags.push_back("-D__HAVE_BUILTIN_BSWAP32__"); - cflags.push_back("-D__HAVE_BUILTIN_BSWAP64__"); -- cflags.push_back("-DKBUILD_MODNAME='\"bpftrace\"'"); -+ cflags.push_back("-DKBUILD_MODNAME=\"bpftrace\""); - - // If ARCH env variable is set, pass this along. - if (archenv) --- -2.25.4 - diff --git a/SOURCES/bpftrace-0.10.0-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch b/SOURCES/bpftrace-0.10.0-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch deleted file mode 100644 index 3c1599f..0000000 --- a/SOURCES/bpftrace-0.10.0-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch +++ /dev/null @@ -1,64 +0,0 @@ -From e9ebda9b3d14831df5e1c5174d21f322e084d074 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 a7de802..d99db93 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 b2d529e..f612ea9 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.25.4 - diff --git a/SOURCES/bpftrace-0.10.0-RHEL-8-fixes.patch b/SOURCES/bpftrace-0.10.0-RHEL-8-fixes.patch deleted file mode 100644 index 7c4becf..0000000 --- a/SOURCES/bpftrace-0.10.0-RHEL-8-fixes.patch +++ /dev/null @@ -1,56 +0,0 @@ -From a09a2f06d6316801e89e7f676d0839910aea765d 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 a1ac1b2..ade1005 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]) / 1000000; -diff --git a/tools/threadsnoop.bt b/tools/threadsnoop.bt -index e4d3875..c56b1ac 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:pthread_create - { - printf("%-10u %-6d %-16s %s\n", elapsed / 1000000, pid, comm, - usym(arg2)); --- -2.25.4 - diff --git a/SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch b/SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch deleted file mode 100644 index 95c4f22..0000000 --- a/SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 604c9d5619ca01a46c208a70b7beec3041ba77a9 Mon Sep 17 00:00:00 2001 -From: Daniel Xu -Date: Thu, 28 May 2020 23:12:47 -0700 -Subject: [PATCH] Remove RLIMIT_AS limit - -We haven't seen any OOM issues in a while so I suspect either our type -fixes in bpftrace or upstream llvm changes have resolved the issue. - -This closes #1355. ---- - src/CMakeLists.txt | 1 - - src/main.cpp | 26 -------------------------- - 2 files changed, 27 deletions(-) - -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 4fa0418..ac040f4 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -99,7 +99,6 @@ if (BUILD_ASAN) - # target_link_options is supported in CMake 3.13 and newer - message("Please use CMake 3.13 or newer to enable ASAN") - endif() -- target_compile_definitions(bpftrace PRIVATE BUILD_ASAN) - target_compile_options(bpftrace PUBLIC "-fsanitize=address") - target_link_options(bpftrace PUBLIC "-fsanitize=address") - endif() -diff --git a/src/main.cpp b/src/main.cpp -index 4ff9d37..d92ea8d 100644 ---- a/src/main.cpp -+++ b/src/main.cpp -@@ -92,30 +92,6 @@ static void enforce_infinite_rlimit() { - "\"ulimit -l 8192\" to fix the problem" << std::endl; - } - --#ifdef BUILD_ASAN --static void cap_memory_limits() --{ --} --#else --static void cap_memory_limits() { -- struct rlimit rl = {}; -- int err; -- uint64_t memory_limit_bytes = 1 * 1024 * 1024 * 1024; -- -- // this is a safety measure for issue #528 "LLVM ERROR: out of memory", -- // and caps bpftrace memory to 1 Gbyte. This may be removed once the LLVM -- // issue has been fixed, and this is no longer deemed necessary. -- rl.rlim_max = memory_limit_bytes; -- rl.rlim_cur = rl.rlim_max; -- err = setrlimit(RLIMIT_AS, &rl); -- err += setrlimit(RLIMIT_RSS, &rl); -- if (err) -- std::cerr << std::strerror(err)<<": couldn't set RLIMIT_AS and " << -- "RLIMIT_RSS for bpftrace (these are a temporary precaution to stop " << -- "accidental large program loads, and are not required" << std::endl; --} --#endif // BUILD_ASAN -- - bool is_root() - { - if (geteuid() != 0) -@@ -425,8 +401,6 @@ int main(int argc, char *argv[]) - // rlimit? - enforce_infinite_rlimit(); - -- cap_memory_limits(); -- - // positional parameters - while (optind < argc) { - bpftrace.add_param(argv[optind]); --- -2.25.4 - diff --git a/SOURCES/bpftrace-0.11.1-Fix-clear-when-called-on-an-array.patch b/SOURCES/bpftrace-0.11.1-Fix-clear-when-called-on-an-array.patch new file mode 100644 index 0000000..491f7c1 --- /dev/null +++ b/SOURCES/bpftrace-0.11.1-Fix-clear-when-called-on-an-array.patch @@ -0,0 +1,49 @@ +From ed9caea4efcffdd9f37c67b272324a87abfd20c8 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Thu, 5 Nov 2020 15:17:14 +0100 +Subject: [PATCH] Fix clear() when called on an array + +Fixes the following error: +Error looking up elem: -1 +terminate called after throwing an instance of 'std::runtime_error' + what(): Could not clear map with ident "@", err=-1 +Aborted (core dumped) +--- + src/bpftrace.cpp | 5 +++++ + src/imap.h | 4 ++++ + 2 files changed, 9 insertions(+) + +diff --git a/src/bpftrace.cpp b/src/bpftrace.cpp +index 23b65a5..fe2fb66 100644 +--- a/src/bpftrace.cpp ++++ b/src/bpftrace.cpp +@@ -1147,6 +1147,11 @@ int BPFtrace::print_maps() + int BPFtrace::clear_map(IMap &map) + { + std::vector old_key; ++ if (map.is_array_type()) ++ { ++ return zero_map(map); ++ } ++ + try + { + if (map.type_.IsHistTy() || map.type_.IsLhistTy() || +diff --git a/src/imap.h b/src/imap.h +index 27d0d74..ca9f424 100644 +--- a/src/imap.h ++++ b/src/imap.h +@@ -27,6 +27,10 @@ class IMap + return map_type_ == BPF_MAP_TYPE_PERCPU_HASH || + map_type_ == BPF_MAP_TYPE_PERCPU_ARRAY; + } ++ bool is_array_type() ++ { ++ return map_type_ == BPF_MAP_TYPE_PERCPU_ARRAY; ++ } + + // unique id of this map. Used by (bpf) runtime to reference + // this map +-- +2.25.4 + diff --git a/SOURCES/bpftrace-0.11.1-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch b/SOURCES/bpftrace-0.11.1-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch new file mode 100644 index 0000000..3c1599f --- /dev/null +++ b/SOURCES/bpftrace-0.11.1-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch @@ -0,0 +1,64 @@ +From e9ebda9b3d14831df5e1c5174d21f322e084d074 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 a7de802..d99db93 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 b2d529e..f612ea9 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.25.4 + diff --git a/SOURCES/bpftrace-0.11.1-RHEL-8-fixes.patch b/SOURCES/bpftrace-0.11.1-RHEL-8-fixes.patch new file mode 100644 index 0000000..df3586e --- /dev/null +++ b/SOURCES/bpftrace-0.11.1-RHEL-8-fixes.patch @@ -0,0 +1,56 @@ +From 30cd8a899ec375ca0e46db51fa48ee80c5463470 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 a1ac1b2..ade1005 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]) / 1000000; +diff --git a/tools/threadsnoop.bt b/tools/threadsnoop.bt +index e4d3875..c56b1ac 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:pthread_create + { + printf("%-10u %-6d %-16s %s\n", elapsed / 1000000, pid, comm, + usym(arg2)); +-- +2.25.4 + diff --git a/SOURCES/bpftrace-0.11.1-irbuilderbpf.cpp-bpforc.h-Fix-compilation-with-LLVM-.patch b/SOURCES/bpftrace-0.11.1-irbuilderbpf.cpp-bpforc.h-Fix-compilation-with-LLVM-.patch new file mode 100644 index 0000000..43b02fa --- /dev/null +++ b/SOURCES/bpftrace-0.11.1-irbuilderbpf.cpp-bpforc.h-Fix-compilation-with-LLVM-.patch @@ -0,0 +1,282 @@ +From 0768e5f58d39ebb60c18813ea77953be00ce5830 Mon Sep 17 00:00:00 2001 +From: Ovidiu Panait +Date: Thu, 6 Aug 2020 10:34:23 +0300 +Subject: [PATCH] irbuilderbpf.cpp, bpforc.h: Fix compilation with LLVM 11 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes: #1384 + +Fix the following build errors when compiling with LLVM 11: + + #1 +---- +/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:118:35: error: no match for call to ‘(bpftrace::BpfOrc::BpfOrc(llvm::TargetMachine*)::) (llvm::StringRef)’ + 118 | if (JITSymbol Sym = FindSymbol(*S)) { + | ~~~~~~~~~~^~~~ +/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:118:35: note: candidate: ‘llvm::JITSymbol (*)(const string&)’ {aka ‘llvm::JITSymbol (*)(const std::__cxx11::basic_string&)’} +/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:118:35: note: candidate expects 2 arguments, 2 provided +In file included from /work/src/github.com/iovisor/bpftrace/src/ast/codegen_llvm.cpp:5: +/work/src/github.com/iovisor/bpftrace/src/bpforc.h:99:13: note: candidate: ‘bpftrace::BpfOrc::BpfOrc(llvm::TargetMachine*)::’ + 99 | [](const std::string &Name __attribute__((unused))) -> JITSymbol { + | ^ +/work/src/github.com/iovisor/bpftrace/src/bpforc.h:99:13: note: no known conversion for argument 1 from ‘llvm::StringRef’ to ‘const string&’ {aka ‘const std::__cxx11::basic_string&’} +In file included from /llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h:23, + + #2 +---- +| /src/ast/irbuilderbpf.cpp: In member function 'llvm::CallInst* bpftrace::ast::IRBuilderBPF::createMapLookup(int, llvm::AllocaInst*)': +| /src/ast/irbuilderbpf.cpp:230:65: error: no matching function for call to 'bpftrace::ast::IRBuilderBPF::CreateCall(llvm::Constant*&, , const char [12])' +| 230 | return CreateCall(lookup_func, { map_ptr, key }, "lookup_elem"); +| | ^ +| In file included from /src/ast/irbuilderbpf.h:9, +| from /src/ast/async_event_types.h:3, +| from /src/ast/irbuilderbpf.cpp:5: +| /usr/include/llvm/IR/IRBuilder.h:2324:13: note: candidate: 'llvm::CallInst* llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef, const llvm::Twine&, llvm::MDNode*)' +| 2324 | CallInst *CreateCall(FunctionType *FTy, Value *Callee, +| | ^~~~~~~~~~ +| /usr/include/llvm/IR/IRBuilder.h:2324:38: note: no known conversion for argument 1 from 'llvm::Constant*' to 'llvm::FunctionType*' +| 2324 | CallInst *CreateCall(FunctionType *FTy, Value *Callee, +| | ~~~~~~~~~~~~~~^~~ + +The CreateCall part is based on the llvm 11 fix from bcc: +https://github.com/iovisor/bcc/commit/45e63f2b316cdce2d8cc925f6f14a8726ade9ff6 + +Signed-off-by: Ovidiu Panait +--- + src/ast/irbuilderbpf.cpp | 55 ++++++++++++++++++++++++++-------------- + src/ast/irbuilderbpf.h | 1 + + src/bpforc.h | 6 +++++ + 3 files changed, 43 insertions(+), 19 deletions(-) + +diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp +index 8ae055e..4498e0f 100644 +--- a/src/ast/irbuilderbpf.cpp ++++ b/src/ast/irbuilderbpf.cpp +@@ -201,10 +201,25 @@ llvm::Type *IRBuilderBPF::GetType(const SizedType &stype) + return ty; + } + ++CallInst *IRBuilderBPF::createCall(Value *callee, ++ ArrayRef args, ++ const Twine &Name) ++{ ++#if LLVM_VERSION_MAJOR >= 11 ++ auto *calleePtrType = cast(callee->getType()); ++ auto *calleeType = cast(calleePtrType->getElementType()); ++ return CreateCall(calleeType, callee, args, Name); ++#else ++ return CreateCall(callee, args, Name); ++#endif ++} ++ + CallInst *IRBuilderBPF::CreateBpfPseudoCall(int mapfd) + { + Function *pseudo_func = module_.getFunction("llvm.bpf.pseudo"); +- return CreateCall(pseudo_func, {getInt64(BPF_PSEUDO_MAP_FD), getInt64(mapfd)}, "pseudo"); ++ return createCall(pseudo_func, ++ { getInt64(BPF_PSEUDO_MAP_FD), getInt64(mapfd) }, ++ "pseudo"); + } + + CallInst *IRBuilderBPF::CreateBpfPseudoCall(Map &map) +@@ -227,7 +242,7 @@ CallInst *IRBuilderBPF::createMapLookup(int mapfd, AllocaInst *key) + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_map_lookup_elem), + lookup_func_ptr_type); +- return CreateCall(lookup_func, { map_ptr, key }, "lookup_elem"); ++ return createCall(lookup_func, { map_ptr, key }, "lookup_elem"); + } + + CallInst *IRBuilderBPF::CreateGetJoinMap(Value *ctx, const location &loc) +@@ -325,7 +340,7 @@ void IRBuilderBPF::CreateMapUpdateElem(Value *ctx, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_map_update_elem), + update_func_ptr_type); +- CallInst *call = CreateCall(update_func, ++ CallInst *call = createCall(update_func, + { map_ptr, key, val, flags }, + "update_elem"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_map_update_elem, loc); +@@ -349,7 +364,7 @@ void IRBuilderBPF::CreateMapDeleteElem(Value *ctx, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_map_delete_elem), + delete_func_ptr_type); +- CallInst *call = CreateCall(delete_func, { map_ptr, key }, "delete_elem"); ++ CallInst *call = createCall(delete_func, { map_ptr, key }, "delete_elem"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_map_delete_elem, loc); + } + +@@ -378,7 +393,7 @@ void IRBuilderBPF::CreateProbeRead(Value *ctx, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_probe_read), + proberead_func_ptr_type); +- CallInst *call = CreateCall(proberead_func, { dst, size, src }, "probe_read"); ++ CallInst *call = createCall(proberead_func, { dst, size, src }, "probe_read"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_probe_read, loc); + } + +@@ -413,7 +428,7 @@ CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, + { + assert(ctx && ctx->getType() == getInt8PtrTy()); + Constant *fn = createProbeReadStrFn(dst->getType(), src->getType()); +- CallInst *call = CreateCall(fn, ++ CallInst *call = createCall(fn, + { dst, getInt32(size), src }, + "probe_read_str"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_probe_read_str, loc); +@@ -434,7 +449,7 @@ CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, + auto *size_i32 = CreateIntCast(size, getInt32Ty(), false); + + Constant *fn = createProbeReadStrFn(dst->getType(), src->getType()); +- CallInst *call = CreateCall(fn, { dst, size_i32, src }, "probe_read_str"); ++ CallInst *call = createCall(fn, { dst, size_i32, src }, "probe_read_str"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_probe_read_str, loc); + return call; + } +@@ -717,7 +732,7 @@ CallInst *IRBuilderBPF::CreateGetNs() + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_ktime_get_ns), + gettime_func_ptr_type); +- return CreateCall(gettime_func, {}, "get_ns"); ++ return createCall(gettime_func, {}, "get_ns"); + } + + CallInst *IRBuilderBPF::CreateGetPidTgid() +@@ -730,7 +745,7 @@ CallInst *IRBuilderBPF::CreateGetPidTgid() + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_current_pid_tgid), + getpidtgid_func_ptr_type); +- return CreateCall(getpidtgid_func, {}, "get_pid_tgid"); ++ return createCall(getpidtgid_func, {}, "get_pid_tgid"); + } + + CallInst *IRBuilderBPF::CreateGetCurrentCgroupId() +@@ -744,7 +759,7 @@ CallInst *IRBuilderBPF::CreateGetCurrentCgroupId() + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_current_cgroup_id), + getcgroupid_func_ptr_type); +- return CreateCall(getcgroupid_func, {}, "get_cgroup_id"); ++ return createCall(getcgroupid_func, {}, "get_cgroup_id"); + } + + CallInst *IRBuilderBPF::CreateGetUidGid() +@@ -757,7 +772,7 @@ CallInst *IRBuilderBPF::CreateGetUidGid() + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_current_uid_gid), + getuidgid_func_ptr_type); +- return CreateCall(getuidgid_func, {}, "get_uid_gid"); ++ return createCall(getuidgid_func, {}, "get_uid_gid"); + } + + CallInst *IRBuilderBPF::CreateGetCpuId() +@@ -770,7 +785,7 @@ CallInst *IRBuilderBPF::CreateGetCpuId() + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_smp_processor_id), + getcpuid_func_ptr_type); +- return CreateCall(getcpuid_func, {}, "get_cpu_id"); ++ return createCall(getcpuid_func, {}, "get_cpu_id"); + } + + CallInst *IRBuilderBPF::CreateGetCurrentTask() +@@ -783,7 +798,7 @@ CallInst *IRBuilderBPF::CreateGetCurrentTask() + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_current_task), + getcurtask_func_ptr_type); +- return CreateCall(getcurtask_func, {}, "get_cur_task"); ++ return createCall(getcurtask_func, {}, "get_cur_task"); + } + + CallInst *IRBuilderBPF::CreateGetRandom() +@@ -796,7 +811,7 @@ CallInst *IRBuilderBPF::CreateGetRandom() + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_prandom_u32), + getrandom_func_ptr_type); +- return CreateCall(getrandom_func, {}, "get_random"); ++ return createCall(getrandom_func, {}, "get_random"); + } + + CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx, +@@ -826,7 +841,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_stackid), + getstackid_func_ptr_type); +- CallInst *call = CreateCall(getstackid_func, ++ CallInst *call = createCall(getstackid_func, + { ctx, map_ptr, flags_val }, + "get_stackid"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_get_stackid, loc); +@@ -852,7 +867,7 @@ void IRBuilderBPF::CreateGetCurrentComm(Value *ctx, + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_get_current_comm), + getcomm_func_ptr_type); +- CallInst *call = CreateCall(getcomm_func, ++ CallInst *call = createCall(getcomm_func, + { buf, getInt64(size) }, + "get_comm"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_get_current_comm, loc); +@@ -883,7 +898,9 @@ void IRBuilderBPF::CreatePerfEventOutput(Value *ctx, Value *data, size_t size) + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_perf_event_output), + perfoutput_func_ptr_type); +- CreateCall(perfoutput_func, {ctx, map_ptr, flags_val, data, size_val}, "perf_event_output"); ++ createCall(perfoutput_func, ++ { ctx, map_ptr, flags_val, data, size_val }, ++ "perf_event_output"); + } + + void IRBuilderBPF::CreateSignal(Value *ctx, Value *sig, const location &loc) +@@ -899,7 +916,7 @@ void IRBuilderBPF::CreateSignal(Value *ctx, Value *sig, const location &loc) + Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_send_signal), + signal_func_ptr_type); +- CallInst *call = CreateCall(signal_func, { sig }, "signal"); ++ CallInst *call = createCall(signal_func, { sig }, "signal"); + CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_send_signal, loc); + } + +@@ -913,7 +930,7 @@ void IRBuilderBPF::CreateOverrideReturn(Value *ctx, Value *rc) + Constant *override_func = ConstantExpr::getCast(Instruction::IntToPtr, + getInt64(libbpf::BPF_FUNC_override_return), + override_func_ptr_type); +- CreateCall(override_func, { ctx, rc }, "override"); ++ createCall(override_func, { ctx, rc }, "override"); + } + + Value *IRBuilderBPF::CreatKFuncArg(Value *ctx, +diff --git a/src/ast/irbuilderbpf.h b/src/ast/irbuilderbpf.h +index d4361a8..3111507 100644 +--- a/src/ast/irbuilderbpf.h ++++ b/src/ast/irbuilderbpf.h +@@ -80,6 +80,7 @@ class IRBuilderBPF : public IRBuilder<> + CallInst *CreateGetRandom(); + CallInst *CreateGetStackId(Value *ctx, bool ustack, StackType stack_type, const location& loc); + CallInst *CreateGetJoinMap(Value *ctx, const location& loc); ++ CallInst *createCall(Value *callee, ArrayRef args, const Twine &Name); + void CreateGetCurrentComm(Value *ctx, AllocaInst *buf, size_t size, const location& loc); + void CreatePerfEventOutput(Value *ctx, Value *data, size_t size); + void CreateSignal(Value *ctx, Value *sig, const location &loc); +diff --git a/src/bpforc.h b/src/bpforc.h +index a42e031..295f703 100644 +--- a/src/bpforc.h ++++ b/src/bpforc.h +@@ -96,9 +96,15 @@ class BpfOrc + : TM(TM_), + Resolver(createLegacyLookupResolver( + ES, ++#if LLVM_VERSION_MAJOR >= 11 ++ [](llvm::StringRef Name __attribute__((unused))) -> JITSymbol { ++ return nullptr; ++ }, ++#else + [](const std::string &Name __attribute__((unused))) -> JITSymbol { + return nullptr; + }, ++#endif + [](Error Err) { cantFail(std::move(Err), "lookup failed"); })), + #if LLVM_VERSION_MAJOR > 8 + ObjectLayer(AcknowledgeORCv1Deprecation, +-- +2.25.4 + diff --git a/SPECS/bpftrace.spec b/SPECS/bpftrace.spec index c18ce6c..05b3772 100644 --- a/SPECS/bpftrace.spec +++ b/SPECS/bpftrace.spec @@ -1,17 +1,16 @@ %bcond_without llvm_static Name: bpftrace -Version: 0.10.0 -Release: 4%{?dist} +Version: 0.11.1 +Release: 3%{?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}-Add-s390x-register-support.patch -Patch2: %{name}-%{version}-Remove-RLIMIT_AS-limit.patch -Patch3: %{name}-%{version}-Fix-KBUILD_MODNAME.patch +Patch1: %{name}-%{version}-irbuilderbpf.cpp-bpforc.h-Fix-compilation-with-LLVM-.patch +Patch2: %{name}-%{version}-Fix-clear-when-called-on-an-array.patch # WARNING: because of the arch-specific patch, no autosetup is used # Remember to patch accordingly Patch10: %{name}-%{version}-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch @@ -29,6 +28,9 @@ 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 @@ -50,7 +52,6 @@ and predecessor tracers such as DTrace and SystemTap %patch0 -p1 %patch1 -p1 %patch2 -p1 -%patch3 -p1 %ifarch aarch64 %patch10 -p1 @@ -60,12 +61,18 @@ and predecessor tracers such as DTrace and SystemTap %cmake . \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_TESTING:BOOL=OFF \ - -DBUILD_SHARED_LIBS:BOOL=OFF -# -DLLVM_DIR=/usr/lib64/llvm7.0/lib/cmake/llvm/ + -DBUILD_SHARED_LIBS:BOOL=OFF \ + -DLIBBCC_LIBRARIES:PATH=%{_libdir}/libbcc-no-libbpf.so %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) @@ -96,6 +103,18 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \ %endif %changelog +* 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