Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/system_func.stp

raw
1 #! stap
2
3 # test the system() function
4
5 global saw_echo, did_cat
6
7 %(runtime == "kernel" %?
8 probe kernel.function("do_sys_open")
9 %:
10 # The dyninst runtime doesn't have kernel.function probes. Instead,
11 # we'll just use a begin probe to run system().
12 probe begin
13 %)
14 {
15 if (!saw_echo) {
16 # very inefficient. Testing only. DO NOT DO THIS
17 msg="echo do_sys_open"
18 system(msg)
19 saw_echo = 1
20 }
21 }
22
23 probe timer.ms(100) {
24 # should fail
25 if (!did_cat) {
26 system("cat __xyzzy123ABC__")
27 did_cat = 1
28 }
29 }
30
31 probe timer.ms(150) {
32 if (saw_echo && did_cat)
33 exit()
34 }
35
36 probe begin {
37 # should succeed
38 system("whoami")
39 }
40
41 probe end {
42 # should succeed
43 system("echo DONE")
44 }