Debian Codegraph @

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

raw
1 # Why probe syscall.socket.return? The test executable opens several
2 # directories, pipes, and a socket. The socket is the last thing to be
3 # opened, so in syscall.socket.return everything should be set up.
4
5 probe syscall.socket.return
6 {
7 if (pid() != target()) next
8
9 task = task_current()
10
11 # Why are we looping through the first 15 file descriptors instead
12 # of looking for certain file descriptors? The test executable
13 # opens the files in a certain order. When run with systemtap,
14 # that order is preserved. However, when this is run as part of
15 # the testsuite, dejagnu opens several additional files. The
16 # number of these files varies on different systems, probably
17 # based on the dejagnu version.
18 #
19 # So, we can't be certain of where the files we are interested in
20 # are. That's why we try to print the paths of the first 15 file
21 # descriptors.
22 for (i = 0; i < 15; ++i)
23 {
24 try {
25 file = task_fd_lookup(task, i)
26 printf("%d: %s\n", i, fullpath_struct_file(task, file))
27 } catch {
28 printf("%d: fail reading file\n", i)
29 }
30 }
31 }