Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tracepoint_raw attach support #38

Merged
merged 3 commits into from
Feb 16, 2025

Conversation

Mr-Pine
Copy link
Contributor

@Mr-Pine Mr-Pine commented Feb 15, 2025

This adds support for attaching tracepoint_raw functions:

@BPFFunction(
        headerTemplate = "int BPF_PROG($name, struct pt_regs *regs, unsigned long number)",
        lastStatement = "return 0;",
        section = "raw_tracepoint/sys_enter",
        autoAttach = true
)
public void syscall_counter(Ptr<PtDefinitions.pt_regs> regs, @Unsigned long number) {
    syscalls.set(syscalls.get() + 1);
}
try (var program = BPFProgram.load(RawTracepoints.class)) {
    program.rawTracepointAttach("syscall_counter", "sys_enter");
}

@parttimenerd
Copy link
Owner

Nice work. Could you add an example to bpf-samples?

@Mr-Pine
Copy link
Contributor Author

Mr-Pine commented Feb 16, 2025

I added a syscall counter to the samples

@parttimenerd parttimenerd merged commit 33bec9e into parttimenerd:main Feb 16, 2025
1 of 2 checks passed
@Mr-Pine Mr-Pine deleted the raw-tracepoint branch February 16, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants