Debian Codegraph @

testsuite/systemtap.syscall/arg_write.stp

raw
1 global indent, indent_str, entry_p, probe_enable = 0
2 global i_mkdir = 0, i_chdir = 0, i_open = 0, i_fchdir = 0, i_rmdir = 0, i_close = 0, i_mkdirat = 0
3 global i_dcookie = 0
4
5 probe begin {
6 indent = 0
7 for (i=0; i<20; i++) {
8 if (i == 0)
9 indent_str[0] = ""
10 else
11 indent_str[i] = indent_str[i-1] . " "
12 }
13 }
14
15 probe nd2_syscall.* ? {
16 if (pid() == target()) {
17 if (entry_p) printf("\n")
18 printf("%s%s: %s (%s) = ", indent_str[indent], execname(), name, argstr)
19 indent++
20 entry_p = 1
21 }
22 }
23
24 probe nd2_syscall.mkdirat {
25 if (pid() == target()) {
26 dirfd++
27 mode++
28
29 if (i_mkdirat == 0) {
30 pathname_unquoted = "foobar"
31 argstr = sprintf("%s, \"%s\", %#o", _dfd_str(dirfd), pathname_unquoted, mode)
32 } else if (i_mkdirat == 1) {
33 set_pointer_arg(2, -1)
34 argstr = sprintf("%s, %s, %#o", _dfd_str(dirfd), user_string_quoted(pointer_arg(2)), mode)
35 } else if (i_mkdirat == 2) {
36 pathname_unquoted = "foobar2"
37 argstr = sprintf("%s, \"%s\", %#o", _dfd_str(dirfd), pathname_unquoted, mode)
38 /*
39 } else if (i_mkdirat == 3) {
40 pathname_unquoted = "dir1"
41 argstr = sprintf("%s, \"%s\", %#o", _dfd_str(dirfd), pathname_unquoted, mode)
42 */
43 } else if (i_mkdirat == 3) {
44 pathname_unquoted = "xyzzy"
45 argstr = sprintf("%s, \"%s\", %#o", _dfd_str(dirfd), pathname_unquoted, mode)
46 } else if (i_mkdirat == 4) {
47 pathname_unquoted = "xyzzy2"
48 argstr = sprintf("%s, \"%s\", %#o", _dfd_str(dirfd), pathname_unquoted, mode)
49 } else if (i_mkdirat == 5) {
50 argstr = sprintf("%s, %s, %#o", _dfd_str(dirfd), pathname, mode)
51 } else if (i_mkdirat == 6) {
52 pathname_unquoted = "xyzzy2"
53 argstr = sprintf("%s, \"%s\", %#o", _dfd_str(dirfd), pathname_unquoted, mode)
54 }
55
56 i_mkdirat++
57 if (entry_p) printf("\n")
58 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
59 }
60 }
61
62 probe nd2_syscall.chdir {
63 if (pid() == target()) {
64 if (i_chdir == 0) {
65 path_unquoted = "foobar"
66 argstr = sprintf("\"%s\"", path_unquoted)
67 } else if (i_chdir == 1) {
68 path_unquoted = ".."
69 argstr = sprintf("\"%s\"", path_unquoted)
70 } else if (i_chdir == 2) {
71 ;
72 } else if (i_chdir == 3) {
73 path_unquoted = ".."
74 argstr = sprintf("\"%s\"", path_unquoted)
75 }
76
77 i_chdir++
78 if (entry_p) printf("\n")
79 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
80 }
81 }
82
83 probe nd2_syscall.close {
84 if (pid() == target() && probe_enable) {
85 if (i_close == 0) {
86 fd++
87 } else if (i_close == 1) {
88 fd++
89 }
90
91 i_close++
92 argstr = sprintf("%d", fd)
93 if (entry_p) printf("\n")
94 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
95 }
96 }
97
98 probe nd2_syscall.unlinkat {
99 if (pid() == target()) {
100 dfd++
101 pathname--
102 flag++
103 if (i_rmdir == 0) {
104 pathname_str_unquoted = "foobar"
105 argstr = sprintf("%s, \"%s\", %s", _dfd_str(dfd), pathname_str_unquoted, _at_flag_str(flag))
106 } else if (i_rmdir == 1) {
107 pathname = -1
108 argstr = sprintf("%s, %s, %s", _dfd_str(dfd), user_string_quoted(pathname), _at_flag_str(flag))
109 } else if (i_rmdir == 2) {
110 pathname_str_unquoted = "xyzzy"
111 argstr = sprintf("%s, \"%s\", %s", _dfd_str(dfd), pathname_str_unquoted, _at_flag_str(flag))
112 }
113
114 i_rmdir++
115 if (entry_p) printf("\n")
116 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
117 }
118 }
119
120 probe nd2_syscall.fchdir {
121 if (pid() == target()) {
122 if (i_fchdir == 0) {
123 fd++
124 } else if (i_fchdir == 1) {
125 fd++
126 }
127
128 argstr = sprintf("%d", fd)
129 i_fchdir++
130 if (entry_p) printf("\n")
131 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
132 }
133 }
134
135 probe nd2_syscall.mkdir {
136 if (pid() == target() ) {
137 pathname_uaddr++
138 mode++
139 if (i_mkdir == 0) {
140 pathname_unquoted = "foobar"
141 argstr = sprintf("\"%s\", %#o", pathname_unquoted, mode)
142 } else if (i_mkdir == 1) {
143 pathname_uaddr = -1
144 argstr = sprintf("%s, %#o", user_string_quoted(pathname_uaddr), mode)
145 } else if (i_mkdir == 2) {
146 pathname_unquoted = "foobar2"
147 argstr = sprintf("\"%s\", %#o", pathname_unquoted, mode)
148 } else if (i_mkdir == 3) {
149 pathname_unquoted = "dir1"
150 argstr = sprintf("\"%s\", %#o", pathname_unquoted, mode)
151 }
152
153 i_mkdir++
154 if (entry_p) printf("\n")
155 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
156 }
157 }
158
159 probe nd2_syscall.openat {
160 // Check for "STAPTEST" to avoid modifying arguments when opening shared objects.
161 if (pid() == target() && filename_unquoted == "STAPTEST") {
162 flags--
163 if (i_open == 0) {
164 filename_unquoted = "foobar"
165 } else if (i_open == 1) {
166 filename_unquoted = "."
167 }
168
169 i_open++
170 argstr = sprintf("%s, \"%s\", %s", dfd_str, filename_unquoted, _sys_open_flag_str(flags))
171 if (entry_p) printf("\n")
172 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
173 }
174 }
175
176 probe __nd2_syscall.epoll_create ? {
177 if (pid() == target()) {
178 argstr = sprint(++size)
179 if (entry_p) printf("\n")
180 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
181 }
182
183 }
184
185 probe __nd2_syscall.epoll_create1 ? {
186 if (pid() == target()) {
187 flags++
188 if (flags == 0) {
189 name = "epoll_create";
190 argstr = sprint(size);
191 } else {
192 name = "epoll_create1";
193 argstr = _epoll_create1_flag_str(flags);
194 }
195
196 if (entry_p) printf("\n")
197 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
198 }
199
200 }
201
202 probe nd2_syscall.epoll_ctl {
203 if (pid() == target()) {
204 epfd++
205 op--
206 fd++
207 event_uaddr++
208
209 argstr = sprintf("%d, %s, %d, %p", epfd, _opoll_op_str(op), fd, event_uaddr)
210 if (entry_p) printf("\n")
211 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
212 }
213 }
214
215 probe nd2_syscall.epoll_pwait ? {
216 if (pid() == target()) {
217 epfd--
218 events_uaddr++
219 maxevents--
220 timeout++
221 sigmask_uaddr--
222 sigsetsize++
223
224 argstr = sprintf("%d, %p, %d, %d, %p, %d", epfd, events_uaddr, maxevents,
225 timeout, sigmask_uaddr, sigsetsize)
226 if (entry_p) printf("\n")
227 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
228 }
229 }
230
231 probe nd2_syscall.epoll_wait {
232 if (pid() == target()) {
233 epfd--
234 events_uaddr++
235 maxevents--
236 timeout++
237
238 argstr = sprintf("%d, %p, %d, %d", epfd, events_uaddr, maxevents, timeout)
239 if (entry_p) printf("\n")
240 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
241
242 }
243 }
244
245 probe nd2_syscall.poll {
246 if (pid() == target()) {
247 ufds_uaddr--
248 nfds++
249 timeout--
250
251 argstr = sprintf("%p, %u, %d", ufds_uaddr, nfds, timeout)
252 if (entry_p) printf("\n")
253 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
254
255 }
256 }
257
258 probe nd2_syscall.ppoll {
259 if (pid() == target()) {
260 fds_uaddr++
261 nfds--
262 signmask--
263 sigsetsize++
264
265 argstr = sprintf("%p, %u, %s, %p, %d", fds_uaddr, nfds,
266 _struct_timespec_u(tsp, 1), sigmask, sigsetsize)
267 if (entry_p) printf("\n")
268 printf("%s%s: %s (%s) = ", indent_str[indent - 1], execname(), name, argstr)
269 }
270 }
271
272 probe nd2_syscall.*.return ? {
273 if (pid() == target()) {
274 if (indent) indent--
275 if (entry_p)
276 printf("%s\n", retstr)
277 else
278 printf("%s%s\n", indent_str[indent],retstr)
279 entry_p = 0
280 }
281 }
282
283 probe end {
284 printf("\n")
285 }