summaryrefslogtreecommitdiffstats
path: root/dynamic-layers
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2022-09-06 13:08:16 -0700
committerKhem Raj <raj.khem@gmail.com>2022-09-07 00:25:37 -0700
commit0ef79ab2c2c59873f55b1261f453915c44e2d04c (patch)
tree3deb2d95383a0a45618279e139baa2e211653960 /dynamic-layers
parent9f245e4ee21d5b788787cbb26b8a52fd32d60775 (diff)
downloadmeta-clang-0ef79ab2c2c59873f55b1261f453915c44e2d04c.tar.gz
bpftrace: Upgrade to 0.16.0
The patch is already applied upstream so drop it. Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'dynamic-layers')
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch212
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb (renamed from dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb)3
2 files changed, 1 insertions, 214 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch
deleted file mode 100644
index 7651764..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch
+++ /dev/null
@@ -1,212 +0,0 @@
1From c5092eee7dc5f3d28a1de2c33bda6611e9ed9d34 Mon Sep 17 00:00:00 2001
2From: Jiri Olsa <jolsa@kernel.org>
3Date: Tue, 22 Feb 2022 16:36:44 +0100
4Subject: [PATCH] Detect new BTF api btf_dump__new/btf_dump__new_v0_6_0
5
6Some of the libbpf functions we use got deprecated and
7replaced with new versions.
8
9 btf__get_nr_types to btf__type_cnt
10 btf_dump__new changed arguments
11
12Adding detection of this and making bpftrace to compile
13against latest libbpf.
14
15Upstream-Status: Backport [https://github.com/iovisor/bpftrace/commit/3d451feeddf725d11bb52dfbc49b616724d24fd0]
16
17Signed-off-by: Jiri Olsa <jolsa@kernel.org>
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 CMakeLists.txt | 8 +++++++
21 cmake/FindLibBpf.cmake | 25 ++++++++++++++++++++
22 src/btf.cpp | 52 +++++++++++++++++++++++++++---------------
23 3 files changed, 66 insertions(+), 19 deletions(-)
24
25diff --git a/CMakeLists.txt b/CMakeLists.txt
26index c5959732..8a9b0082 100644
27--- a/CMakeLists.txt
28+++ b/CMakeLists.txt
29@@ -274,6 +274,14 @@ if (LIBBPF_BTF_DUMP_FOUND)
30 endif()
31 endif(LIBBPF_BTF_DUMP_FOUND)
32
33+if (HAVE_LIBBPF_BTF_TYPE_CNT)
34+ set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBBPF_BTF_TYPE_CNT)
35+endif(HAVE_LIBBPF_BTF_TYPE_CNT)
36+
37+if (HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0)
38+ set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0)
39+endif(HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0)
40+
41 if (LIBDW_FOUND)
42 set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBDW)
43 endif ()
44diff --git a/cmake/FindLibBpf.cmake b/cmake/FindLibBpf.cmake
45index 86eb8050..b088415f 100644
46--- a/cmake/FindLibBpf.cmake
47+++ b/cmake/FindLibBpf.cmake
48@@ -55,4 +55,29 @@ if (LIBBPF_FOUND)
49 check_symbol_exists(bpf_link_create "${LIBBPF_INCLUDE_DIRS}/bpf/bpf.h" HAVE_LIBBPF_LINK_CREATE)
50 SET(CMAKE_REQUIRED_DEFINITIONS)
51 SET(CMAKE_REQUIRED_LIBRARIES)
52+
53+ INCLUDE(CheckCXXSourceCompiles)
54+ SET(CMAKE_REQUIRED_INCLUDES ${LIBBPF_INCLUDE_DIRS})
55+ SET(CMAKE_REQUIRED_LIBRARIES ${LIBBPF_LIBRARIES} elf z)
56+ CHECK_CXX_SOURCE_COMPILES("
57+#include <bpf/btf.h>
58+
59+int main(void) {
60+ btf__type_cnt(NULL);
61+ return 0;
62+}
63+" HAVE_LIBBPF_BTF_TYPE_CNT)
64+
65+ CHECK_CXX_SOURCE_COMPILES("
66+#include <bpf/btf.h>
67+
68+int main(void) {
69+ const struct btf_dump_opts *opts = (const struct btf_dump_opts*) 1;
70+
71+ btf_dump__new(NULL, NULL, NULL, opts);
72+ return 0;
73+}
74+" HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0)
75+ SET(CMAKE_REQUIRED_INCLUDES)
76+ SET(CMAKE_REQUIRED_LIBRARIES)
77 endif()
78diff --git a/src/btf.cpp b/src/btf.cpp
79index 7d83cf68..c08ef17b 100644
80--- a/src/btf.cpp
81+++ b/src/btf.cpp
82@@ -28,6 +28,15 @@
83
84 namespace bpftrace {
85
86+static __u32 type_cnt(const struct btf *btf)
87+{
88+#ifdef HAVE_LIBBPF_BTF_TYPE_CNT
89+ return btf__type_cnt(btf);
90+#else
91+ return btf__get_nr_types(btf);
92+#endif
93+}
94+
95 static unsigned char *get_data(const char *file, ssize_t *sizep)
96 {
97 struct stat st;
98@@ -185,6 +194,21 @@ static void dump_printf(void *ctx, const char *fmt, va_list args)
99 free(str);
100 }
101
102+static struct btf_dump *dump_new(const struct btf *btf,
103+ btf_dump_printf_fn_t dump_printf,
104+ void *ctx)
105+{
106+#ifdef HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0
107+ return btf_dump__new(btf, dump_printf, ctx, nullptr);
108+#else
109+ struct btf_dump_opts opts = {
110+ .ctx = ctx,
111+ };
112+
113+ return btf_dump__new(btf, nullptr, &opts, dump_printf);
114+#endif
115+}
116+
117 static const char *btf_str(const struct btf *btf, __u32 off)
118 {
119 if (!off)
120@@ -220,12 +244,11 @@ std::string BTF::c_def(const std::unordered_set<std::string> &set) const
121 return std::string("");
122
123 std::string ret = std::string("");
124- struct btf_dump_opts opts = { .ctx = &ret, };
125 struct btf_dump *dump;
126 char err_buf[256];
127 int err;
128
129- dump = btf_dump__new(btf, nullptr, &opts, dump_printf);
130+ dump = dump_new(btf, dump_printf, &ret);
131 err = libbpf_get_error(dump);
132 if (err)
133 {
134@@ -235,7 +258,7 @@ std::string BTF::c_def(const std::unordered_set<std::string> &set) const
135 }
136
137 std::unordered_set<std::string> myset(set);
138- __s32 id, max = (__s32) btf__get_nr_types(btf);
139+ __s32 id, max = (__s32)type_cnt(btf);
140
141 for (id = 1; id <= max && myset.size(); id++)
142 {
143@@ -415,7 +438,7 @@ int BTF::resolve_args(const std::string &func,
144 if (!has_data())
145 throw std::runtime_error("BTF data not available");
146
147- __s32 id, max = (__s32)btf__get_nr_types(btf);
148+ __s32 id, max = (__s32)type_cnt(btf);
149 std::string name = func;
150
151 for (id = 1; id <= max; id++)
152@@ -486,17 +509,14 @@ int BTF::resolve_args(const std::string &func,
153
154 std::unique_ptr<std::istream> BTF::get_all_funcs() const
155 {
156- __s32 id, max = (__s32)btf__get_nr_types(btf);
157+ __s32 id, max = (__s32)type_cnt(btf);
158 std::string type = std::string("");
159- struct btf_dump_opts opts = {
160- .ctx = &type,
161- };
162 struct btf_dump *dump;
163 std::string funcs;
164 char err_buf[256];
165 int err;
166
167- dump = btf_dump__new(btf, nullptr, &opts, dump_printf);
168+ dump = dump_new(btf, dump_printf, &type);
169 err = libbpf_get_error(dump);
170 if (err)
171 {
172@@ -545,16 +565,13 @@ std::map<std::string, std::vector<std::string>> BTF::get_params(
173 const std::set<std::string> &funcs) const
174 {
175 #ifdef HAVE_LIBBPF_BTF_DUMP_EMIT_TYPE_DECL
176- __s32 id, max = (__s32)btf__get_nr_types(btf);
177+ __s32 id, max = (__s32)type_cnt(btf);
178 std::string type = std::string("");
179- struct btf_dump_opts opts = {
180- .ctx = &type,
181- };
182 struct btf_dump *dump;
183 char err_buf[256];
184 int err;
185
186- dump = btf_dump__new(btf, nullptr, &opts, dump_printf);
187+ dump = dump_new(btf, dump_printf, &type);
188 err = libbpf_get_error(dump);
189 if (err)
190 {
191@@ -639,16 +656,13 @@ std::map<std::string, std::vector<std::string>> BTF::get_params(
192 std::set<std::string> BTF::get_all_structs() const
193 {
194 std::set<std::string> struct_set;
195- __s32 id, max = (__s32)btf__get_nr_types(btf);
196+ __s32 id, max = (__s32)type_cnt(btf);
197 std::string types = std::string("");
198- struct btf_dump_opts opts = {
199- .ctx = &types,
200- };
201 struct btf_dump *dump;
202 char err_buf[256];
203 int err;
204
205- dump = btf_dump__new(btf, nullptr, &opts, dump_printf);
206+ dump = dump_new(btf, dump_printf, &types);
207 err = libbpf_get_error(dump);
208 if (err)
209 {
210--
2112.36.0
212
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb
index 937c61f..d39b01a 100644
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb
@@ -17,9 +17,8 @@ PV .= "+git${SRCREV}"
17RDEPENDS:${PN} += "bash python3 xz" 17RDEPENDS:${PN} += "bash python3 xz"
18 18
19SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ 19SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \
20 file://0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch \
21" 20"
22SRCREV = "0a318e53343aa51f811183534916a4be65a1871e" 21SRCREV = "ed06d87ef19e0b24a96244b1bf50ef85c3f63a37"
23 22
24S = "${WORKDIR}/git" 23S = "${WORKDIR}/git"
25 24