mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
change c-file test structure
This commit is contained in:
@ -1,19 +1,22 @@
|
||||
BPF_CLANG := clang
|
||||
CFLAGS := -O0 -emit-llvm -target bpf -c
|
||||
CFLAGS := -emit-llvm -target bpf -c
|
||||
|
||||
SRC := $(wildcard *.bpf.c)
|
||||
LL := $(SRC:.bpf.c=.bpf.ll)
|
||||
OBJ := $(SRC:.bpf.c=.bpf.o)
|
||||
|
||||
LL0 := $(SRC:.bpf.c=.bpf.o0.ll)
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(LL) $(OBJ)
|
||||
all: $(LL) $(OBJ) $(LL0)
|
||||
|
||||
%.bpf.o: %.bpf.c
|
||||
$(BPF_CLANG) -O2 -g -target bpf -c $< -o $@
|
||||
|
||||
%.bpf.ll: %.bpf.c
|
||||
$(BPF_CLANG) $(CFLAGS) -g -S $< -o $@
|
||||
$(BPF_CLANG) $(CFLAGS) -O2 -g -S $< -o $@
|
||||
|
||||
%.bpf.o0.ll: %.bpf.c
|
||||
$(BPF_CLANG) $(CFLAGS) -O0 -g -S $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(LL) $(OBJ)
|
||||
rm -f $(LL) $(OBJ) $(LL0)
|
||||
|
||||
15
tests/c-form/requests.bpf.c
Normal file
15
tests/c-form/requests.bpf.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "vmlinux.h"
|
||||
#include <bpf/bpf_helpers.h>
|
||||
#include <bpf/bpf_tracing.h>
|
||||
|
||||
char LICENSE[] SEC("license") = "GPL";
|
||||
|
||||
SEC("kprobe/blk_mq_start_request")
|
||||
int example(struct pt_regs *ctx)
|
||||
{
|
||||
struct request *req = (struct request *)(ctx->di);
|
||||
u32 data_len = req->__data_len;
|
||||
bpf_printk("data length %u\n", data_len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user