3 # Copyright (C) 2010 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # ` = 0' is there to prevent: WARNING: never-assigned global variable
20 # `opt_f' is a boolean for both -f and -ff.
22 # Modify the [pid %5d] output to [%d] for the -ff postprocessor.
28 /* systemtap bug? /usr/share/doc/systemtap-1.3/SystemTap_Beginners_Guide.pdf
29 Example 3.19 reads or writes? */
35 tid = opt_child > 0 ? opt_child : target ()
40 function heading (tid:long)
43 return printf ("[%d]", tid)
45 foreach (tidi in trace limit 2)
50 /* strace really calls TID a "pid". */
51 return printf ("[pid %5d] ", tid)
68 if (nest[last_tid] && funcname[last_tid] != "")
70 printf (") = ? <tracer terminated>")
77 printf ("<... %s resumed> ) = ? <tracer terminated>",
78 funcname[tid] != "" ? funcname[tid] : "?");
83 /* BUG: sleeping function called from invalid context at kernel/mutex.c:94 */
84 %{static DEFINE_MUTEX (tracer_mutex);%}
87 if (in_atomic () || irqs_disabled())
92 mutex_lock (&tracer_mutex);
97 mutex_unlock (&tracer_mutex);
100 # systamtap bug? on void function value use no warning is given.
102 function lock:long ()
113 #probe kprocess.start
121 probe kprocess.create
123 if (opt_f && trace[tid ()] != 0)
125 /* systemtap bug? Why `new_pid' is provided but `new_tid' is not? */
126 new_tid = task_tid (task)
130 printf ("Process %d attached", new_tid);
136 probe kprocess.release
138 /* systemtap bug? Why `pid' is provided but `tid' is not? */
139 /* systemtap bug? Why `[pt]id' is not called `released_[pt]id' to keep the
140 naming in sync with kprocess.create? */
141 tid = task_tid (task)
147 /* FIXME: Do not assume "exit" for the nested calls. */
148 printf ("<... %s resumed> = ?",
149 funcname[tid] != "" ? funcname[tid] : "exit")
157 printf ("Process %d detached", tid);
164 if (trace[tid ()] != 0 && lock ())
166 /* Why is mmap() called recursively twice? */
167 if (nest[last_tid] && funcname[last_tid] != "")
169 if (last_tid != tid ())
174 print (" <unfinished ...>\n")
178 print (" <unfinished ...>")
183 funcname[tid ()] = name
186 printf ("%s(%s",name, argstr)
190 probe syscall.*.return
192 if (trace[tid ()] != 0 && lock ())
194 if (last_tid != tid () && nest[last_tid] && funcname[last_tid] != "")
199 print (" <unfinished ...>\n")
201 if (last_tid != tid ())
205 printf ("<... %s resumed> ", name);
207 if (last_tid == tid () && funcname[last_tid] == "")
210 printf ("<... %s resumed> ", name);
213 printf (") = %s", retstr)
217 delete funcname[tid ()]