lcc/pylcc/guide/hello.py (11 lines of code) (raw):

# -*- coding: utf-8 -*- # cython:language_level=2 """ ------------------------------------------------- File Name: hello.py Description : Author : liaozhaoyan date: 2021/11/3 ------------------------------------------------- Change Activity: 2021/11/3: ------------------------------------------------- """ __author__ = 'liaozhaoyan' import time from pylcc.lbcBase import ClbcBase bpfPog = r""" #include "lbc.h" SEC("kprobe/wake_up_new_task") int j_wake_up_new_task(struct pt_regs *ctx) { struct task_struct* parent = (struct task_struct *)PT_REGS_PARM1(ctx); bpf_printk("hello lcc, parent: %d\n", _(parent->tgid)); return 0; } char _license[] SEC("license") = "GPL"; """ class Chello(ClbcBase): def __init__(self): super(Chello, self).__init__("hello", bpf_str=bpfPog) self.waitInterrupt() if __name__ == "__main__": hello = Chello() pass