Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Nov 15, 2023
1 parent c429660 commit 685ce16
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function(set_project_warnings project_name)
-Wno-unused-function
-Wno-unused-parameter
-Wno-unused-variable
-Wno-missing-field-initializers
)

if (BPFTIME_WARNINGS_AS_ERRORS)
Expand Down
2 changes: 1 addition & 1 deletion cmake/StandardSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if(BPFTIME_ENABLE_LTO)
endif()
endif()

option(BPFTIME_ENABLE_CCACHE "Enable the usage of Ccache, in order to speed up rebuild times." ON)
option(BPFTIME_ENABLE_CCACHE "Enable the usage of Ccache, in order to speed up rebuild times." OFF)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
Expand Down
24 changes: 13 additions & 11 deletions daemon/kernel/bpf_tracer.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ int tracepoint__syscalls__sys_exit_bpf(struct trace_event_raw_sys_exit *ctx)

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

static __always_inline int
process_perf_event_open_enter(struct trace_event_raw_sys_enter *ctx)
Expand All @@ -393,18 +395,18 @@ process_perf_event_open_enter(struct trace_event_raw_sys_enter *ctx)
if (!attr) {
return 0;
}
bpf_probe_read_user(&new_attr, sizeof(new_attr), attr);

if (new_attr.type == uprobe_perf_type) {
bpf_probe_read_user(&new_attr_buffer, sizeof(new_attr_buffer), attr);
struct perf_event_attr* new_attr_pointer = &new_attr_buffer;
if (new_attr_pointer->type == uprobe_perf_type) {
// found uprobe
if (enable_replace_uprobe) {
if (can_hook_uprobe_at(new_attr.probe_offset)) {
u64 old_offset = new_attr.probe_offset;
new_attr.probe_offset = 0;
if (can_hook_uprobe_at(new_attr_pointer->probe_offset)) {
u64 old_offset = new_attr_pointer->probe_offset;
new_attr_pointer->probe_offset = 0;
long size = bpf_probe_read_user_str(
old_uprobe_path,
sizeof(old_uprobe_path),
(void *)new_attr.uprobe_path);
(void *)new_attr_pointer->uprobe_path);
if (size <= 0) {
// no uprobe path
return 0;
Expand All @@ -413,10 +415,10 @@ process_perf_event_open_enter(struct trace_event_raw_sys_enter *ctx)
size = PATH_LENTH;
}
bpf_probe_write_user(
(void *)new_attr.uprobe_path,
(void *)new_attr_pointer->uprobe_path,
&new_uprobe_path, (size_t)size);
bpf_probe_write_user(attr, &new_attr,
sizeof(new_attr));
bpf_probe_write_user(attr, new_attr_pointer,
sizeof(*new_attr_pointer));
// This probe creation request should be
// executed in userspace
bpf_printk(
Expand Down
5 changes: 2 additions & 3 deletions runtime/include/bpftime_prog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ class bpftime_prog {
// vm at the first element
struct ebpf_vm *vm;

enum bpftime_runtime {

}
bool jitted;

// used in jit
ebpf_jit_fn fn;
std::vector<struct ebpf_inst> insns;
Expand Down

0 comments on commit 685ce16

Please sign in to comment.