bd8a9c
import bpftrace-0.13.1-1.el9
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ddc4abda22761b58fc7fc49623e60ca7e3ae26ff SOURCES/bpftrace-0.13.1.tar.gz
|
@@ -1 +1 @@
|
|
1
|
-
SOURCES/bpftrace-0.
|
1
|
+
SOURCES/bpftrace-0.13.1.tar.gz
|
@@ -1,72 +0,0 @@
|
|
1
|
-
From b7fd0900b18c4b640926e0bb830464565a527ca1 Mon Sep 17 00:00:00 2001
|
2
|
-
From: Daniel Xu <dxu@dxuuu.xyz>
|
3
|
-
Date: Mon, 5 Apr 2021 14:35:08 -0700
|
4
|
-
Subject: [PATCH] Fix single arg wildcard listings
|
5
|
-
|
6
|
-
The docs say we can do stuff like
|
7
|
-
|
8
|
-
# bpftrace -l "*sleep*"
|
9
|
-
|
10
|
-
so we should probably implement it. We probably regressed on this during
|
11
|
-
the probe matching refactoring.
|
12
|
-
---
|
13
|
-
src/ast/attachpoint_parser.cpp | 10 +++++++---
|
14
|
-
tests/runtime/regression | 6 ++++++
|
15
|
-
2 files changed, 13 insertions(+), 3 deletions(-)
|
16
|
-
|
17
|
-
diff --git a/src/ast/attachpoint_parser.cpp b/src/ast/attachpoint_parser.cpp
|
18
|
-
index cfac09bc..b62549d7 100644
|
19
|
-
--- a/src/ast/attachpoint_parser.cpp
|
20
|
-
+++ b/src/ast/attachpoint_parser.cpp
|
21
|
-
@@ -77,6 +77,9 @@ AttachPointParser::State AttachPointParser::parse_attachpoint(AttachPoint &ap)
|
22
|
-
std::set<std::string> probe_types;
|
23
|
-
if (has_wildcard(parts_.front()))
|
24
|
-
{
|
25
|
-
+ // Single argument listing looks at all relevant probe types
|
26
|
-
+ std::string probetype_query = (parts_.size() == 1) ? "*" : parts_.front();
|
27
|
-
+
|
28
|
-
// Probe type expansion
|
29
|
-
// If PID is specified or the second part of the attach point is a path
|
30
|
-
// (contains '/'), use userspace probe types.
|
31
|
-
@@ -85,12 +88,12 @@ AttachPointParser::State AttachPointParser::parse_attachpoint(AttachPoint &ap)
|
32
|
-
(parts_.size() >= 2 && parts_[1].find('/') != std::string::npos))
|
33
|
-
{
|
34
|
-
probe_types = bpftrace_.probe_matcher_->expand_probetype_userspace(
|
35
|
-
- parts_.front());
|
36
|
-
+ probetype_query);
|
37
|
-
}
|
38
|
-
else
|
39
|
-
{
|
40
|
-
probe_types = bpftrace_.probe_matcher_->expand_probetype_kernel(
|
41
|
-
- parts_.front());
|
42
|
-
+ probetype_query);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
else
|
46
|
-
@@ -111,7 +114,8 @@ AttachPointParser::State AttachPointParser::parse_attachpoint(AttachPoint &ap)
|
47
|
-
for (const auto &probe_type : probe_types)
|
48
|
-
{
|
49
|
-
std::string raw_input = ap.raw_input;
|
50
|
-
- erase_prefix(raw_input);
|
51
|
-
+ if (parts_.size() > 1)
|
52
|
-
+ erase_prefix(raw_input);
|
53
|
-
raw_input = probe_type + ":" + raw_input;
|
54
|
-
// New attach points have ignore_invalid set to true - probe types for
|
55
|
-
// which raw_input has invalid number of parts will be ignored (instead
|
56
|
-
diff --git a/tests/runtime/regression b/tests/runtime/regression
|
57
|
-
index 7f40ffdb..b7fa4653 100644
|
58
|
-
--- a/tests/runtime/regression
|
59
|
-
+++ b/tests/runtime/regression
|
60
|
-
@@ -33,3 +33,9 @@ NAME c_array_indexing
|
61
|
-
RUN bpftrace -v -e 'struct Foo { int a; uint8_t b[10]; } uprobe:testprogs/uprobe_test:function2 { $foo = (struct Foo *)arg0; printf("%c %c %c %c %c\n", $foo->b[0], $foo->b[1], $foo->b[2], $foo->b[3], $foo->b[4]) }' -c ./testprogs/uprobe_test
|
62
|
-
EXPECT h e l l o
|
63
|
-
TIMEOUT 5
|
64
|
-
+
|
65
|
-
+# https://github.com/iovisor/bpftrace/issues/1773
|
66
|
-
+NAME single_arg_wildcard_listing
|
67
|
-
+RUN bpftrace -l "*do_nanosleep*"
|
68
|
-
+EXPECT kprobe:do_nanosleep
|
69
|
-
+TIMEOUT 1
|
70
|
-
--
|
71
|
-
2.34.1
|
72
|
-
|
@@ -0,0 +1,834 @@
|
|
1
|
+
From 291cb44a513049e94b8de80f58fa7f08d3491aea Mon Sep 17 00:00:00 2001
|
2
|
+
From: Viktor Malik <viktor.malik@gmail.com>
|
3
|
+
Date: Mon, 10 Jan 2022 16:41:05 +0100
|
4
|
+
Subject: [PATCH 8/8] Fix LLVM 13 warnings
|
5
|
+
|
6
|
+
Since LLVM 13, CreateGEP and CreateLoad require explicit types.
|
7
|
+
---
|
8
|
+
src/ast/codegen_llvm.cpp | 265 ++++++++++++++++++++++++---------------
|
9
|
+
src/ast/irbuilderbpf.cpp | 56 +++++----
|
10
|
+
2 files changed, 200 insertions(+), 121 deletions(-)
|
11
|
+
|
12
|
+
diff --git a/src/ast/codegen_llvm.cpp b/src/ast/codegen_llvm.cpp
|
13
|
+
index d30327a2..0bd23276 100644
|
14
|
+
--- a/src/ast/codegen_llvm.cpp
|
15
|
+
+++ b/src/ast/codegen_llvm.cpp
|
16
|
+
@@ -224,9 +224,10 @@ void CodegenLLVM::visit(Builtin &builtin)
|
17
|
+
// LLVM optimization is possible to transform `(uint64*)ctx` into
|
18
|
+
// `(uint8*)ctx`, but sometimes this causes invalid context access.
|
19
|
+
// Mark every context acess to supporess any LLVM optimization.
|
20
|
+
- expr_ = b_.CreateLoad(b_.getInt64Ty(),
|
21
|
+
- b_.CreateGEP(ctx, b_.getInt64(offset)),
|
22
|
+
- builtin.ident);
|
23
|
+
+ expr_ = b_.CreateLoad(
|
24
|
+
+ b_.getInt64Ty(),
|
25
|
+
+ b_.CreateGEP(b_.getInt64Ty(), ctx, b_.getInt64(offset)),
|
26
|
+
+ builtin.ident);
|
27
|
+
// LLVM 7.0 <= does not have CreateLoad(*Ty, *Ptr, isVolatile, Name),
|
28
|
+
// so call setVolatile() manually
|
29
|
+
dyn_cast<LoadInst>(expr_)->setVolatile(true);
|
30
|
+
@@ -249,16 +250,17 @@ void CodegenLLVM::visit(Builtin &builtin)
|
31
|
+
|
32
|
+
int arg_num = atoi(builtin.ident.substr(4).c_str());
|
33
|
+
Value *ctx = b_.CreatePointerCast(ctx_, b_.getInt64Ty()->getPointerTo());
|
34
|
+
- Value *sp = b_.CreateLoad(b_.getInt64Ty(),
|
35
|
+
- b_.CreateGEP(ctx, b_.getInt64(sp_offset)),
|
36
|
+
- "reg_sp");
|
37
|
+
+ Value *sp = b_.CreateLoad(
|
38
|
+
+ b_.getInt64Ty(),
|
39
|
+
+ b_.CreateGEP(b_.getInt64Ty(), ctx, b_.getInt64(sp_offset)),
|
40
|
+
+ "reg_sp");
|
41
|
+
dyn_cast<LoadInst>(sp)->setVolatile(true);
|
42
|
+
AllocaInst *dst = b_.CreateAllocaBPF(builtin.type, builtin.ident);
|
43
|
+
Value *src = b_.CreateAdd(sp,
|
44
|
+
b_.getInt64((arg_num + arch::arg_stack_offset()) *
|
45
|
+
sizeof(uintptr_t)));
|
46
|
+
b_.CreateProbeRead(ctx_, dst, 8, src, builtin.type.GetAS(), builtin.loc);
|
47
|
+
- expr_ = b_.CreateLoad(dst);
|
48
|
+
+ expr_ = b_.CreateLoad(b_.GetType(builtin.type), dst);
|
49
|
+
b_.CreateLifetimeEnd(dst);
|
50
|
+
}
|
51
|
+
else if (builtin.ident == "probe")
|
52
|
+
@@ -526,8 +528,12 @@ void CodegenLLVM::visit(Call &call)
|
53
|
+
b_.CREATE_MEMSET(buf, b_.getInt8(0), bpftrace_.strlen_, 1);
|
54
|
+
auto arg0 = call.vargs->front();
|
55
|
+
auto scoped_del = accept(call.vargs->front());
|
56
|
+
- b_.CreateProbeReadStr(
|
57
|
+
- ctx_, buf, b_.CreateLoad(strlen), expr_, arg0->type.GetAS(), call.loc);
|
58
|
+
+ b_.CreateProbeReadStr(ctx_,
|
59
|
+
+ buf,
|
60
|
+
+ b_.CreateLoad(b_.getInt64Ty(), strlen),
|
61
|
+
+ expr_,
|
62
|
+
+ arg0->type.GetAS(),
|
63
|
+
+ call.loc);
|
64
|
+
b_.CreateLifetimeEnd(strlen);
|
65
|
+
|
66
|
+
expr_ = buf;
|
67
|
+
@@ -569,12 +575,14 @@ void CodegenLLVM::visit(Call &call)
|
68
|
+
false);
|
69
|
+
AllocaInst *buf = b_.CreateAllocaBPF(buf_struct, "buffer");
|
70
|
+
|
71
|
+
- Value *buf_len_offset = b_.CreateGEP(buf,
|
72
|
+
+ Value *buf_len_offset = b_.CreateGEP(buf_struct,
|
73
|
+
+ buf,
|
74
|
+
{ b_.getInt32(0), b_.getInt32(0) });
|
75
|
+
length = b_.CreateIntCast(length, buf_struct->getElementType(0), false);
|
76
|
+
b_.CreateStore(length, buf_len_offset);
|
77
|
+
|
78
|
+
- Value *buf_data_offset = b_.CreateGEP(buf,
|
79
|
+
+ Value *buf_data_offset = b_.CreateGEP(buf_struct,
|
80
|
+
+ buf,
|
81
|
+
{ b_.getInt32(0), b_.getInt32(1) });
|
82
|
+
b_.CREATE_MEMSET(buf_data_offset,
|
83
|
+
b_.GetIntSameSize(0, elements.at(0)),
|
84
|
+
@@ -664,14 +672,14 @@ void CodegenLLVM::visit(Call &call)
|
85
|
+
b_.SetInsertPoint(notzero);
|
86
|
+
b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::join)), perfdata);
|
87
|
+
b_.CreateStore(b_.getInt64(join_id_),
|
88
|
+
- b_.CreateGEP(perfdata, b_.getInt64(8)));
|
89
|
+
+ b_.CreateGEP(b_.getInt8Ty(), perfdata, b_.getInt64(8)));
|
90
|
+
join_id_++;
|
91
|
+
AllocaInst *arr = b_.CreateAllocaBPF(b_.getInt64Ty(), call.func + "_r0");
|
92
|
+
b_.CreateProbeRead(ctx_, arr, 8, expr_, addrspace, call.loc);
|
93
|
+
b_.CreateProbeReadStr(ctx_,
|
94
|
+
b_.CreateAdd(perfdata, b_.getInt64(8 + 8)),
|
95
|
+
bpftrace_.join_argsize_,
|
96
|
+
- b_.CreateLoad(arr),
|
97
|
+
+ b_.CreateLoad(b_.getInt64Ty(), arr),
|
98
|
+
addrspace,
|
99
|
+
call.loc);
|
100
|
+
|
101
|
+
@@ -679,14 +687,18 @@ void CodegenLLVM::visit(Call &call)
|
102
|
+
{
|
103
|
+
// argi
|
104
|
+
b_.CreateStore(b_.CreateAdd(expr_, b_.getInt64(8 * i)), first);
|
105
|
+
- b_.CreateProbeRead(
|
106
|
+
- ctx_, second, 8, b_.CreateLoad(first), addrspace, call.loc);
|
107
|
+
+ b_.CreateProbeRead(ctx_,
|
108
|
+
+ second,
|
109
|
+
+ 8,
|
110
|
+
+ b_.CreateLoad(b_.getInt64Ty(), first),
|
111
|
+
+ addrspace,
|
112
|
+
+ call.loc);
|
113
|
+
b_.CreateProbeReadStr(
|
114
|
+
ctx_,
|
115
|
+
b_.CreateAdd(perfdata,
|
116
|
+
b_.getInt64(8 + 8 + i * bpftrace_.join_argsize_)),
|
117
|
+
bpftrace_.join_argsize_,
|
118
|
+
- b_.CreateLoad(second),
|
119
|
+
+ b_.CreateLoad(b_.getInt64Ty(), second),
|
120
|
+
addrspace,
|
121
|
+
call.loc);
|
122
|
+
}
|
123
|
+
@@ -729,7 +741,9 @@ void CodegenLLVM::visit(Call &call)
|
124
|
+
|
125
|
+
AllocaInst *buf = b_.CreateAllocaBPF(inet_struct, "inet");
|
126
|
+
|
127
|
+
- Value *af_offset = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) });
|
128
|
+
+ Value *af_offset = b_.CreateGEP(inet_struct,
|
129
|
+
+ buf,
|
130
|
+
+ { b_.getInt64(0), b_.getInt32(0) });
|
131
|
+
Value *af_type;
|
132
|
+
|
133
|
+
auto inet = call.vargs->at(0);
|
134
|
+
@@ -752,7 +766,9 @@ void CodegenLLVM::visit(Call &call)
|
135
|
+
}
|
136
|
+
b_.CreateStore(af_type, af_offset);
|
137
|
+
|
138
|
+
- Value *inet_offset = b_.CreateGEP(buf, {b_.getInt32(0), b_.getInt32(1)});
|
139
|
+
+ Value *inet_offset = b_.CreateGEP(inet_struct,
|
140
|
+
+ buf,
|
141
|
+
+ { b_.getInt32(0), b_.getInt32(1) });
|
142
|
+
b_.CREATE_MEMSET(inet_offset, b_.getInt8(0), 16, 1);
|
143
|
+
|
144
|
+
auto scoped_del = accept(inet);
|
145
|
+
@@ -785,9 +801,10 @@ void CodegenLLVM::visit(Call &call)
|
146
|
+
}
|
147
|
+
|
148
|
+
Value *ctx = b_.CreatePointerCast(ctx_, b_.getInt64Ty()->getPointerTo());
|
149
|
+
- expr_ = b_.CreateLoad(b_.getInt64Ty(),
|
150
|
+
- b_.CreateGEP(ctx, b_.getInt64(offset)),
|
151
|
+
- call.func + "_" + reg_name);
|
152
|
+
+ expr_ = b_.CreateLoad(
|
153
|
+
+ b_.getInt64Ty(),
|
154
|
+
+ b_.CreateGEP(b_.getInt64Ty(), ctx, b_.getInt64(offset)),
|
155
|
+
+ call.func + "_" + reg_name);
|
156
|
+
dyn_cast<LoadInst>(expr_)->setVolatile(true);
|
157
|
+
}
|
158
|
+
else if (call.func == "printf")
|
159
|
+
@@ -812,8 +829,10 @@ void CodegenLLVM::visit(Call &call)
|
160
|
+
auto scoped_del = accept(&arg);
|
161
|
+
|
162
|
+
// and store it to data area
|
163
|
+
- Value *offset = b_.CreateGEP(
|
164
|
+
- data, { b_.getInt64(0), b_.getInt64((i - 1) * ptr_size) });
|
165
|
+
+ Value *offset = b_.CreateGEP(b_.GetType(data_type),
|
166
|
+
+ data,
|
167
|
+
+ { b_.getInt64(0),
|
168
|
+
+ b_.getInt64((i - 1) * ptr_size) });
|
169
|
+
b_.CreateStore(expr_, offset);
|
170
|
+
|
171
|
+
// keep the expression alive, so it's still there
|
172
|
+
@@ -901,7 +920,9 @@ void CodegenLLVM::visit(Call &call)
|
173
|
+
AllocaInst *buf = b_.CreateAllocaBPF(event_struct,
|
174
|
+
call.func + "_" + map.ident);
|
175
|
+
|
176
|
+
- auto aa_ptr = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) });
|
177
|
+
+ auto aa_ptr = b_.CreateGEP(event_struct,
|
178
|
+
+ buf,
|
179
|
+
+ { b_.getInt64(0), b_.getInt32(0) });
|
180
|
+
if (call.func == "clear")
|
181
|
+
b_.CreateStore(b_.GetIntSameSize(asyncactionint(AsyncAction::clear),
|
182
|
+
elements.at(0)),
|
183
|
+
@@ -912,7 +933,9 @@ void CodegenLLVM::visit(Call &call)
|
184
|
+
aa_ptr);
|
185
|
+
|
186
|
+
auto id = bpftrace_.maps[map.ident].value()->id;
|
187
|
+
- auto *ident_ptr = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) });
|
188
|
+
+ auto *ident_ptr = b_.CreateGEP(event_struct,
|
189
|
+
+ buf,
|
190
|
+
+ { b_.getInt64(0), b_.getInt32(1) });
|
191
|
+
b_.CreateStore(b_.GetIntSameSize(id, elements.at(1)), ident_ptr);
|
192
|
+
|
193
|
+
b_.CreatePerfEventOutput(ctx_, buf, getStructSize(event_struct));
|
194
|
+
@@ -928,12 +951,13 @@ void CodegenLLVM::visit(Call &call)
|
195
|
+
|
196
|
+
AllocaInst *buf = b_.CreateAllocaBPF(time_struct, call.func + "_t");
|
197
|
+
|
198
|
+
- b_.CreateStore(b_.GetIntSameSize(asyncactionint(AsyncAction::time),
|
199
|
+
- elements.at(0)),
|
200
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
|
201
|
+
+ b_.CreateStore(
|
202
|
+
+ b_.GetIntSameSize(asyncactionint(AsyncAction::time), elements.at(0)),
|
203
|
+
+ b_.CreateGEP(time_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
|
204
|
+
|
205
|
+
- b_.CreateStore(b_.GetIntSameSize(time_id_, elements.at(1)),
|
206
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
|
207
|
+
+ b_.CreateStore(
|
208
|
+
+ b_.GetIntSameSize(time_id_, elements.at(1)),
|
209
|
+
+ b_.CreateGEP(time_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
|
210
|
+
|
211
|
+
time_id_++;
|
212
|
+
b_.CreatePerfEventOutput(ctx_, buf, getStructSize(time_struct));
|
213
|
+
@@ -948,13 +972,15 @@ void CodegenLLVM::visit(Call &call)
|
214
|
+
true);
|
215
|
+
|
216
|
+
AllocaInst *buf = b_.CreateAllocaBPF(strftime_struct, call.func + "_args");
|
217
|
+
- b_.CreateStore(b_.GetIntSameSize(strftime_id_, elements.at(0)),
|
218
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
|
219
|
+
+ b_.CreateStore(
|
220
|
+
+ b_.GetIntSameSize(strftime_id_, elements.at(0)),
|
221
|
+
+ b_.CreateGEP(strftime_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
|
222
|
+
strftime_id_++;
|
223
|
+
Expression *arg = call.vargs->at(1);
|
224
|
+
auto scoped_del = accept(arg);
|
225
|
+
- b_.CreateStore(expr_,
|
226
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
|
227
|
+
+ b_.CreateStore(
|
228
|
+
+ expr_,
|
229
|
+
+ b_.CreateGEP(strftime_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
|
230
|
+
expr_ = buf;
|
231
|
+
}
|
232
|
+
else if (call.func == "kstack" || call.func == "ustack")
|
233
|
+
@@ -1068,11 +1094,12 @@ void CodegenLLVM::visit(Call &call)
|
234
|
+
AllocaInst *buf = b_.CreateAllocaBPF(unwatch_struct, "unwatch");
|
235
|
+
size_t struct_size = datalayout().getTypeAllocSize(unwatch_struct);
|
236
|
+
|
237
|
+
- b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::watchpoint_detach)),
|
238
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
|
239
|
+
+ b_.CreateStore(
|
240
|
+
+ b_.getInt64(asyncactionint(AsyncAction::watchpoint_detach)),
|
241
|
+
+ b_.CreateGEP(unwatch_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
|
242
|
+
b_.CreateStore(
|
243
|
+
b_.CreateIntCast(expr_, b_.getInt64Ty(), false /* unsigned */),
|
244
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
|
245
|
+
+ b_.CreateGEP(unwatch_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
|
246
|
+
b_.CreatePerfEventOutput(ctx_, buf, struct_size);
|
247
|
+
b_.CreateLifetimeEnd(buf);
|
248
|
+
expr_ = nullptr;
|
249
|
+
@@ -1102,7 +1129,8 @@ void CodegenLLVM::visit(Variable &var)
|
250
|
+
}
|
251
|
+
else
|
252
|
+
{
|
253
|
+
- expr_ = b_.CreateLoad(variables_[var.ident]);
|
254
|
+
+ auto *var_alloca = variables_[var.ident];
|
255
|
+
+ expr_ = b_.CreateLoad(var_alloca->getType()->getElementType(), var_alloca);
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
@@ -1379,13 +1407,15 @@ void CodegenLLVM::visit(Unop &unop)
|
260
|
+
if (unop.is_post_op)
|
261
|
+
expr_ = oldval;
|
262
|
+
else
|
263
|
+
- expr_ = b_.CreateLoad(newval);
|
264
|
+
+ expr_ = b_.CreateLoad(b_.GetType(map.type), newval);
|
265
|
+
b_.CreateLifetimeEnd(newval);
|
266
|
+
}
|
267
|
+
else if (unop.expr->is_variable)
|
268
|
+
{
|
269
|
+
Variable &var = static_cast<Variable&>(*unop.expr);
|
270
|
+
- Value *oldval = b_.CreateLoad(variables_[var.ident]);
|
271
|
+
+ Value *oldval = b_.CreateLoad(
|
272
|
+
+ variables_[var.ident]->getType()->getElementType(),
|
273
|
+
+ variables_[var.ident]);
|
274
|
+
Value *newval;
|
275
|
+
if (is_increment)
|
276
|
+
newval = b_.CreateAdd(oldval, b_.getInt64(1));
|
277
|
+
@@ -1411,9 +1441,10 @@ void CodegenLLVM::visit(Unop &unop)
|
278
|
+
: type.GetSize();
|
279
|
+
auto as = type.GetAS();
|
280
|
+
|
281
|
+
- AllocaInst *dst = b_.CreateAllocaBPF(SizedType(type.type, size), "deref");
|
282
|
+
+ auto dst_type = SizedType(type.type, size);
|
283
|
+
+ AllocaInst *dst = b_.CreateAllocaBPF(dst_type, "deref");
|
284
|
+
b_.CreateProbeRead(ctx_, dst, size, expr_, as, unop.loc);
|
285
|
+
- expr_ = b_.CreateIntCast(b_.CreateLoad(dst),
|
286
|
+
+ expr_ = b_.CreateIntCast(b_.CreateLoad(b_.GetType(dst_type), dst),
|
287
|
+
b_.getInt64Ty(),
|
288
|
+
type.IsSigned());
|
289
|
+
b_.CreateLifetimeEnd(dst);
|
290
|
+
@@ -1434,7 +1465,7 @@ void CodegenLLVM::visit(Unop &unop)
|
291
|
+
int size = unop.type.IsIntegerTy() ? et->GetIntBitWidth() / 8 : 8;
|
292
|
+
AllocaInst *dst = b_.CreateAllocaBPF(*et, "deref");
|
293
|
+
b_.CreateProbeRead(ctx_, dst, size, expr_, type.GetAS(), unop.loc);
|
294
|
+
- expr_ = b_.CreateIntCast(b_.CreateLoad(dst),
|
295
|
+
+ expr_ = b_.CreateIntCast(b_.CreateLoad(b_.GetType(*et), dst),
|
296
|
+
b_.getInt64Ty(),
|
297
|
+
unop.type.IsSigned());
|
298
|
+
b_.CreateLifetimeEnd(dst);
|
299
|
+
@@ -1492,7 +1523,7 @@ void CodegenLLVM::visit(Ternary &ternary)
|
300
|
+
b_.CreateBr(done);
|
301
|
+
|
302
|
+
b_.SetInsertPoint(done);
|
303
|
+
- expr_ = b_.CreateLoad(result);
|
304
|
+
+ expr_ = b_.CreateLoad(b_.GetType(ternary.type), result);
|
305
|
+
}
|
306
|
+
else if (ternary.type.IsStringTy())
|
307
|
+
{
|
308
|
+
@@ -1549,7 +1580,8 @@ void CodegenLLVM::visit(FieldAccess &acc)
|
309
|
+
}
|
310
|
+
else if (type.IsTupleTy())
|
311
|
+
{
|
312
|
+
- Value *src = b_.CreateGEP(expr_,
|
313
|
+
+ Value *src = b_.CreateGEP(b_.GetType(type),
|
314
|
+
+ expr_,
|
315
|
+
{ b_.getInt32(0), b_.getInt32(acc.index) });
|
316
|
+
SizedType &elem_type = type.GetFields()[acc.index].type;
|
317
|
+
|
318
|
+
@@ -1596,10 +1628,12 @@ void CodegenLLVM::visit(FieldAccess &acc)
|
319
|
+
if (field.is_bitfield)
|
320
|
+
{
|
321
|
+
Value *raw;
|
322
|
+
+ auto field_type = b_.GetType(field.type);
|
323
|
+
if (type.IsCtxAccess())
|
324
|
+
- raw = b_.CreateLoad(
|
325
|
+
- b_.CreateIntToPtr(src, b_.GetType(field.type)->getPointerTo()),
|
326
|
+
- true);
|
327
|
+
+ raw = b_.CreateLoad(field_type,
|
328
|
+
+ b_.CreateIntToPtr(src,
|
329
|
+
+ field_type->getPointerTo()),
|
330
|
+
+ true);
|
331
|
+
else
|
332
|
+
{
|
333
|
+
AllocaInst *dst = b_.CreateAllocaBPF(field.type,
|
334
|
+
@@ -1610,7 +1644,7 @@ void CodegenLLVM::visit(FieldAccess &acc)
|
335
|
+
b_.CREATE_MEMSET(dst, b_.getInt8(0), field.type.GetSize(), 1);
|
336
|
+
b_.CreateProbeRead(
|
337
|
+
ctx_, dst, field.bitfield.read_bytes, src, type.GetAS(), acc.loc);
|
338
|
+
- raw = b_.CreateLoad(dst);
|
339
|
+
+ raw = b_.CreateLoad(field_type, dst);
|
340
|
+
b_.CreateLifetimeEnd(dst);
|
341
|
+
}
|
342
|
+
size_t rshiftbits;
|
343
|
+
@@ -1638,7 +1672,8 @@ void CodegenLLVM::visit(FieldAccess &acc)
|
344
|
+
// offset which we add to the start of the tracepoint struct.
|
345
|
+
expr_ = b_.CreateLoad(
|
346
|
+
b_.getInt32Ty(),
|
347
|
+
- b_.CreateGEP(b_.CreatePointerCast(ctx_,
|
348
|
+
+ b_.CreateGEP(b_.getInt32Ty(),
|
349
|
+
+ b_.CreatePointerCast(ctx_,
|
350
|
+
b_.getInt32Ty()->getPointerTo()),
|
351
|
+
b_.getInt64(field.offset / 4)));
|
352
|
+
expr_ = b_.CreateIntCast(expr_, b_.getInt64Ty(), false);
|
353
|
+
@@ -1757,7 +1792,9 @@ void CodegenLLVM::visit(Tuple &tuple)
|
354
|
+
Expression *elem = tuple.elems->at(i);
|
355
|
+
auto scoped_del = accept(elem);
|
356
|
+
|
357
|
+
- Value *dst = b_.CreateGEP(buf, { b_.getInt32(0), b_.getInt32(i) });
|
358
|
+
+ Value *dst = b_.CreateGEP(tuple_ty,
|
359
|
+
+ buf,
|
360
|
+
+ { b_.getInt32(0), b_.getInt32(i) });
|
361
|
+
|
362
|
+
if (onStack(elem->type))
|
363
|
+
b_.CREATE_MEMCPY(dst, expr_, elem->type.GetSize(), 1);
|
364
|
+
@@ -2357,6 +2394,7 @@ std::tuple<Value *, CodegenLLVM::ScopedExprDeleter> CodegenLLVM::getMapKey(
|
365
|
+
size += expr->type.GetSize();
|
366
|
+
}
|
367
|
+
key = b_.CreateAllocaBPF(size, map.ident + "_key");
|
368
|
+
+ auto *key_type = ArrayType::get(b_.getInt8Ty(), size);
|
369
|
+
|
370
|
+
int offset = 0;
|
371
|
+
// Construct a map key in the stack
|
372
|
+
@@ -2364,7 +2402,8 @@ std::tuple<Value *, CodegenLLVM::ScopedExprDeleter> CodegenLLVM::getMapKey(
|
373
|
+
{
|
374
|
+
auto scoped_del = accept(expr);
|
375
|
+
Value *offset_val = b_.CreateGEP(
|
376
|
+
- key, { b_.getInt64(0), b_.getInt64(offset) });
|
377
|
+
+ key_type, key,
|
378
|
+
+ { b_.getInt64(0), b_.getInt64(offset) });
|
379
|
+
|
380
|
+
if (onStack(expr->type))
|
381
|
+
b_.CREATE_MEMCPY(offset_val, expr_, expr->type.GetSize(), 1);
|
382
|
+
@@ -2417,18 +2456,19 @@ AllocaInst *CodegenLLVM::getHistMapKey(Map &map, Value *log2)
|
383
|
+
size += expr->type.GetSize();
|
384
|
+
}
|
385
|
+
key = b_.CreateAllocaBPF(size, map.ident + "_key");
|
386
|
+
+ auto *key_type = ArrayType::get(b_.getInt8Ty(), size);
|
387
|
+
|
388
|
+
int offset = 0;
|
389
|
+
for (Expression *expr : *map.vargs) {
|
390
|
+
auto scoped_del = accept(expr);
|
391
|
+
- Value *offset_val = b_.CreateGEP(key, {b_.getInt64(0), b_.getInt64(offset)});
|
392
|
+
+ Value *offset_val = b_.CreateGEP(key_type, key, {b_.getInt64(0), b_.getInt64(offset)});
|
393
|
+
if (shouldBeOnStackAlready(expr->type))
|
394
|
+
b_.CREATE_MEMCPY(offset_val, expr_, expr->type.GetSize(), 1);
|
395
|
+
else
|
396
|
+
b_.CreateStore(expr_, offset_val);
|
397
|
+
offset += expr->type.GetSize();
|
398
|
+
}
|
399
|
+
- Value *offset_val = b_.CreateGEP(key, {b_.getInt64(0), b_.getInt64(offset)});
|
400
|
+
+ Value *offset_val = b_.CreateGEP(key_type, key, {b_.getInt64(0), b_.getInt64(offset)});
|
401
|
+
b_.CreateStore(log2, offset_val);
|
402
|
+
}
|
403
|
+
else
|
404
|
+
@@ -2475,7 +2515,7 @@ Value *CodegenLLVM::createLogicalAnd(Binop &binop)
|
405
|
+
b_.CreateBr(merge_block);
|
406
|
+
|
407
|
+
b_.SetInsertPoint(merge_block);
|
408
|
+
- return b_.CreateLoad(result);
|
409
|
+
+ return b_.CreateLoad(b_.getInt64Ty(), result);
|
410
|
+
}
|
411
|
+
|
412
|
+
Value *CodegenLLVM::createLogicalOr(Binop &binop)
|
413
|
+
@@ -2514,7 +2554,7 @@ Value *CodegenLLVM::createLogicalOr(Binop &binop)
|
414
|
+
b_.CreateBr(merge_block);
|
415
|
+
|
416
|
+
b_.SetInsertPoint(merge_block);
|
417
|
+
- return b_.CreateLoad(result);
|
418
|
+
+ return b_.CreateLoad(b_.getInt64Ty(), result);
|
419
|
+
}
|
420
|
+
|
421
|
+
Function *CodegenLLVM::createLog2Function()
|
422
|
+
@@ -2558,34 +2598,37 @@ Function *CodegenLLVM::createLog2Function()
|
423
|
+
// test for less than zero
|
424
|
+
BasicBlock *is_less_than_zero = BasicBlock::Create(module_->getContext(), "hist.is_less_than_zero", log2_func);
|
425
|
+
BasicBlock *is_not_less_than_zero = BasicBlock::Create(module_->getContext(), "hist.is_not_less_than_zero", log2_func);
|
426
|
+
- b_.CreateCondBr(b_.CreateICmpSLT(b_.CreateLoad(n_alloc), b_.getInt64(0)),
|
427
|
+
+ b_.CreateCondBr(b_.CreateICmpSLT(b_.CreateLoad(b_.getInt64Ty(), n_alloc),
|
428
|
+
+ b_.getInt64(0)),
|
429
|
+
is_less_than_zero,
|
430
|
+
is_not_less_than_zero);
|
431
|
+
b_.SetInsertPoint(is_less_than_zero);
|
432
|
+
- createRet(b_.CreateLoad(result));
|
433
|
+
+ createRet(b_.CreateLoad(b_.getInt64Ty(), result));
|
434
|
+
b_.SetInsertPoint(is_not_less_than_zero);
|
435
|
+
|
436
|
+
// test for equal to zero
|
437
|
+
BasicBlock *is_zero = BasicBlock::Create(module_->getContext(), "hist.is_zero", log2_func);
|
438
|
+
BasicBlock *is_not_zero = BasicBlock::Create(module_->getContext(), "hist.is_not_zero", log2_func);
|
439
|
+
- b_.CreateCondBr(b_.CreateICmpEQ(b_.CreateLoad(n_alloc), b_.getInt64(0)),
|
440
|
+
+ b_.CreateCondBr(b_.CreateICmpEQ(b_.CreateLoad(b_.getInt64Ty(), n_alloc),
|
441
|
+
+ b_.getInt64(0)),
|
442
|
+
is_zero,
|
443
|
+
is_not_zero);
|
444
|
+
b_.SetInsertPoint(is_zero);
|
445
|
+
b_.CreateStore(b_.getInt64(1), result);
|
446
|
+
- createRet(b_.CreateLoad(result));
|
447
|
+
+ createRet(b_.CreateLoad(b_.getInt64Ty(), result));
|
448
|
+
b_.SetInsertPoint(is_not_zero);
|
449
|
+
|
450
|
+
// power-of-2 index, offset by +2
|
451
|
+
b_.CreateStore(b_.getInt64(2), result);
|
452
|
+
for (int i = 4; i >= 0; i--)
|
453
|
+
{
|
454
|
+
- Value *n = b_.CreateLoad(n_alloc);
|
455
|
+
+ Value *n = b_.CreateLoad(b_.getInt64Ty(), n_alloc);
|
456
|
+
Value *shift = b_.CreateShl(b_.CreateIntCast(b_.CreateICmpSGE(b_.CreateIntCast(n, b_.getInt64Ty(), false), b_.getInt64(1 << (1<<i))), b_.getInt64Ty(), false), i);
|
457
|
+
b_.CreateStore(b_.CreateLShr(n, shift), n_alloc);
|
458
|
+
- b_.CreateStore(b_.CreateAdd(b_.CreateLoad(result), shift), result);
|
459
|
+
+ b_.CreateStore(b_.CreateAdd(b_.CreateLoad(b_.getInt64Ty(), result), shift),
|
460
|
+
+ result);
|
461
|
+
}
|
462
|
+
- createRet(b_.CreateLoad(result));
|
463
|
+
+ createRet(b_.CreateLoad(b_.getInt64Ty(), result));
|
464
|
+
b_.restoreIP(ip);
|
465
|
+
return module_->getFunction("log2");
|
466
|
+
}
|
467
|
+
@@ -2635,8 +2678,8 @@ Function *CodegenLLVM::createLinearFunction()
|
468
|
+
|
469
|
+
// algorithm
|
470
|
+
{
|
471
|
+
- Value *min = b_.CreateLoad(min_alloc);
|
472
|
+
- Value *val = b_.CreateLoad(value_alloc);
|
473
|
+
+ Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc);
|
474
|
+
+ Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc);
|
475
|
+
cmp = b_.CreateICmpSLT(val, min);
|
476
|
+
}
|
477
|
+
BasicBlock *lt_min = BasicBlock::Create(module_->getContext(), "lhist.lt_min", linear_func);
|
478
|
+
@@ -2648,8 +2691,8 @@ Function *CodegenLLVM::createLinearFunction()
|
479
|
+
|
480
|
+
b_.SetInsertPoint(ge_min);
|
481
|
+
{
|
482
|
+
- Value *max = b_.CreateLoad(max_alloc);
|
483
|
+
- Value *val = b_.CreateLoad(value_alloc);
|
484
|
+
+ Value *max = b_.CreateLoad(b_.getInt64Ty(), max_alloc);
|
485
|
+
+ Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc);
|
486
|
+
cmp = b_.CreateICmpSGT(val, max);
|
487
|
+
}
|
488
|
+
BasicBlock *le_max = BasicBlock::Create(module_->getContext(), "lhist.le_max", linear_func);
|
489
|
+
@@ -2658,22 +2701,22 @@ Function *CodegenLLVM::createLinearFunction()
|
490
|
+
|
491
|
+
b_.SetInsertPoint(gt_max);
|
492
|
+
{
|
493
|
+
- Value *step = b_.CreateLoad(step_alloc);
|
494
|
+
- Value *min = b_.CreateLoad(min_alloc);
|
495
|
+
- Value *max = b_.CreateLoad(max_alloc);
|
496
|
+
+ Value *step = b_.CreateLoad(b_.getInt64Ty(), step_alloc);
|
497
|
+
+ Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc);
|
498
|
+
+ Value *max = b_.CreateLoad(b_.getInt64Ty(), max_alloc);
|
499
|
+
Value *div = b_.CreateUDiv(b_.CreateSub(max, min), step);
|
500
|
+
b_.CreateStore(b_.CreateAdd(div, b_.getInt64(1)), result_alloc);
|
501
|
+
- createRet(b_.CreateLoad(result_alloc));
|
502
|
+
+ createRet(b_.CreateLoad(b_.getInt64Ty(), result_alloc));
|
503
|
+
}
|
504
|
+
|
505
|
+
b_.SetInsertPoint(le_max);
|
506
|
+
{
|
507
|
+
- Value *step = b_.CreateLoad(step_alloc);
|
508
|
+
- Value *min = b_.CreateLoad(min_alloc);
|
509
|
+
- Value *val = b_.CreateLoad(value_alloc);
|
510
|
+
+ Value *step = b_.CreateLoad(b_.getInt64Ty(), step_alloc);
|
511
|
+
+ Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc);
|
512
|
+
+ Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc);
|
513
|
+
Value *div3 = b_.CreateUDiv(b_.CreateSub(val, min), step);
|
514
|
+
b_.CreateStore(b_.CreateAdd(div3, b_.getInt64(1)), result_alloc);
|
515
|
+
- createRet(b_.CreateLoad(result_alloc));
|
516
|
+
+ createRet(b_.CreateLoad(b_.getInt64Ty(), result_alloc));
|
517
|
+
}
|
518
|
+
|
519
|
+
b_.restoreIP(ip);
|
520
|
+
@@ -2711,14 +2754,18 @@ void CodegenLLVM::createFormatStringCall(Call &call, int &id, CallArgs &call_arg
|
521
|
+
// as the struct is not packed we need to memset it.
|
522
|
+
b_.CREATE_MEMSET(fmt_args, b_.getInt8(0), struct_size, 1);
|
523
|
+
|
524
|
+
- Value *id_offset = b_.CreateGEP(fmt_args, {b_.getInt32(0), b_.getInt32(0)});
|
525
|
+
+ Value *id_offset = b_.CreateGEP(fmt_struct,
|
526
|
+
+ fmt_args,
|
527
|
+
+ { b_.getInt32(0), b_.getInt32(0) });
|
528
|
+
b_.CreateStore(b_.getInt64(id + asyncactionint(async_action)), id_offset);
|
529
|
+
|
530
|
+
for (size_t i=1; i<call.vargs->size(); i++)
|
531
|
+
{
|
532
|
+
Expression &arg = *call.vargs->at(i);
|
533
|
+
auto scoped_del = accept(&arg);
|
534
|
+
- Value *offset = b_.CreateGEP(fmt_args, {b_.getInt32(0), b_.getInt32(i)});
|
535
|
+
+ Value *offset = b_.CreateGEP(fmt_struct,
|
536
|
+
+ fmt_args,
|
537
|
+
+ { b_.getInt32(0), b_.getInt32(i) });
|
538
|
+
if (needMemcpy(arg.type))
|
539
|
+
b_.CREATE_MEMCPY(offset, expr_, arg.type.GetSize(), 1);
|
540
|
+
else if (arg.type.IsIntegerTy() && arg.type.GetSize() < 8)
|
541
|
+
@@ -2758,10 +2805,12 @@ void CodegenLLVM::generateWatchpointSetupProbe(
|
542
|
+
// Pull out function argument
|
543
|
+
Value *ctx = func->arg_begin();
|
544
|
+
int offset = arch::arg_offset(arg_num);
|
545
|
+
- Value *addr = b_.CreateLoad(
|
546
|
+
- b_.getInt64Ty(),
|
547
|
+
- b_.CreateGEP(ctx, b_.getInt64(offset * sizeof(uintptr_t))),
|
548
|
+
- "arg" + std::to_string(arg_num));
|
549
|
+
+ Value *arg = b_.CreateGEP(b_.getInt8Ty(),
|
550
|
+
+ ctx,
|
551
|
+
+ b_.getInt64(offset * sizeof(uintptr_t)));
|
552
|
+
+ Value *addr = b_.CreateLoad(b_.getInt64Ty(),
|
553
|
+
+ arg,
|
554
|
+
+ "arg" + std::to_string(arg_num));
|
555
|
+
|
556
|
+
// Tell userspace to setup the real watchpoint
|
557
|
+
auto elements = AsyncEvent::Watchpoint().asLLVMType(b_);
|
558
|
+
@@ -2772,12 +2821,16 @@ void CodegenLLVM::generateWatchpointSetupProbe(
|
559
|
+
size_t struct_size = datalayout().getTypeAllocSize(watchpoint_struct);
|
560
|
+
|
561
|
+
// Fill in perf event struct
|
562
|
+
- b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::watchpoint_attach)),
|
563
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
|
564
|
+
- b_.CreateStore(b_.getInt64(watchpoint_id_),
|
565
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
|
566
|
+
+ b_.CreateStore(
|
567
|
+
+ b_.getInt64(asyncactionint(AsyncAction::watchpoint_attach)),
|
568
|
+
+ b_.CreateGEP(watchpoint_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
|
569
|
+
+ b_.CreateStore(
|
570
|
+
+ b_.getInt64(watchpoint_id_),
|
571
|
+
+ b_.CreateGEP(watchpoint_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
|
572
|
+
watchpoint_id_++;
|
573
|
+
- b_.CreateStore(addr, b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(2) }));
|
574
|
+
+ b_.CreateStore(
|
575
|
+
+ addr,
|
576
|
+
+ b_.CreateGEP(watchpoint_struct, buf, { b_.getInt64(0), b_.getInt32(2) }));
|
577
|
+
b_.CreatePerfEventOutput(ctx, buf, struct_size);
|
578
|
+
b_.CreateLifetimeEnd(buf);
|
579
|
+
|
580
|
+
@@ -2796,11 +2849,14 @@ void CodegenLLVM::createPrintMapCall(Call &call)
|
581
|
+
call.func + "_" + map.ident);
|
582
|
+
|
583
|
+
// store asyncactionid:
|
584
|
+
- b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::print)),
|
585
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
|
586
|
+
+ b_.CreateStore(
|
587
|
+
+ b_.getInt64(asyncactionint(AsyncAction::print)),
|
588
|
+
+ b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
|
589
|
+
|
590
|
+
auto id = bpftrace_.maps[map.ident].value()->id;
|
591
|
+
- auto *ident_ptr = b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) });
|
592
|
+
+ auto *ident_ptr = b_.CreateGEP(print_struct,
|
593
|
+
+ buf,
|
594
|
+
+ { b_.getInt64(0), b_.getInt32(1) });
|
595
|
+
b_.CreateStore(b_.GetIntSameSize(id, elements.at(1)), ident_ptr);
|
596
|
+
|
597
|
+
// top, div
|
598
|
+
@@ -2812,14 +2868,16 @@ void CodegenLLVM::createPrintMapCall(Call &call)
|
599
|
+
auto scoped_del = accept(call.vargs->at(arg_idx));
|
600
|
+
|
601
|
+
b_.CreateStore(b_.CreateIntCast(expr_, elements.at(arg_idx), false),
|
602
|
+
- b_.CreateGEP(buf,
|
603
|
+
+ b_.CreateGEP(print_struct,
|
604
|
+
+ buf,
|
605
|
+
{ b_.getInt64(0), b_.getInt32(arg_idx + 1) }));
|
606
|
+
}
|
607
|
+
|
608
|
+
for (; arg_idx < 3; arg_idx++)
|
609
|
+
{
|
610
|
+
b_.CreateStore(b_.GetIntSameSize(0, elements.at(arg_idx)),
|
611
|
+
- b_.CreateGEP(buf,
|
612
|
+
+ b_.CreateGEP(print_struct,
|
613
|
+
+ buf,
|
614
|
+
{ b_.getInt64(0), b_.getInt32(arg_idx + 1) }));
|
615
|
+
}
|
616
|
+
|
617
|
+
@@ -2844,15 +2902,19 @@ void CodegenLLVM::createPrintNonMapCall(Call &call, int &id)
|
618
|
+
size_t struct_size = datalayout().getTypeAllocSize(print_struct);
|
619
|
+
|
620
|
+
// Store asyncactionid:
|
621
|
+
- b_.CreateStore(b_.getInt64(asyncactionint(AsyncAction::print_non_map)),
|
622
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(0) }));
|
623
|
+
+ b_.CreateStore(
|
624
|
+
+ b_.getInt64(asyncactionint(AsyncAction::print_non_map)),
|
625
|
+
+ b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(0) }));
|
626
|
+
|
627
|
+
// Store print id
|
628
|
+
- b_.CreateStore(b_.getInt64(id),
|
629
|
+
- b_.CreateGEP(buf, { b_.getInt64(0), b_.getInt32(1) }));
|
630
|
+
+ b_.CreateStore(
|
631
|
+
+ b_.getInt64(id),
|
632
|
+
+ b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(1) }));
|
633
|
+
|
634
|
+
// Store content
|
635
|
+
- Value *content_offset = b_.CreateGEP(buf, { b_.getInt32(0), b_.getInt32(2) });
|
636
|
+
+ Value *content_offset = b_.CreateGEP(print_struct,
|
637
|
+
+ buf,
|
638
|
+
+ { b_.getInt32(0), b_.getInt32(2) });
|
639
|
+
b_.CREATE_MEMSET(content_offset, b_.getInt8(0), arg.type.GetSize(), 1);
|
640
|
+
if (needMemcpy(arg.type))
|
641
|
+
{
|
642
|
+
@@ -3023,7 +3085,9 @@ void CodegenLLVM::readDatastructElemFromStack(Value *src_data,
|
643
|
+
src_data = b_.CreateIntToPtr(src_data,
|
644
|
+
b_.GetType(data_type)->getPointerTo());
|
645
|
+
|
646
|
+
- Value *src = b_.CreateGEP(src_data, { b_.getInt32(0), index });
|
647
|
+
+ Value *src = b_.CreateGEP(b_.GetType(data_type),
|
648
|
+
+ src_data,
|
649
|
+
+ { b_.getInt32(0), index });
|
650
|
+
|
651
|
+
// It may happen that the result pointer type is not correct, in such case
|
652
|
+
// do a typecast
|
653
|
+
@@ -3034,7 +3098,7 @@ void CodegenLLVM::readDatastructElemFromStack(Value *src_data,
|
654
|
+
if (elem_type.IsIntegerTy() || elem_type.IsPtrTy())
|
655
|
+
{
|
656
|
+
// Load the correct type from src
|
657
|
+
- expr_ = b_.CreateLoad(src, true);
|
658
|
+
+ expr_ = b_.CreateLoad(b_.GetType(elem_type), src, true);
|
659
|
+
}
|
660
|
+
else
|
661
|
+
{
|
662
|
+
@@ -3101,7 +3165,8 @@ void CodegenLLVM::probereadDatastructElem(Value *src_data,
|
663
|
+
// Read data onto stack
|
664
|
+
if (data_type.IsCtxAccess())
|
665
|
+
{
|
666
|
+
- expr_ = b_.CreateLoad(b_.CreateIntToPtr(src, dst_type->getPointerTo()),
|
667
|
+
+ expr_ = b_.CreateLoad(dst_type,
|
668
|
+
+ b_.CreateIntToPtr(src, dst_type->getPointerTo()),
|
669
|
+
true);
|
670
|
+
expr_ = b_.CreateIntCast(expr_, b_.getInt64Ty(), elem_type.IsSigned());
|
671
|
+
|
672
|
+
@@ -3132,7 +3197,7 @@ void CodegenLLVM::probereadDatastructElem(Value *src_data,
|
673
|
+
AllocaInst *dst = b_.CreateAllocaBPF(elem_type, temp_name);
|
674
|
+
b_.CreateProbeRead(
|
675
|
+
ctx_, dst, elem_type.GetSize(), src, data_type.GetAS(), loc);
|
676
|
+
- expr_ = b_.CreateIntCast(b_.CreateLoad(dst),
|
677
|
+
+ expr_ = b_.CreateIntCast(b_.CreateLoad(b_.GetType(elem_type), dst),
|
678
|
+
b_.getInt64Ty(),
|
679
|
+
elem_type.IsSigned());
|
680
|
+
b_.CreateLifetimeEnd(dst);
|
681
|
+
diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp
|
682
|
+
index ab1464d3..59771e91 100644
|
683
|
+
--- a/src/ast/irbuilderbpf.cpp
|
684
|
+
+++ b/src/ast/irbuilderbpf.cpp
|
685
|
+
@@ -94,8 +94,8 @@ AllocaInst *IRBuilderBPF::CreateUSym(llvm::Value *val)
|
686
|
+
Value *pid = CreateLShr(CreateGetPidTgid(), 32);
|
687
|
+
|
688
|
+
// The extra 0 here ensures the type of addr_offset will be int64
|
689
|
+
- Value *addr_offset = CreateGEP(buf, { getInt64(0), getInt32(0) });
|
690
|
+
- Value *pid_offset = CreateGEP(buf, { getInt64(0), getInt32(1) });
|
691
|
+
+ Value *addr_offset = CreateGEP(usym_t, buf, { getInt64(0), getInt32(0) });
|
692
|
+
+ Value *pid_offset = CreateGEP(usym_t, buf, { getInt64(0), getInt32(1) });
|
693
|
+
|
694
|
+
CreateStore(val, addr_offset);
|
695
|
+
CreateStore(pid, pid_offset);
|
696
|
+
@@ -401,7 +401,8 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
|
697
|
+
if (needMemcpy(type))
|
698
|
+
return value;
|
699
|
+
|
700
|
+
- Value *ret = CreateLoad(value);
|
701
|
+
+ // value is a pointer to i64
|
702
|
+
+ Value *ret = CreateLoad(getInt64Ty(), value);
|
703
|
+
CreateLifetimeEnd(value);
|
704
|
+
return ret;
|
705
|
+
}
|
706
|
+
@@ -621,7 +622,10 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
|
707
|
+
// bpftrace's args are internally represented as 64 bit integers. However,
|
708
|
+
// the underlying argument (of the target program) may be less than 64
|
709
|
+
// bits. So we must be careful to zero out unused bits.
|
710
|
+
- Value* reg = CreateGEP(ctx, getInt64(offset * sizeof(uintptr_t)), "load_register");
|
711
|
+
+ Value *reg = CreateGEP(getInt8Ty(),
|
712
|
+
+ ctx,
|
713
|
+
+ getInt64(offset * sizeof(uintptr_t)),
|
714
|
+
+ "load_register");
|
715
|
+
AllocaInst *dst = CreateAllocaBPF(builtin.type, builtin.ident);
|
716
|
+
Value *index_offset = nullptr;
|
717
|
+
if (argument->valid & BCC_USDT_ARGUMENT_INDEX_REGISTER_NAME)
|
718
|
+
@@ -632,7 +636,8 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
|
719
|
+
LOG(FATAL) << "offset for register " << argument->index_register_name
|
720
|
+
<< " not known";
|
721
|
+
}
|
722
|
+
- index_offset = CreateGEP(ctx,
|
723
|
+
+ index_offset = CreateGEP(getInt8Ty(),
|
724
|
+
+ ctx,
|
725
|
+
getInt64(ioffset * sizeof(uintptr_t)),
|
726
|
+
"load_register");
|
727
|
+
index_offset = CreateLoad(getInt64Ty(), index_offset);
|
728
|
+
@@ -754,7 +759,7 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx __attribute__((unused)),
|
729
|
+
"strcmp.loop",
|
730
|
+
parent);
|
731
|
+
|
732
|
+
- auto *ptr = CreateGEP(val, { getInt32(0), getInt32(i) });
|
733
|
+
+ auto *ptr = CreateGEP(valp->getElementType(), val, { getInt32(0), getInt32(i) });
|
734
|
+
Value *l = CreateLoad(getInt8Ty(), ptr);
|
735
|
+
Value *r = getInt8(c_str[i]);
|
736
|
+
Value *cmp = CreateICmpNE(l, r, "strcmp.cmp");
|
737
|
+
@@ -767,7 +772,8 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx __attribute__((unused)),
|
738
|
+
CreateBr(str_ne);
|
739
|
+
|
740
|
+
SetInsertPoint(str_ne);
|
741
|
+
- Value *result = CreateLoad(store);
|
742
|
+
+ // store is a pointer to bool (i1 *)
|
743
|
+
+ Value *result = CreateLoad(getInt1Ty(), store);
|
744
|
+
CreateLifetimeEnd(store);
|
745
|
+
result = CreateIntCast(result, getInt64Ty(), false);
|
746
|
+
return result;
|
747
|
+
@@ -817,9 +823,11 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx,
|
748
|
+
}
|
749
|
+
*/
|
750
|
+
|
751
|
+
+ auto *val1p = dyn_cast<PointerType>(val1->getType());
|
752
|
+
+ auto *val2p = dyn_cast<PointerType>(val2->getType());
|
753
|
+
#ifndef NDEBUG
|
754
|
+
- PointerType *val1p = cast<PointerType>(val1->getType());
|
755
|
+
- PointerType *val2p = cast<PointerType>(val2->getType());
|
756
|
+
+ assert(val1p);
|
757
|
+
+ assert(val2p);
|
758
|
+
|
759
|
+
assert(val1p->getElementType()->isArrayTy() &&
|
760
|
+
val1p->getElementType()->getArrayElementType() == getInt8Ty());
|
761
|
+
@@ -852,11 +860,11 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx,
|
762
|
+
"strcmp.loop_null_cmp",
|
763
|
+
parent);
|
764
|
+
|
765
|
+
- auto *ptr1 = CreateGEP(val1, { getInt32(0), getInt32(i) });
|
766
|
+
+ auto *ptr1 = CreateGEP(val1p->getElementType(), val1, { getInt32(0), getInt32(i) });
|
767
|
+
CreateProbeRead(ctx, val_l, 1, ptr1, as1, loc);
|
768
|
+
Value *l = CreateLoad(getInt8Ty(), val_l);
|
769
|
+
|
770
|
+
- auto *ptr2 = CreateGEP(val2, { getInt32(0), getInt32(i) });
|
771
|
+
+ auto *ptr2 = CreateGEP(val2p->getElementType(), val2, { getInt32(0), getInt32(i) });
|
772
|
+
CreateProbeRead(ctx, val_r, 1, ptr2, as2, loc);
|
773
|
+
Value *r = CreateLoad(getInt8Ty(), val_r);
|
774
|
+
|
775
|
+
@@ -878,7 +886,8 @@ Value *IRBuilderBPF::CreateStrncmp(Value *ctx,
|
776
|
+
CreateBr(str_ne);
|
777
|
+
SetInsertPoint(str_ne);
|
778
|
+
|
779
|
+
- Value *result = CreateLoad(store);
|
780
|
+
+ // store is a pointer to bool (i1 *)
|
781
|
+
+ Value *result = CreateLoad(getInt1Ty(), store);
|
782
|
+
CreateLifetimeEnd(store);
|
783
|
+
CreateLifetimeEnd(val_l);
|
784
|
+
CreateLifetimeEnd(val_r);
|
785
|
+
@@ -1107,7 +1116,7 @@ Value *IRBuilderBPF::CreatKFuncArg(Value *ctx,
|
786
|
+
{
|
787
|
+
ctx = CreatePointerCast(ctx, getInt64Ty()->getPointerTo());
|
788
|
+
Value *expr = CreateLoad(getInt64Ty(),
|
789
|
+
- CreateGEP(ctx, getInt64(type.kfarg_idx)),
|
790
|
+
+ CreateGEP(getInt64Ty(), ctx, getInt64(type.kfarg_idx)),
|
791
|
+
name);
|
792
|
+
|
793
|
+
// LLVM 7.0 <= does not have CreateLoad(*Ty, *Ptr, isVolatile, Name),
|
794
|
+
@@ -1161,12 +1170,15 @@ void IRBuilderBPF::CreateHelperError(Value *ctx,
|
795
|
+
elements,
|
796
|
+
true);
|
797
|
+
AllocaInst *buf = CreateAllocaBPF(helper_error_struct, "helper_error_t");
|
798
|
+
- CreateStore(GetIntSameSize(asyncactionint(AsyncAction::helper_error),
|
799
|
+
- elements.at(0)),
|
800
|
+
- CreateGEP(buf, { getInt64(0), getInt32(0) }));
|
801
|
+
- CreateStore(GetIntSameSize(error_id, elements.at(1)),
|
802
|
+
- CreateGEP(buf, { getInt64(0), getInt32(1) }));
|
803
|
+
- CreateStore(return_value, CreateGEP(buf, { getInt64(0), getInt32(2) }));
|
804
|
+
+ CreateStore(
|
805
|
+
+ GetIntSameSize(asyncactionint(AsyncAction::helper_error), elements.at(0)),
|
806
|
+
+ CreateGEP(helper_error_struct, buf, { getInt64(0), getInt32(0) }));
|
807
|
+
+ CreateStore(
|
808
|
+
+ GetIntSameSize(error_id, elements.at(1)),
|
809
|
+
+ CreateGEP(helper_error_struct, buf, { getInt64(0), getInt32(1) }));
|
810
|
+
+ CreateStore(
|
811
|
+
+ return_value,
|
812
|
+
+ CreateGEP(helper_error_struct, buf, { getInt64(0), getInt32(2) }));
|
813
|
+
|
814
|
+
auto &layout = module_.getDataLayout();
|
815
|
+
auto struct_size = layout.getTypeAllocSize(helper_error_struct);
|
816
|
+
@@ -1256,11 +1268,13 @@ void IRBuilderBPF::CreateSeqPrintf(Value *ctx,
|
817
|
+
|
818
|
+
ctx = CreatePointerCast(ctx, getInt8Ty()->getPointerTo());
|
819
|
+
Value *meta = CreateLoad(getInt64Ty()->getPointerTo(),
|
820
|
+
- CreateGEP(ctx, getInt64(0)),
|
821
|
+
+ CreateGEP(getInt8Ty(), ctx, getInt64(0)),
|
822
|
+
"meta");
|
823
|
+
dyn_cast<LoadInst>(meta)->setVolatile(true);
|
824
|
+
|
825
|
+
- Value *seq = CreateLoad(getInt64Ty(), CreateGEP(meta, getInt64(0)), "seq");
|
826
|
+
+ Value *seq = CreateLoad(getInt64Ty(),
|
827
|
+
+ CreateGEP(getInt64Ty(), meta, getInt64(0)),
|
828
|
+
+ "seq");
|
829
|
+
|
830
|
+
CallInst *call = createCall(seq_printf_func,
|
831
|
+
{ seq, fmt, fmt_size, data, data_len },
|
832
|
+
--
|
833
|
+
2.35.3
|
834
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
From aee721b9b5ed72c287b302df20ea0fffc3cd72bd Mon Sep 17 00:00:00 2001
|
2
|
+
From: Yucong Sun <sunyucong@gmail.com>
|
3
|
+
Date: Thu, 21 Oct 2021 14:43:38 -0700
|
4
|
+
Subject: [PATCH 7/7] Fix compile under llvm14 (trunk)
|
5
|
+
|
6
|
+
---
|
7
|
+
CMakeLists.txt | 2 +-
|
8
|
+
src/bpforc.h | 4 ++++
|
9
|
+
2 files changed, 5 insertions(+), 1 deletion(-)
|
10
|
+
|
11
|
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
12
|
+
index 3beeb027..3cfae6cb 100644
|
13
|
+
--- a/CMakeLists.txt
|
14
|
+
+++ b/CMakeLists.txt
|
15
|
+
@@ -159,7 +159,7 @@ else()
|
16
|
+
find_package(LLVM REQUIRED)
|
17
|
+
endif()
|
18
|
+
|
19
|
+
- if((${LLVM_VERSION_MAJOR} VERSION_LESS 6) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER 12))
|
20
|
+
+ if((${LLVM_VERSION_MAJOR} VERSION_LESS 6) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER 14))
|
21
|
+
message(SEND_ERROR "Unsupported LLVM version found: ${LLVM_INCLUDE_DIRS}")
|
22
|
+
message(SEND_ERROR "Specify an LLVM major version using LLVM_REQUESTED_VERSION=<major version>")
|
23
|
+
endif()
|
24
|
+
diff --git a/src/bpforc.h b/src/bpforc.h
|
25
|
+
index cc6a1c97..a0e5c9b8 100644
|
26
|
+
--- a/src/bpforc.h
|
27
|
+
+++ b/src/bpforc.h
|
28
|
+
|
29
|
+
#include <llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h>
|
30
|
+
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
|
31
|
+
#include <llvm/Support/Error.h>
|
32
|
+
+#if LLVM_VERSION_MAJOR < 14
|
33
|
+
#include <llvm/Support/TargetRegistry.h>
|
34
|
+
+#else
|
35
|
+
+#include <llvm/MC/TargetRegistry.h>
|
36
|
+
+#endif
|
37
|
+
#include <llvm/Target/TargetMachine.h>
|
38
|
+
|
39
|
+
#ifdef LLVM_ORC_V2
|
40
|
+
--
|
41
|
+
2.35.3
|
42
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
From d26accaba6f911cf82be7e9791bf6440213c5627 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Jerome Marchand <jmarchan@redhat.com>
|
3
|
+
Date: Wed, 23 Mar 2022 09:47:25 +0100
|
4
|
+
Subject: [PATCH 4/6] Fix libbtf 0.6.0 build
|
5
|
+
|
6
|
+
Libbtf 0.6.0 introduced a new version of btf_dump__new(). The new
|
7
|
+
version is btf_dump__new_v0_6_0() while the old version was renamed
|
8
|
+
btf_dump__new_deprecated(). btf_dump__new() is now overloaded,
|
9
|
+
unfortunately the macro doesn't work on cpp, at least with LLVM 12.
|
10
|
+
Let's call btf_dump__new_deprecated() explicitely when it's defined.
|
11
|
+
|
12
|
+
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
13
|
+
---
|
14
|
+
src/btf.cpp | 9 +++++++++
|
15
|
+
1 file changed, 9 insertions(+)
|
16
|
+
|
17
|
+
diff --git a/src/btf.cpp b/src/btf.cpp
|
18
|
+
index a5a5e2c0..fccf0a00 100644
|
19
|
+
--- a/src/btf.cpp
|
20
|
+
+++ b/src/btf.cpp
|
21
|
+
|
22
|
+
#pragma GCC diagnostic pop
|
23
|
+
#include <bpf/libbpf.h>
|
24
|
+
|
25
|
+
+/*
|
26
|
+
+ * Since libbtf 0.6, btf_dump__new() has been overloaded and now can design
|
27
|
+
+ * either btf_dump__new_v0_6_0() or btf_dump__new_deprecated(), which is the
|
28
|
+
+ * same as btf_dump__new() for libbtf < 0.6, and the one we still use.
|
29
|
+
+ */
|
30
|
+
+#if LIBBPF_MAJOR_VERSION == 0 && LIBBPF_MINOR_VERSION >= 6
|
31
|
+
+#define btf_dump__new(a1, a2, a3, a4) btf_dump__new_deprecated(a1, a2, a3, a4)
|
32
|
+
+#endif
|
33
|
+
+
|
34
|
+
#include "bpftrace.h"
|
35
|
+
|
36
|
+
namespace bpftrace {
|
37
|
+
--
|
38
|
+
2.35.3
|
39
|
+
|
@@ -1,11 +1,13 @@
|
|
1
|
-
From
|
1
|
+
From 0585b27f6070c0d4016ae9b0d6e1a28261f2e2d2 Mon Sep 17 00:00:00 2001
|
2
2
|
From: Jerome Marchand <jmarchan@redhat.com>
|
3
3
|
Date: Fri, 15 Oct 2021 14:26:28 +0200
|
4
|
-
Subject: [PATCH] Fix mdflush
|
4
|
+
Subject: [PATCH 2/6] Fix mdflush
|
5
5
|
|
6
6
|
Since kernel commit 309dca309fc ("block: store a block_device pointer
|
7
7
|
in struct bio") struct bio points again to a block_device and not to a
|
8
8
|
gendisk directly.
|
9
|
+
|
10
|
+
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
9
11
|
---
|
10
12
|
tools/mdflush.bt | 2 +-
|
11
13
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
@@ -22,5 +24,5 @@ index e767b81d..541abba1 100755
|
|
22
24
|
+ ((struct bio *)arg1)->bi_bdev->bd_disk->disk_name);
|
23
25
|
}
|
24
26
|
--
|
25
|
-
2.
|
27
|
+
2.35.3
|
26
28
|
|
@@ -1,10 +1,12 @@
|
|
1
|
-
From
|
1
|
+
From 4d7c2c148f7fb788d74e6cd3b6d65c07a815b0c1 Mon Sep 17 00:00:00 2001
|
2
2
|
From: Jerome Marchand <jmarchan@redhat.com>
|
3
3
|
Date: Tue, 11 Jun 2019 16:41:59 +0200
|
4
|
-
Subject: [PATCH] RHEL 9 fixes
|
4
|
+
Subject: [PATCH 1/6] RHEL 9 fixes
|
5
5
|
|
6
6
|
Fixes the following RHEL 8 specific issues:
|
7
7
|
- library path in gethostlatency and threadsnoop
|
8
|
+
|
9
|
+
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
8
10
|
---
|
9
11
|
tools/gethostlatency.bt | 12 ++++++------
|
10
12
|
tools/threadsnoop.bt | 2 +-
|
@@ -39,7 +41,7 @@ index 9f4ec31e..dd389c6f 100755
|
|
39
41
|
{
|
40
42
|
$latms = (nsecs - @start[tid]) / 1e6;
|
41
43
|
diff --git a/tools/threadsnoop.bt b/tools/threadsnoop.bt
|
42
|
-
index 3824bc6d..
|
44
|
+
index 3824bc6d..ab52bc48 100755
|
43
45
|
--- a/tools/threadsnoop.bt
|
44
46
|
+++ b/tools/threadsnoop.bt
|
45
47
|
@@ -18,7 +18,7 @@ BEGIN
|
@@ -52,5 +54,5 @@ index 3824bc6d..bdc6e4df 100755
|
|
52
54
|
printf("%-10u %-6d %-16s %s\n", elapsed / 1e6, pid, comm,
|
53
55
|
usym(arg2));
|
54
56
|
--
|
55
|
-
2.
|
57
|
+
2.35.3
|
56
58
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
From
|
1
|
+
From b23980e4f6ed33d98f4f09ef25ae17baca215cce Mon Sep 17 00:00:00 2001
|
2
2
|
From: Jerome Marchand <jmarchan@redhat.com>
|
3
3
|
Date: Thu, 11 Jun 2020 14:56:36 +0200
|
4
|
-
Subject: [PATCH] RHEL
|
4
|
+
Subject: [PATCH 6/6] RHEL: aarch64: fixes statsnoop and opensnoop
|
5
5
|
|
6
6
|
On aarch64 the open syscall has been dropped. Only openat remains,
|
7
7
|
wich is called by libc open() function.
|
@@ -12,6 +12,8 @@ instance, new(l)stat are missing from aarch64.
|
|
12
12
|
|
13
13
|
The only way I can think of fixing thess is RHEL-8 only arch specific
|
14
14
|
patches.
|
15
|
+
|
16
|
+
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
15
17
|
---
|
16
18
|
tools/opensnoop.bt | 2 --
|
17
19
|
tools/statsnoop.bt | 8 ++------
|
@@ -60,5 +62,5 @@ index b2d529e2..f612ea94 100755
|
|
60
62
|
{
|
61
63
|
$ret = args->ret;
|
62
64
|
--
|
63
|
-
2.
|
65
|
+
2.35.3
|
64
66
|
|
@@ -1,84 +1,78 @@
|
|
1
|
-
From
|
1
|
+
From ff22437ef4310a2ab37d732bdd1496a926315691 Mon Sep 17 00:00:00 2001
|
2
2
|
From: Viktor Malik <viktor.malik@gmail.com>
|
3
3
|
Date: Mon, 17 Jan 2022 11:15:26 +0100
|
4
|
-
Subject: [PATCH] Update bio* tools to work on
|
4
|
+
Subject: [PATCH 5/6] Update bio* tools to work on kernel 5.16+
|
5
5
|
|
6
|
-
Kernel commit:
|
6
|
+
Kernel 5.16 contains commit:
|
7
|
-
9e6c144e5fee block: inline hot paths of blk_account_io_*()
|
8
|
-
renamed some functions used in the tools.
|
9
7
|
|
10
|
-
|
8
|
+
https://github.com/torvalds/linux/commit/be6bfe36db1795babe9d92178a47b2e02193cb0f
|
11
|
-
5f8d3bf600d2 block: move struct request to blk-mq.h
|
12
|
-
moved "struct request" to a different header.
|
13
9
|
|
14
|
-
|
10
|
+
which renamed some of the functions that the bio* tools attach to.
|
15
11
|
---
|
16
|
-
tools/biolatency.bt |
|
17
|
-
tools/biosnoop.bt | 6
|
18
|
-
tools/biostacks.bt |
|
19
|
-
3 files changed,
|
12
|
+
tools/biolatency.bt | 6 ++++--
|
13
|
+
tools/biosnoop.bt | 6 ++++--
|
14
|
+
tools/biostacks.bt | 3 ++-
|
15
|
+
3 files changed, 10 insertions(+), 5 deletions(-)
|
20
16
|
|
21
17
|
diff --git a/tools/biolatency.bt b/tools/biolatency.bt
|
22
|
-
index 4ea910b4..
|
18
|
+
index 4ea910b4..d5af1f29 100755
|
23
19
|
--- a/tools/biolatency.bt
|
24
20
|
+++ b/tools/biolatency.bt
|
25
|
-
@@ -16,12 +16,
|
21
|
+
@@ -16,12 +16,14 @@ BEGIN
|
26
22
|
printf("Tracing block device I/O... Hit Ctrl-C to end.\n");
|
27
23
|
}
|
28
24
|
|
29
25
|
-kprobe:blk_account_io_start
|
26
|
+
+kprobe:blk_account_io_start,
|
30
27
|
+kprobe:__blk_account_io_start
|
31
28
|
{
|
32
29
|
@start[arg0] = nsecs;
|
33
30
|
}
|
34
31
|
|
35
32
|
-kprobe:blk_account_io_done
|
33
|
+
+kprobe:blk_account_io_done,
|
36
34
|
+kprobe:__blk_account_io_done
|
37
35
|
/@start[arg0]/
|
38
36
|
{
|
39
37
|
@usecs = hist((nsecs - @start[arg0]) / 1000);
|
40
38
|
diff --git a/tools/biosnoop.bt b/tools/biosnoop.bt
|
41
|
-
index 38ffeb52..
|
39
|
+
index 38ffeb52..aa88f4ba 100755
|
42
40
|
--- a/tools/biosnoop.bt
|
43
41
|
+++ b/tools/biosnoop.bt
|
44
|
-
|
42
|
+
@@ -16,7 +16,8 @@ BEGIN
|
45
|
-
#!/usr/bin/env bpftrace
|
46
|
-
-#include <linux/blkdev.h>
|
47
|
-
+#include <linux/blk-mq.h>
|
48
|
-
/*
|
49
|
-
* biosnoop.bt Block I/O tracing tool, showing per I/O latency.
|
50
|
-
* For Linux, uses bpftrace, eBPF.
|
51
|
-
@@ -16,7 +16,7 @@ BEGIN
|
52
43
|
printf("%-12s %-7s %-16s %-6s %7s\n", "TIME(ms)", "DISK", "COMM", "PID", "LAT(ms)");
|
53
44
|
}
|
54
45
|
|
55
46
|
-kprobe:blk_account_io_start
|
47
|
+
+kprobe:blk_account_io_start,
|
56
48
|
+kprobe:__blk_account_io_start
|
57
49
|
{
|
58
50
|
@start[arg0] = nsecs;
|
59
51
|
@iopid[arg0] = pid;
|
60
|
-
@@ -24,7 +
|
52
|
+
@@ -24,7 +25,8 @@ kprobe:blk_account_io_start
|
61
53
|
@disk[arg0] = ((struct request *)arg0)->rq_disk->disk_name;
|
62
54
|
}
|
63
55
|
|
64
56
|
-kprobe:blk_account_io_done
|
57
|
+
+kprobe:blk_account_io_done,
|
65
58
|
+kprobe:__blk_account_io_done
|
66
59
|
/@start[arg0] != 0 && @iopid[arg0] != 0 && @iocomm[arg0] != ""/
|
67
60
|
|
68
61
|
{
|
69
62
|
diff --git a/tools/biostacks.bt b/tools/biostacks.bt
|
70
|
-
index 58201cdf..
|
63
|
+
index 58201cdf..1bc9f819 100755
|
71
64
|
--- a/tools/biostacks.bt
|
72
65
|
+++ b/tools/biostacks.bt
|
73
|
-
@@ -18,7 +18,
|
66
|
+
@@ -18,7 +18,8 @@ BEGIN
|
74
67
|
printf("Tracing block I/O with init stacks. Hit Ctrl-C to end.\n");
|
75
68
|
}
|
76
69
|
|
77
70
|
-kprobe:blk_account_io_start
|
71
|
+
+kprobe:blk_account_io_start,
|
78
72
|
+kprobe:__blk_account_io_start
|
79
73
|
{
|
80
74
|
@reqstack[arg0] = kstack;
|
81
75
|
@reqts[arg0] = nsecs;
|
82
76
|
--
|
83
|
-
2.
|
77
|
+
2.35.3
|
84
78
|
|
@@ -0,0 +1,98 @@
|
|
1
|
+
From bcb8903067ce7a45b67ad0d5cabf83154b56d5ab Mon Sep 17 00:00:00 2001
|
2
|
+
From: Viktor Malik <viktor.malik@gmail.com>
|
3
|
+
Date: Mon, 9 May 2022 07:58:46 +0200
|
4
|
+
Subject: [PATCH 10/10] biosnoop.bt: handle Linux 5.17 block layer update
|
5
|
+
|
6
|
+
The kernel upstream commit:
|
7
|
+
|
8
|
+
https://github.com/torvalds/linux/commit/f3fa33acca9f0058157214800f68b10d8e71ab7a
|
9
|
+
|
10
|
+
has removed the `rq_disk` field from `struct request`. Instead,
|
11
|
+
`->q->disk` should be used, so this is reflected in biosnoop.bt.
|
12
|
+
|
13
|
+
The old version of the tool (suitable for kernel <= 5.16) is backed up
|
14
|
+
in tools/old and used in the CI.
|
15
|
+
---
|
16
|
+
tools/biosnoop.bt | 2 +-
|
17
|
+
tools/old/biosnoop.bt | 56 +++++++++++++++++++++++++++++++++++++++++++
|
18
|
+
2 files changed, 57 insertions(+), 1 deletion(-)
|
19
|
+
create mode 100755 tools/old/biosnoop.bt
|
20
|
+
|
21
|
+
diff --git a/tools/biosnoop.bt b/tools/biosnoop.bt
|
22
|
+
index 33ad75de..c00ef428 100755
|
23
|
+
--- a/tools/biosnoop.bt
|
24
|
+
+++ b/tools/biosnoop.bt
|
25
|
+
@@ -25,7 +25,7 @@ kprobe:__blk_account_io_start
|
26
|
+
@start[arg0] = nsecs;
|
27
|
+
@iopid[arg0] = pid;
|
28
|
+
@iocomm[arg0] = comm;
|
29
|
+
- @disk[arg0] = ((struct request *)arg0)->rq_disk->disk_name;
|
30
|
+
+ @disk[arg0] = ((struct request *)arg0)->q->disk->disk_name;
|
31
|
+
}
|
32
|
+
|
33
|
+
kprobe:blk_account_io_done,
|
34
|
+
diff --git a/tools/old/biosnoop.bt b/tools/old/biosnoop.bt
|
35
|
+
new file mode 100755
|
36
|
+
index 00000000..1a99643a
|
37
|
+
--- /dev/null
|
38
|
+
+++ b/tools/old/biosnoop.bt
|
39
|
+
|
40
|
+
+#!/usr/bin/env bpftrace
|
41
|
+
+/*
|
42
|
+
+ * biosnoop.bt Block I/O tracing tool, showing per I/O latency.
|
43
|
+
+ * For Linux, uses bpftrace, eBPF.
|
44
|
+
+ *
|
45
|
+
+ * TODO: switch to block tracepoints. Add offset and size columns.
|
46
|
+
+ *
|
47
|
+
+ * This is a bpftrace version of the bcc tool of the same name.
|
48
|
+
+ *
|
49
|
+
+ * For Linux <= 5.16.
|
50
|
+
+ *
|
51
|
+
+ * 15-Nov-2017 Brendan Gregg Created this.
|
52
|
+
+ */
|
53
|
+
+
|
54
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
55
|
+
+#include <linux/blkdev.h>
|
56
|
+
+#include <linux/blk-mq.h>
|
57
|
+
+#endif
|
58
|
+
+
|
59
|
+
+BEGIN
|
60
|
+
+{
|
61
|
+
+ printf("%-12s %-7s %-16s %-6s %7s\n", "TIME(ms)", "DISK", "COMM", "PID", "LAT(ms)");
|
62
|
+
+}
|
63
|
+
+
|
64
|
+
+kprobe:blk_account_io_start,
|
65
|
+
+kprobe:__blk_account_io_start
|
66
|
+
+{
|
67
|
+
+ @start[arg0] = nsecs;
|
68
|
+
+ @iopid[arg0] = pid;
|
69
|
+
+ @iocomm[arg0] = comm;
|
70
|
+
+ @disk[arg0] = ((struct request *)arg0)->rq_disk->disk_name;
|
71
|
+
+}
|
72
|
+
+
|
73
|
+
+kprobe:blk_account_io_done,
|
74
|
+
+kprobe:__blk_account_io_done
|
75
|
+
+/@start[arg0] != 0 && @iopid[arg0] != 0 && @iocomm[arg0] != ""/
|
76
|
+
+
|
77
|
+
+{
|
78
|
+
+ $now = nsecs;
|
79
|
+
+ printf("%-12u %-7s %-16s %-6d %7d\n",
|
80
|
+
+ elapsed / 1e6, @disk[arg0], @iocomm[arg0], @iopid[arg0],
|
81
|
+
+ ($now - @start[arg0]) / 1e6);
|
82
|
+
+
|
83
|
+
+ delete(@start[arg0]);
|
84
|
+
+ delete(@iopid[arg0]);
|
85
|
+
+ delete(@iocomm[arg0]);
|
86
|
+
+ delete(@disk[arg0]);
|
87
|
+
+}
|
88
|
+
+
|
89
|
+
+END
|
90
|
+
+{
|
91
|
+
+ clear(@start);
|
92
|
+
+ clear(@iopid);
|
93
|
+
+ clear(@iocomm);
|
94
|
+
+ clear(@disk);
|
95
|
+
+}
|
96
|
+
--
|
97
|
+
2.35.3
|
98
|
+
|
@@ -1,7 +1,7 @@
|
|
1
|
-
From
|
1
|
+
From f562f8fae4bdb8ac51fc815b725bfaada2371b31 Mon Sep 17 00:00:00 2001
|
2
2
|
From: Khem Raj <raj.khem@gmail.com>
|
3
3
|
Date: Sat, 4 Sep 2021 17:28:17 -0700
|
4
|
-
Subject: [PATCH] orc: Fix build with clang >= 13
|
4
|
+
Subject: [PATCH 3/6] orc: Fix build with clang >= 13
|
5
5
|
|
6
6
|
Fixes errors like
|
7
7
|
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
|
@@ -17,7 +17,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
|
17
17
|
2 files changed, 37 insertions(+), 9 deletions(-)
|
18
18
|
|
19
19
|
diff --git a/src/bpforc.h b/src/bpforc.h
|
20
|
-
index
|
20
|
+
index c333a651..cc6a1c97 100644
|
21
21
|
--- a/src/bpforc.h
|
22
22
|
+++ b/src/bpforc.h
|
23
23
|
|
@@ -30,7 +30,7 @@ index 5634c544..1900e497 100644
|
|
30
30
|
#endif
|
31
31
|
|
32
32
|
#include <optional>
|
33
|
-
@@ -
|
33
|
+
@@ -71,8 +74,12 @@ class BpfOrc
|
34
34
|
std::unique_ptr<TargetMachine> TM;
|
35
35
|
DataLayout DL;
|
36
36
|
#if LLVM_VERSION_MAJOR >= 7
|
@@ -43,7 +43,7 @@ index 5634c544..1900e497 100644
|
|
43
43
|
#if LLVM_VERSION_MAJOR >= 7 && LLVM_VERSION_MAJOR < 12
|
44
44
|
std::shared_ptr<SymbolResolver> Resolver;
|
45
45
|
#endif
|
46
|
-
@@ -
|
46
|
+
@@ -97,7 +104,21 @@ class BpfOrc
|
47
47
|
#endif
|
48
48
|
|
49
49
|
public:
|
@@ -65,7 +65,7 @@ index 5634c544..1900e497 100644
|
|
65
65
|
void compile(std::unique_ptr<Module> M);
|
66
66
|
|
67
67
|
/* Helper for creating a orc object, responsible for creating internal objects
|
68
|
-
@@ -
|
68
|
+
@@ -130,7 +151,7 @@ class BpfOrc
|
69
69
|
#ifdef LLVM_ORC_V2
|
70
70
|
Expected<JITEvaluatedSymbol> lookup(StringRef Name)
|
71
71
|
{
|
@@ -75,10 +75,10 @@ index 5634c544..1900e497 100644
|
|
75
75
|
#endif
|
76
76
|
};
|
77
77
|
diff --git a/src/bpforcv2.cpp b/src/bpforcv2.cpp
|
78
|
-
index
|
78
|
+
index 9876625b..3e6684e4 100644
|
79
79
|
--- a/src/bpforcv2.cpp
|
80
80
|
+++ b/src/bpforcv2.cpp
|
81
|
-
|
81
|
+
|
82
82
|
// Included by bpforc.cpp
|
83
83
|
|
84
84
|
-BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL)
|
@@ -103,15 +103,12 @@ index 209e08e5..104213b0 100644
|
|
103
103
|
- MainJD(cantFail(ES.createJITDylib("<main>")))
|
104
104
|
+ MainJD(cantFail(this->ES->createJITDylib("<main>")))
|
105
105
|
{
|
106
|
-
MainJD.addGenerator(
|
107
|
-
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
|
108
|
-
DL.getGlobalPrefix())));
|
109
106
|
}
|
110
107
|
-
|
111
108
|
LLVMContext &BpfOrc::getContext()
|
112
109
|
{
|
113
110
|
return *CTX.getContext();
|
114
|
-
@@ -
|
111
|
+
@@ -34,8 +36,13 @@ std::unique_ptr<BpfOrc> BpfOrc::Create()
|
115
112
|
// return unique_ptrs
|
116
113
|
auto DL = cantFail(JTMB.getDefaultDataLayoutForTarget());
|
117
114
|
auto TM = cantFail(JTMB.createTargetMachine());
|
@@ -128,5 +125,5 @@ index 209e08e5..104213b0 100644
|
|
128
125
|
|
129
126
|
void BpfOrc::compile(std::unique_ptr<Module> M)
|
130
127
|
--
|
131
|
-
2.
|
128
|
+
2.35.3
|
132
129
|
|
@@ -0,0 +1,285 @@
|
|
1
|
+
From 9c9ac55573ac33abbbbad256eda08dafba18bf9f Mon Sep 17 00:00:00 2001
|
2
|
+
From: Jerome Marchand <jmarchan@redhat.com>
|
3
|
+
Date: Thu, 29 Apr 2021 12:03:28 +0200
|
4
|
+
Subject: [PATCH 9/9] tools: Make tools rely on BTF instead of header files.
|
5
|
+
|
6
|
+
Many distribution already ship BTF and this is more robust that
|
7
|
+
parsing header files.
|
8
|
+
|
9
|
+
Fixes #1820
|
10
|
+
---
|
11
|
+
docs/reference_guide.md | 3 ++-
|
12
|
+
src/clang_parser.cpp | 4 ++++
|
13
|
+
tools/biosnoop.bt | 5 ++++-
|
14
|
+
tools/dcsnoop.bt | 2 ++
|
15
|
+
tools/mdflush.bt | 2 ++
|
16
|
+
tools/naptime.bt | 2 ++
|
17
|
+
tools/oomkill.bt | 2 ++
|
18
|
+
tools/runqlen.bt | 6 ++++--
|
19
|
+
tools/tcpaccept.bt | 4 ++++
|
20
|
+
tools/tcpconnect.bt | 4 ++++
|
21
|
+
tools/tcpdrop.bt | 4 ++++
|
22
|
+
tools/tcplife.bt | 4 ++++
|
23
|
+
tools/tcpretrans.bt | 4 ++++
|
24
|
+
tools/tcpsynbl.bt | 2 ++
|
25
|
+
14 files changed, 44 insertions(+), 4 deletions(-)
|
26
|
+
|
27
|
+
diff --git a/docs/reference_guide.md b/docs/reference_guide.md
|
28
|
+
index 69a8ed22..11a685de 100644
|
29
|
+
--- a/docs/reference_guide.md
|
30
|
+
+++ b/docs/reference_guide.md
|
31
|
+
@@ -3455,7 +3455,8 @@ Attaching 1 probe...
|
32
|
+
# BTF Support
|
33
|
+
|
34
|
+
If kernel has BTF, kernel types are automatically available and there is no need to include additional headers
|
35
|
+
-to use them.
|
36
|
+
+to use them. To allow users to detect this situation in scripts, the preprocessor macro `BPFTRACE_HAVE_BTF`
|
37
|
+
+is defined if BTF is detected. See tools/ for examples of its usage.
|
38
|
+
|
39
|
+
Requirements for using BTF:
|
40
|
+
|
41
|
+
diff --git a/src/clang_parser.cpp b/src/clang_parser.cpp
|
42
|
+
index 20269a71..7fb39949 100644
|
43
|
+
--- a/src/clang_parser.cpp
|
44
|
+
+++ b/src/clang_parser.cpp
|
45
|
+
@@ -747,6 +747,9 @@ bool ClangParser::parse(ast::Program *program, BPFtrace &bpftrace, std::vector<s
|
46
|
+
// Since we're omitting <linux/types.h> there's no reason to
|
47
|
+
// add the wokarounds for it
|
48
|
+
args.push_back("-D__CLANG_WORKAROUNDS_H");
|
49
|
+
+ // Let script know we have BTF -- this is useful for prewritten tools to
|
50
|
+
+ // conditionally include headers if BTF isn't available.
|
51
|
+
+ args.push_back("-DBPFTRACE_HAVE_BTF");
|
52
|
+
|
53
|
+
if (handler.parse_file("definitions.h", input, args, input_files, false) &&
|
54
|
+
handler.has_redefinition_error())
|
55
|
+
@@ -779,6 +782,7 @@ bool ClangParser::parse(ast::Program *program, BPFtrace &bpftrace, std::vector<s
|
56
|
+
// taken from BTF. We cannot use BTF in such a case.
|
57
|
+
args.pop_back();
|
58
|
+
args.pop_back();
|
59
|
+
+ args.pop_back();
|
60
|
+
input_files.back() = get_empty_btf_generated_header();
|
61
|
+
}
|
62
|
+
|
63
|
+
diff --git a/tools/biosnoop.bt b/tools/biosnoop.bt
|
64
|
+
index aa88f4ba..33ad75de 100755
|
65
|
+
--- a/tools/biosnoop.bt
|
66
|
+
+++ b/tools/biosnoop.bt
|
67
|
+
|
68
|
+
#!/usr/bin/env bpftrace
|
69
|
+
-#include <linux/blkdev.h>
|
70
|
+
/*
|
71
|
+
* biosnoop.bt Block I/O tracing tool, showing per I/O latency.
|
72
|
+
* For Linux, uses bpftrace, eBPF.
|
73
|
+
|
74
|
+
* 15-Nov-2017 Brendan Gregg Created this.
|
75
|
+
*/
|
76
|
+
|
77
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
78
|
+
+#include <linux/blkdev.h>
|
79
|
+
+#endif
|
80
|
+
+
|
81
|
+
BEGIN
|
82
|
+
{
|
83
|
+
printf("%-12s %-7s %-16s %-6s %7s\n", "TIME(ms)", "DISK", "COMM", "PID", "LAT(ms)");
|
84
|
+
diff --git a/tools/dcsnoop.bt b/tools/dcsnoop.bt
|
85
|
+
index 183f0fb5..e85ab1aa 100755
|
86
|
+
--- a/tools/dcsnoop.bt
|
87
|
+
+++ b/tools/dcsnoop.bt
|
88
|
+
|
89
|
+
* 08-Sep-2018 Brendan Gregg Created this.
|
90
|
+
*/
|
91
|
+
|
92
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
93
|
+
#include <linux/fs.h>
|
94
|
+
#include <linux/sched.h>
|
95
|
+
|
96
|
+
@@ -24,6 +25,7 @@ struct nameidata {
|
97
|
+
struct qstr last;
|
98
|
+
// [...]
|
99
|
+
};
|
100
|
+
+#endif
|
101
|
+
|
102
|
+
BEGIN
|
103
|
+
{
|
104
|
+
diff --git a/tools/mdflush.bt b/tools/mdflush.bt
|
105
|
+
index 541abba1..1db547f6 100755
|
106
|
+
--- a/tools/mdflush.bt
|
107
|
+
+++ b/tools/mdflush.bt
|
108
|
+
|
109
|
+
* 08-Sep-2018 Brendan Gregg Created this.
|
110
|
+
*/
|
111
|
+
|
112
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
113
|
+
#include <linux/genhd.h>
|
114
|
+
#include <linux/bio.h>
|
115
|
+
+#endif
|
116
|
+
|
117
|
+
BEGIN
|
118
|
+
{
|
119
|
+
diff --git a/tools/naptime.bt b/tools/naptime.bt
|
120
|
+
index eb96b677..a84652a3 100755
|
121
|
+
--- a/tools/naptime.bt
|
122
|
+
+++ b/tools/naptime.bt
|
123
|
+
|
124
|
+
* 16-Feb-2019 Brendan Gregg Created this.
|
125
|
+
*/
|
126
|
+
|
127
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
128
|
+
#include <linux/time.h>
|
129
|
+
#include <linux/sched.h>
|
130
|
+
+#endif
|
131
|
+
|
132
|
+
BEGIN
|
133
|
+
{
|
134
|
+
diff --git a/tools/oomkill.bt b/tools/oomkill.bt
|
135
|
+
index 6126682d..1c9b16a3 100755
|
136
|
+
--- a/tools/oomkill.bt
|
137
|
+
+++ b/tools/oomkill.bt
|
138
|
+
|
139
|
+
* 07-Sep-2018 Brendan Gregg Created this.
|
140
|
+
*/
|
141
|
+
|
142
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
143
|
+
#include <linux/oom.h>
|
144
|
+
+#endif
|
145
|
+
|
146
|
+
BEGIN
|
147
|
+
{
|
148
|
+
diff --git a/tools/runqlen.bt b/tools/runqlen.bt
|
149
|
+
index 02d82d74..1be42adc 100755
|
150
|
+
--- a/tools/runqlen.bt
|
151
|
+
+++ b/tools/runqlen.bt
|
152
|
+
|
153
|
+
* 07-Oct-2018 Brendan Gregg Created this.
|
154
|
+
*/
|
155
|
+
|
156
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
157
|
+
#include <linux/sched.h>
|
158
|
+
|
159
|
+
// Until BTF is available, we'll need to declare some of this struct manually,
|
160
|
+
// since it isn't available to be #included. This will need maintenance to match
|
161
|
+
// your kernel version. It is from kernel/sched/sched.h:
|
162
|
+
-struct cfs_rq_partial {
|
163
|
+
+struct cfs_rq {
|
164
|
+
struct load_weight load;
|
165
|
+
unsigned long runnable_weight;
|
166
|
+
unsigned int nr_running;
|
167
|
+
unsigned int h_nr_running;
|
168
|
+
};
|
169
|
+
+#endif
|
170
|
+
|
171
|
+
BEGIN
|
172
|
+
{
|
173
|
+
@@ -31,7 +33,7 @@ BEGIN
|
174
|
+
profile:hz:99
|
175
|
+
{
|
176
|
+
$task = (struct task_struct *)curtask;
|
177
|
+
- $my_q = (struct cfs_rq_partial *)$task->se.cfs_rq;
|
178
|
+
+ $my_q = (struct cfs_rq *)$task->se.cfs_rq;
|
179
|
+
$len = $my_q->nr_running;
|
180
|
+
$len = $len > 0 ? $len - 1 : 0; // subtract currently running task
|
181
|
+
@runqlen = lhist($len, 0, 100, 1);
|
182
|
+
diff --git a/tools/tcpaccept.bt b/tools/tcpaccept.bt
|
183
|
+
index b40a041b..2f4dfe1f 100755
|
184
|
+
--- a/tools/tcpaccept.bt
|
185
|
+
+++ b/tools/tcpaccept.bt
|
186
|
+
|
187
|
+
* 23-Nov-2018 Dale Hamel created this.
|
188
|
+
*/
|
189
|
+
|
190
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
191
|
+
#include <linux/socket.h>
|
192
|
+
#include <net/sock.h>
|
193
|
+
+#else
|
194
|
+
+#include <sys/socket.h>
|
195
|
+
+#endif
|
196
|
+
|
197
|
+
BEGIN
|
198
|
+
{
|
199
|
+
diff --git a/tools/tcpconnect.bt b/tools/tcpconnect.bt
|
200
|
+
index 4ae30d65..05c3ca0e 100755
|
201
|
+
--- a/tools/tcpconnect.bt
|
202
|
+
+++ b/tools/tcpconnect.bt
|
203
|
+
|
204
|
+
* 23-Nov-2018 Dale Hamel created this.
|
205
|
+
*/
|
206
|
+
|
207
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
208
|
+
#include <linux/socket.h>
|
209
|
+
#include <net/sock.h>
|
210
|
+
+#else
|
211
|
+
+#include <sys/socket.h>
|
212
|
+
+#endif
|
213
|
+
|
214
|
+
BEGIN
|
215
|
+
{
|
216
|
+
diff --git a/tools/tcpdrop.bt b/tools/tcpdrop.bt
|
217
|
+
index 79a86b08..2de3e507 100755
|
218
|
+
--- a/tools/tcpdrop.bt
|
219
|
+
+++ b/tools/tcpdrop.bt
|
220
|
+
|
221
|
+
* 23-Nov-2018 Dale Hamel created this.
|
222
|
+
*/
|
223
|
+
|
224
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
225
|
+
#include <linux/socket.h>
|
226
|
+
#include <net/sock.h>
|
227
|
+
+#else
|
228
|
+
+#include <sys/socket.h>
|
229
|
+
+#endif
|
230
|
+
|
231
|
+
BEGIN
|
232
|
+
{
|
233
|
+
diff --git a/tools/tcplife.bt b/tools/tcplife.bt
|
234
|
+
index 9c0d8814..a9a054bf 100755
|
235
|
+
--- a/tools/tcplife.bt
|
236
|
+
+++ b/tools/tcplife.bt
|
237
|
+
|
238
|
+
* 17-Apr-2019 Brendan Gregg Created this.
|
239
|
+
*/
|
240
|
+
|
241
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
242
|
+
#include <net/tcp_states.h>
|
243
|
+
#include <net/sock.h>
|
244
|
+
#include <linux/socket.h>
|
245
|
+
#include <linux/tcp.h>
|
246
|
+
+#else
|
247
|
+
+#include <sys/socket.h>
|
248
|
+
+#endif
|
249
|
+
|
250
|
+
BEGIN
|
251
|
+
{
|
252
|
+
diff --git a/tools/tcpretrans.bt b/tools/tcpretrans.bt
|
253
|
+
index 8b9500c0..777d78fa 100755
|
254
|
+
--- a/tools/tcpretrans.bt
|
255
|
+
+++ b/tools/tcpretrans.bt
|
256
|
+
|
257
|
+
* 23-Nov-2018 Dale Hamel created this.
|
258
|
+
*/
|
259
|
+
|
260
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
261
|
+
#include <linux/socket.h>
|
262
|
+
#include <net/sock.h>
|
263
|
+
+#else
|
264
|
+
+#include <sys/socket.h>
|
265
|
+
+#endif
|
266
|
+
|
267
|
+
BEGIN
|
268
|
+
{
|
269
|
+
diff --git a/tools/tcpsynbl.bt b/tools/tcpsynbl.bt
|
270
|
+
index 4b3c99c3..0570f29c 100755
|
271
|
+
--- a/tools/tcpsynbl.bt
|
272
|
+
+++ b/tools/tcpsynbl.bt
|
273
|
+
|
274
|
+
* 19-Apr-2019 Brendan Gregg Created this.
|
275
|
+
*/
|
276
|
+
|
277
|
+
+#ifndef BPFTRACE_HAVE_BTF
|
278
|
+
#include <net/sock.h>
|
279
|
+
+#endif
|
280
|
+
|
281
|
+
BEGIN
|
282
|
+
{
|
283
|
+
--
|
284
|
+
2.35.3
|
285
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Name: bpftrace
|
2
|
-
Version: 0.
|
3
|
-
Release:
|
2
|
+
Version: 0.13.1
|
3
|
+
Release: 1%{?dist}
|
4
4
|
Summary: High-level tracing language for Linux eBPF
|
5
5
|
License: ASL 2.0
|
6
6
|
|
@@ -9,10 +9,14 @@ Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
|
9
9
|
Patch0: %{name}-%{version}-RHEL-9-fixes.patch
|
10
10
|
Patch1: %{name}-%{version}-Fix-mdflush.patch
|
11
11
|
Patch2: %{name}-%{version}-orc-Fix-build-with-clang-13.patch
|
12
|
-
Patch3: %{name}-%{version}-
|
13
|
-
Patch4: %{name}-%{version}-
|
12
|
+
Patch3: %{name}-%{version}-Update-bio-tools-to-work-on-kernel-5.16.patch
|
13
|
+
Patch4: %{name}-%{version}-tools-Make-tools-rely-on-BTF-instead-of-header-files.patch
|
14
|
+
Patch5: %{name}-%{version}-Fix-libbtf-0.6.0-build.patch
|
15
|
+
Patch6: %{name}-%{version}-Fix-compile-under-llvm14-trunk.patch
|
16
|
+
Patch7: %{name}-%{version}-Fix-LLVM-13-warnings.patch
|
17
|
+
Patch8: %{name}-%{version}-biosnoop.bt-handle-Linux-5.17-block-layer-update.patch
|
14
18
|
|
15
|
-
Patch10: %{name}-%{version}-aarch64-fixes-statsnoop-and-opensnoop.patch
|
19
|
+
Patch10: %{name}-%{version}-RHEL-aarch64-fixes-statsnoop-and-opensnoop.patch
|
16
20
|
|
17
21
|
# Arches will be included as upstream support is added and dependencies are
|
18
22
|
# satisfied in the respective arches
|
@@ -85,6 +89,10 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \
|
|
85
89
|
%{_datadir}/%{name}/tools/doc/*.txt
|
86
90
|
|
87
91
|
%changelog
|
92
|
+
* Mon May 16 2022 Jerome Marchand <jmarchan@redhat.com> - 0.13.1-1
|
93
|
+
- Rebase to bpftrace 0.13.1
|
94
|
+
- Rebuild for LLVM14
|
95
|
+
|
88
96
|
* Mon Feb 21 2022 Viktor Malik <vmalik@redhat.com> - 0.12.1-8
|
89
97
|
- Fix wildcard listing bug
|
90
98
|
- Fix bio* tools
|