You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to build the examples using cargo build --release, the following errors arise in building tracecon:
error: failed to run custom build command for `tracecon v0.1.0 (/home/tanya/workspace/libbpf-bootstrap/examples/rust/tracecon)`
Caused by:
process didn't exit successfully: `/home/tanya/workspace/libbpf-bootstrap/examples/rust/target/release/build/tracecon-cbe3e5b4ae219d9a/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at tracecon/build.rs:22:10:
bpf compilation failed: Build("Failed to compile obj=/tmp/.tmpevJHx5/tracecon.o with status=exit status: 1
stdout=
stderr=
./src/bpf/tracecon.bpf.c:78:5: error: incomplete definition of type 'struct user_pt_regs'
78 | int BPF_KPROBE(getaddrinfo_enter, const char *hostname, const char *service,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79 | const struct addrinfo *hints, struct addrinfo **res)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:469:20: note: expanded from macro 'BPF_KPROBE'
469 | return ____##name(___bpf_kprobe_args(args)); \\
| ^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:449:41: note: expanded from macro '___bpf_kprobe_args'
449 | #define ___bpf_kprobe_args(args...) ___bpf_apply(___bpf_kprobe_args, ___bpf_narg(args))(args)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_helpers.h:184:29: note: expanded from macro '___bpf_apply'
184 | #define ___bpf_apply(fn, n) ___bpf_concat(fn, n)
| ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:445:41: note: expanded from macro '___bpf_kprobe_args2'
445 | #define ___bpf_kprobe_args2(x, args...) ___bpf_kprobe_args1(args), (void *)PT_REGS_PARM2(ctx)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:444:72: note: expanded from macro '___bpf_kprobe_args1'
444 | #define ___bpf_kprobe_args1(x) ___bpf_kprobe_args0(), (void *)PT_REGS_PARM1(ctx)
| ^~~~~~~~~~~~~~~~~~
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:272:44: note: expanded from macro 'PT_REGS_PARM1'
272 | #define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG)
| ~~~~~~~~~~~~~~~~~^
./src/bpf/tracecon.bpf.c:78:5: note: forward declaration of 'struct user_pt_regs'
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:469:20: note: expanded from macro 'BPF_KPROBE'
469 | return ____##name(___bpf_kprobe_args(args)); \\
| ^
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:449:41: note: expanded from macro '___bpf_kprobe_args'
449 | #define ___bpf_kprobe_args(args...) ___bpf_apply(___bpf_kprobe_args, ___bpf_narg(args))(args)
| ^
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_helpers.h:184:29: note: expanded from macro '___bpf_apply'
184 | #define ___bpf_apply(fn, n) ___bpf_concat(fn, n)
| ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:444:72: note: expanded from macro '___bpf_kprobe_args1'
444 | #define ___bpf_kprobe_args1(x) ___bpf_kprobe_args0(), (void *)PT_REGS_PARM1(ctx)
| ^
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:272:27: note: expanded from macro 'PT_REGS_PARM1'
272 | #define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG)
| ^
/tmp/.tmp44XFnJ/bpf/src/bpf/bpf_tracing.h:168:42: note: expanded from macro '__PT_REGS_CAST'
168 | #define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x))
| ^
The above error repeats 9 times.
The source of the error is the missing struct user_pt_regs in the examples/rust/tracecon/src/bpf/vmlinux.h
Placing the following code in the file seems to solve the issue:
/*
* User structures for general purpose, floating point and debug registers.
* Taken from /usr/include/asm/ptrace.h
*/
struct user_pt_regs {
__u64 regs[31];
__u64 sp;
__u64 pc;
__u64 pstate;
};
As noted, the struct is borrowed from the relevant ptrace header for arm64.
The text was updated successfully, but these errors were encountered:
The example need to include the correct vmlinux.h header for the current
architecture if they aim to build on arches other than x86. Adjust the
logic accordingly.
Fixes: libbpf#247
danielocfb
pushed a commit
to danielocfb/libbpf-bootstrap
that referenced
this issue
Jan 12, 2024
The example need to include the correct vmlinux.h header for the current
architecture if they aim to build on arches other than x86. Adjust the
logic accordingly.
Fixes: libbpf#247
Signed-off-by: Daniel Müller <[email protected]>
When trying to build the examples using
cargo build --release
, the following errors arise in building tracecon:The above error repeats 9 times.
The source of the error is the missing
struct user_pt_regs
in theexamples/rust/tracecon/src/bpf/vmlinux.h
Placing the following code in the file seems to solve the issue:
As noted, the struct is borrowed from the relevant ptrace header for arm64.
The text was updated successfully, but these errors were encountered: