Skip to content

Commit fc55b7e

Browse files
committed
Add passing ptr_to_char_array test for strings
1 parent c143739 commit fc55b7e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
copp: str(16) # type: ignore [valid-type]
12+
13+
14+
@bpf
15+
@section("tracepoint/syscalls/sys_enter_clone")
16+
def hello(ctx: c_void_p) -> c_int64:
17+
dataobj = data_t()
18+
comm(dataobj.comm)
19+
strobj = dataobj.comm
20+
dataobj.copp = strobj
21+
print(f"clone called by comm {dataobj.copp}")
22+
return 0
23+
24+
25+
@bpf
26+
@bpfglobal
27+
def LICENSE() -> str:
28+
return "GPL"

0 commit comments

Comments
 (0)