Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.bpf/bpf_tests/string3.stp

raw
1 // stapbpf string manipulation -- store string in global from kernel space
2 // XXX: the 'locking' scheme here is kind of dumb but it seems to work
3
4 global counter = 0
5 global var
6 global tab1
7 global tab2
8
9 @define test_print
10 %(
11 /* PR23816 Test multiple %s in one printf */
12 printf("[")
13 printf("%s%s%s", "str0", var, tab1[17])
14 printf("%s]", tab2["key"])
15 %)
16
17 probe begin {
18 printf("BEGIN")
19 }
20
21 probe kernel.function("vfs_read") {
22 if (counter == 0) {
23 var = "str1"
24 tab1[17] = "str2"
25 tab2["key"] = "str3"
26 printf("probe0")
27 @test_print
28 counter = 1
29 }
30 }
31
32 probe kernel.function("vfs_read") {
33 if (counter == 1) {
34 printf("probe1")
35 @test_print
36 exit()
37 }
38 }
39
40 probe end {
41 printf("end")
42 @test_print
43 printf("END\n")
44 }