diff options
Diffstat (limited to 'dynamic-layers/openembedded-layer')
-rw-r--r-- | dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch | 212 | ||||
-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 @@ | |||
1 | From c5092eee7dc5f3d28a1de2c33bda6611e9ed9d34 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jiri Olsa <jolsa@kernel.org> | ||
3 | Date: Tue, 22 Feb 2022 16:36:44 +0100 | ||
4 | Subject: [PATCH] Detect new BTF api btf_dump__new/btf_dump__new_v0_6_0 | ||
5 | |||
6 | Some of the libbpf functions we use got deprecated and | ||
7 | replaced with new versions. | ||
8 | |||
9 | btf__get_nr_types to btf__type_cnt | ||
10 | btf_dump__new changed arguments | ||
11 | |||
12 | Adding detection of this and making bpftrace to compile | ||
13 | against latest libbpf. | ||
14 | |||
15 | Upstream-Status: Backport [https://github.com/iovisor/bpftrace/commit/3d451feeddf725d11bb52dfbc49b616724d24fd0] | ||
16 | |||
17 | Signed-off-by: Jiri Olsa <jolsa@kernel.org> | ||
18 | Signed-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 | |||
25 | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
26 | index 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 () | ||
44 | diff --git a/cmake/FindLibBpf.cmake b/cmake/FindLibBpf.cmake | ||
45 | index 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() | ||
78 | diff --git a/src/btf.cpp b/src/btf.cpp | ||
79 | index 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 | -- | ||
211 | 2.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}" | |||
17 | RDEPENDS:${PN} += "bash python3 xz" | 17 | RDEPENDS:${PN} += "bash python3 xz" |
18 | 18 | ||
19 | SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ | 19 | SRC_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 | " |
22 | SRCREV = "0a318e53343aa51f811183534916a4be65a1871e" | 21 | SRCREV = "ed06d87ef19e0b24a96244b1bf50ef85c3f63a37" |
23 | 22 | ||
24 | S = "${WORKDIR}/git" | 23 | S = "${WORKDIR}/git" |
25 | 24 | ||