Skip to content

Commit c143739

Browse files
committed
Add passing test struct_field_to_var_str for strings
1 parent 009b11a commit c143739

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pythonbpf import bpf, struct, section, bpfglobal
2+
from pythonbpf.helper import comm
3+
4+
from ctypes import c_void_p, c_int64
5+
6+
7+
@bpf
8+
@struct
9+
class data_t:
10+
comm: str(16) # type: ignore [valid-type]
11+
12+
13+
@bpf
14+
@section("tracepoint/syscalls/sys_enter_clone")
15+
def hello(ctx: c_void_p) -> c_int64:
16+
dataobj = data_t()
17+
comm(dataobj.comm)
18+
strobj = dataobj.comm
19+
print(f"clone called by comm {strobj}")
20+
return 0
21+
22+
23+
@bpf
24+
@bpfglobal
25+
def LICENSE() -> str:
26+
return "GPL"

0 commit comments

Comments
 (0)