Skip to content

Commit

Permalink
compile pahole from source in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mmat11 committed Oct 5, 2023
1 parent 1ee399b commit 67ff56f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 31 deletions.
34 changes: 26 additions & 8 deletions non-GPL/Events/Lib/EbpfEvents.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const struct btf_type *resolve_btf_type_by_func(struct btf *btf, const char *fun
continue;

const struct btf_type *btf_type_ptr = btf__type_by_id(btf, btf_type);

if (!btf_is_func(btf_type_ptr))
continue;

Expand All @@ -145,6 +144,7 @@ const struct btf_type *resolve_btf_type_by_func(struct btf *btf, const char *fun
}

out:
verbose("resolve_btf_type_by_func(%s): not found\n", func);
return NULL;
}

Expand All @@ -156,8 +156,6 @@ static int resolve_btf_func_arg_idx(struct btf *btf, const char *func, const cha
const struct btf_type *proto_btf_type_ptr = resolve_btf_type_by_func(btf, func);
if (!proto_btf_type_ptr)
goto out;
if (!arg)
goto out;

struct btf_param *params = btf_params(proto_btf_type_ptr);
for (int j = 0; j < btf_vlen(proto_btf_type_ptr); j++) {
Expand All @@ -170,6 +168,7 @@ static int resolve_btf_func_arg_idx(struct btf *btf, const char *func, const cha
goto out;
}
}
verbose("resolve_btf_func_arg_idx(%s, %s): not found\n", func, arg);

out:
return ret;
Expand Down Expand Up @@ -198,6 +197,8 @@ static int resolve_btf_func_ret_idx(struct btf *btf, const char *func)
int r = resolve_btf_func_arg_idx(btf, #func, #arg); \
if (r >= 0) \
__r = 0; \
else \
verbose("fill func arg idx (%s, %s): %d\n", #func, #arg, r); \
obj->rodata->arg__##func##__##arg##__ = r; \
__r; \
})
Expand All @@ -209,6 +210,8 @@ static int resolve_btf_func_ret_idx(struct btf *btf, const char *func)
int r = resolve_btf_func_ret_idx(btf, #func); \
if (r >= 0) \
__r = 0; \
else \
verbose("fill func ret idx (%s): %d\n", #func, r); \
obj->rodata->ret__##func##__ = r; \
__r; \
})
Expand All @@ -223,6 +226,8 @@ static int resolve_btf_func_ret_idx(struct btf *btf, const char *func)
if (r >= 0) { \
obj->rodata->exists__##func##__##arg##__ = true; \
__r = 0; \
} else { \
verbose("fill func arg exists (%s, %s): %d\n", #func, #arg, r); \
} \
__r; \
})
Expand All @@ -236,6 +241,8 @@ static int resolve_btf_func_ret_idx(struct btf *btf, const char *func)
int r = resolve_btf_field_off(btf, #struct, #field); \
if (r >= 0) \
__r = 0; \
else \
verbose("fill field offset (%s, %s): %d\n", #struct, #field, r); \
obj->rodata->off__##struct##__##field##__ = r; \
__r; \
})
Expand Down Expand Up @@ -659,31 +666,42 @@ int ebpf_event_ctx__new(struct ebpf_event_ctx **ctx, ebpf_event_handler_fn cb, u
/* EventProbe_bpf__open doesn't report errors, hard to find something
* that fits perfect here
*/
verbose("EventProbe_bpf__open: %d\n", err);
err = -ENOENT;
goto out_destroy_probe;
}

probe->rodata->consumer_pid = getpid();

err = probe_fill_relos(btf, probe);
if (err != 0)
if (err != 0) {
verbose("probe_fill_relos: %d\n", err);
goto out_destroy_probe;
}

err = probe_resize_maps(probe);
if (err != 0)
if (err != 0) {
verbose("probe_resize_maps: %d\n", err);
goto out_destroy_probe;
}

err = probe_set_autoload(btf, probe, features);
if (err != 0)
if (err != 0) {
verbose("probe_set_autoload: %d\n", err);
goto out_destroy_probe;
}

err = EventProbe_bpf__load(probe);
if (err != 0)
if (err != 0) {
verbose("EventProbe_bpf__load: %d\n", err);
goto out_destroy_probe;
}

err = EventProbe_bpf__attach(probe);
if (err != 0)
if (err != 0) {
verbose("EventProbe_bpf__attach: %d\n", err);
goto out_destroy_probe;
}

if (!ctx)
goto out_destroy_probe;
Expand Down
12 changes: 10 additions & 2 deletions testing/kernel_builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from debian:bullseye

RUN dpkg --add-architecture arm64
RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list
RUN apt-get -y update
RUN apt-get -y install \
git gcc make libssl-dev bison flex bc libelf-dev python3 \
gcc-aarch64-linux-gnu curl xz-utils dwarves
gcc-aarch64-linux-gnu curl xz-utils dwarves \
cmake zlib1g libdw1 libdw-dev

RUN git clone https://git.kernel.org/pub/scm/devel/pahole/pahole.git /pahole
WORKDIR /pahole
RUN git submodule update --init --recursive
RUN mkdir /pahole/build
WORKDIR /pahole/build
RUN cmake -DBUILD_SHARED_LIBS=OFF ..
RUN make install

WORKDIR /work
CMD ./build.sh
2 changes: 0 additions & 2 deletions testing/kernel_builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ readonly BUILD_ARCHES=(
# releases from each LTS series (e.g. 5.10, 5.15)
readonly BUILD_VERSIONS=(
"5.10.16" # Oldest we support
"5.10.50"
"5.10.130"
"5.11"
"5.12"
"5.13"
"5.14"
"5.15"
"5.15.50"
"5.15.133"
"5.16"
"5.17"
Expand Down
10 changes: 5 additions & 5 deletions testing/kernel_builder/config.custom
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_DEBUG_INFO=y

# Enable BTF
CONFIG_DEBUG_INFO_DWARF4=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_BTF=y
CONFIG_DEBUG_INFO_REDUCED=n

# Enable /sys/kernel/debug/tracing/events/syscalls
CONFIG_FTRACE_SYSCALLS=y
CONFIG_DEBUG_INFO_DWARF4=y

# Enable securityfs
CONFIG_SECURITYFS=y
Expand Down Expand Up @@ -46,6 +43,9 @@ CONFIG_CGROUP_NET_CLASSID=y
CONFIG_FTRACE=y
CONFIG_FUNCTION_TRACER=y
CONFIG_KPROBES=y
CONFIG_KPROBES_ON_FTRACE=y
CONFIG_FTRACE_SYSCALLS=y
CONFIG_FPROBE=y

# Enable IPv6 (not on by default in aarch64 defconfig)
CONFIG_IPV6=y
Expand Down
28 changes: 14 additions & 14 deletions testing/testrunner/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
// This is a JSON type printed by the test binaries (not by EventsTrace), it's
// used all over the place, so define it here to save space
type TestPidInfo struct {
Tid int64 `json:"tid"`
Tgid int64 `json:"tgid"`
Ppid int64 `json:"ppid"`
Pgid int64 `json:"pgid"`
Sid int64 `json:"sid"`
Tid int64 `json:"tid"`
Tgid int64 `json:"tgid"`
Ppid int64 `json:"ppid"`
Pgid int64 `json:"pgid"`
Sid int64 `json:"sid"`
CapPermitted uint64 `json:"cap_permitted,string"`
CapEffective uint64 `json:"cap_effective,string"`
}
Expand All @@ -53,12 +53,12 @@ type PidInfo struct {
}

type CredInfo struct {
Ruid int64 `json:"ruid"`
Rgid int64 `json:"rgid"`
Euid int64 `json:"euid"`
Egid int64 `json:"egid"`
Suid int64 `json:"suid"`
Sgid int64 `json:"sgid"`
Ruid int64 `json:"ruid"`
Rgid int64 `json:"rgid"`
Euid int64 `json:"euid"`
Egid int64 `json:"egid"`
Suid int64 `json:"suid"`
Sgid int64 `json:"sgid"`
CapPermitted uint64 `json:"cap_permitted,string"`
CapEffective uint64 `json:"cap_effective,string"`
}
Expand All @@ -79,9 +79,9 @@ type NetInfo struct {
}

type ProcessForkEvent struct {
ParentPids PidInfo `json:"parent_pids"`
ChildPids PidInfo `json:"child_pids"`
Creds CredInfo `json:"creds"`
ParentPids PidInfo `json:"parent_pids"`
ChildPids PidInfo `json:"child_pids"`
Creds CredInfo `json:"creds"`
}

type ProcessExecEvent struct {
Expand Down

0 comments on commit 67ff56f

Please sign in to comment.