Skip to content

Commit 9be5389

Browse files
committed
fix compile
1 parent c429660 commit 9be5389

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

cmake/CompilerWarnings.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function(set_project_warnings project_name)
6464
-Wno-unused-function
6565
-Wno-unused-parameter
6666
-Wno-unused-variable
67+
-Wno-missing-field-initializers
6768
)
6869

6970
if (BPFTIME_WARNINGS_AS_ERRORS)

cmake/StandardSettings.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if(BPFTIME_ENABLE_LTO)
5151
endif()
5252
endif()
5353

54-
option(BPFTIME_ENABLE_CCACHE "Enable the usage of Ccache, in order to speed up rebuild times." ON)
54+
option(BPFTIME_ENABLE_CCACHE "Enable the usage of Ccache, in order to speed up rebuild times." OFF)
5555
find_program(CCACHE_FOUND ccache)
5656
if(CCACHE_FOUND)
5757
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)

daemon/kernel/bpf_tracer.bpf.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ int tracepoint__syscalls__sys_exit_bpf(struct trace_event_raw_sys_exit *ctx)
384384

385385
// uprobe path buffer for bpf_probe_read_user_str
386386
char old_uprobe_path[PATH_LENTH] = "\0";
387-
struct perf_event_attr new_attr = {};
387+
// avoid type mismatch in userspace program
388+
// struct perf_event_attr new_attr = {}; will result in compile error
389+
char new_attr_buffer[sizeof(struct perf_event_attr)] = "\0";
388390

389391
static __always_inline int
390392
process_perf_event_open_enter(struct trace_event_raw_sys_enter *ctx)
@@ -393,18 +395,18 @@ process_perf_event_open_enter(struct trace_event_raw_sys_enter *ctx)
393395
if (!attr) {
394396
return 0;
395397
}
396-
bpf_probe_read_user(&new_attr, sizeof(new_attr), attr);
397-
398-
if (new_attr.type == uprobe_perf_type) {
398+
bpf_probe_read_user(&new_attr_buffer, sizeof(new_attr_buffer), attr);
399+
struct perf_event_attr* new_attr_pointer = &new_attr_buffer;
400+
if (new_attr_pointer->type == uprobe_perf_type) {
399401
// found uprobe
400402
if (enable_replace_uprobe) {
401-
if (can_hook_uprobe_at(new_attr.probe_offset)) {
402-
u64 old_offset = new_attr.probe_offset;
403-
new_attr.probe_offset = 0;
403+
if (can_hook_uprobe_at(new_attr_pointer->probe_offset)) {
404+
u64 old_offset = new_attr_pointer->probe_offset;
405+
new_attr_pointer->probe_offset = 0;
404406
long size = bpf_probe_read_user_str(
405407
old_uprobe_path,
406408
sizeof(old_uprobe_path),
407-
(void *)new_attr.uprobe_path);
409+
(void *)new_attr_pointer->uprobe_path);
408410
if (size <= 0) {
409411
// no uprobe path
410412
return 0;
@@ -413,10 +415,10 @@ process_perf_event_open_enter(struct trace_event_raw_sys_enter *ctx)
413415
size = PATH_LENTH;
414416
}
415417
bpf_probe_write_user(
416-
(void *)new_attr.uprobe_path,
418+
(void *)new_attr_pointer->uprobe_path,
417419
&new_uprobe_path, (size_t)size);
418-
bpf_probe_write_user(attr, &new_attr,
419-
sizeof(new_attr));
420+
bpf_probe_write_user(attr, new_attr_pointer,
421+
sizeof(*new_attr_pointer));
420422
// This probe creation request should be
421423
// executed in userspace
422424
bpf_printk(

runtime/include/bpftime_prog.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ class bpftime_prog {
3838
// vm at the first element
3939
struct ebpf_vm *vm;
4040

41-
enum bpftime_runtime {
42-
43-
}
41+
bool jitted;
42+
4443
// used in jit
4544
ebpf_jit_fn fn;
4645
std::vector<struct ebpf_inst> insns;

0 commit comments

Comments
 (0)