Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/kretprobe-vars.stp

raw
1 # Check that implicitly-saved $target variables have the same
2 # value as those manually saved on entry.
3
4
5 # saved individual parameters
6 global read_file
7 global read_file_mode
8 global read_buf
9 global read_count
10 global read_pos
11
12 # the saved string $$parms
13 global read_parms
14
15 # error count
16 global errors
17
18 probe begin
19 {
20 println("systemtap starting probe")
21 }
22
23 function check_num(name, ent, ret)
24 {
25 if (ent != ret) {
26 printf("%s mismatch, entry:%#x vs. return:%#x\n", name, ent, ret)
27 errors++
28 }
29 }
30 function check_str(name, ent, ret)
31 {
32 if (ent != ret) {
33 printf("%s mismatch, entry:'%s' vs. return:'%s'\n", name, ent, ret)
34 errors++
35 }
36 }
37
38 probe kernel.function("vfs_read").call
39 {
40 if (tid() != target())
41 next
42
43 read_file = $file
44 read_file_mode = $file->f_mode
45 read_buf = $buf
46 read_count = $count
47 read_pos = $pos
48
49 read_parms = $$parms
50 }
51
52 probe kernel.function("vfs_read").return
53 {
54 if (tid() != target())
55 next
56
57 println("systemtap ending probe")
58
59 check_num("file", read_file, $file)
60 check_num("file->f_mode", read_file_mode, $file->f_mode)
61 check_num("buf", read_buf, $buf)
62 check_num("count", read_count, $count)
63 check_num("pos", read_pos, $pos)
64
65 check_str("parms", read_parms, $$parms)
66
67 if (!errors)
68 println("systemtap test success")
69 exit()
70 }