mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
add debug info module
This commit is contained in:
@ -2,38 +2,39 @@
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
#define u64 unsigned long long
|
||||
#define u32 unsigned int
|
||||
|
||||
// Define the map
|
||||
struct {
|
||||
__uint(type, BPF_MAP_TYPE_HASH);
|
||||
__type(key, u64);
|
||||
__type(value, u64);
|
||||
__type(value, u32);
|
||||
__uint(max_entries, 4);
|
||||
} last SEC(".maps");
|
||||
|
||||
// Handler for syscall entry
|
||||
SEC("tracepoint/syscalls/sys_enter_execve")
|
||||
int hello(void *ctx) {
|
||||
bpf_printk("entered");
|
||||
bpf_printk("multi constant support");
|
||||
return 0;
|
||||
}
|
||||
// // Handler for syscall entry
|
||||
// SEC("tracepoint/syscalls/sys_enter_execve")
|
||||
// int hello(void *ctx) {
|
||||
// bpf_printk("entered");
|
||||
// bpf_printk("multi constant support");
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// Handler for syscall exit
|
||||
SEC("tracepoint/syscalls/sys_exit_execve")
|
||||
long hello_again(void *ctx) {
|
||||
bpf_printk("exited");
|
||||
// // Handler for syscall exit
|
||||
// SEC("tracepoint/syscalls/sys_exit_execve")
|
||||
// long hello_again(void *ctx) {
|
||||
// bpf_printk("exited");
|
||||
|
||||
// Create a key for map lookup
|
||||
u64 key = 0;
|
||||
// // Create a key for map lookup
|
||||
// u64 key = 0;
|
||||
|
||||
// Simple lookup without conditionals
|
||||
u64 *tsp = bpf_map_lookup_elem(&last, &key);
|
||||
// // Simple lookup without conditionals
|
||||
// u64 *tsp = bpf_map_lookup_elem(&last, &key);
|
||||
|
||||
// Get current timestamp
|
||||
u64 ts = bpf_ktime_get_ns();
|
||||
// // Get current timestamp
|
||||
// u64 ts = bpf_ktime_get_ns();
|
||||
|
||||
return 0;
|
||||
}
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
char LICENSE[] SEC("license") = "GPL";
|
||||
|
||||
Reference in New Issue
Block a user