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.
32 tid = opt_child > 0 ? opt_child : target ()
37 function heading (tid:long)
40 return printf ("[%d]", tid)
42 foreach (tidi in trace limit 2)
47 /* strace really calls TID a "pid". */
48 return printf ("[pid %5d] ", tid)
65 if (nest[last_tid] && funcname[last_tid] != "")
67 printf (") = ? <tracer terminated>")
74 printf ("<... %s resumed> ) = ? <tracer terminated>",
75 funcname[tid] != "" ? funcname[tid] : "?");
80 /* BUG: sleeping function called from invalid context at kernel/mutex.c:94 */
81 %{static DEFINE_MUTEX (tracer_mutex);%}
84 if (in_atomic () || irqs_disabled())
89 mutex_lock (&tracer_mutex);
94 mutex_unlock (&tracer_mutex);
97 # systamtap bug? on void function value use no warning is given.
110 #probe kprocess.start
118 probe kprocess.create
120 if (opt_f && trace[tid ()] != 0)
122 new_tid = task_tid (task)
126 printf ("Process %d attached", new_tid);
132 probe kprocess.release
134 tid = task_tid (task)
140 /* FIXME: Do not assume "exit" for the nested calls. */
141 printf ("<... %s resumed> = ?",
142 funcname[tid] != "" ? funcname[tid] : "exit")
150 printf ("Process %d detached", tid);
157 if (trace[tid ()] != 0 && lock ())
159 /* Why is mmap() called recursively twice? */
160 if (nest[last_tid] && funcname[last_tid] != "")
162 if (last_tid != tid ())
167 print (" <unfinished ...>\n")
171 print (" <unfinished ...>")
176 funcname[tid ()] = name
179 printf ("%s(%s",name, argstr)
183 probe syscall.*.return
185 if (trace[tid ()] != 0 && lock ())
187 if (last_tid != tid () && nest[last_tid] && funcname[last_tid] != "")
192 print (" <unfinished ...>\n")
194 if (last_tid != tid ())
198 printf ("<... %s resumed> ", name);
200 if (last_tid == tid () && funcname[last_tid] == "")
203 printf ("<... %s resumed> ", name);
206 printf (") = %s", retstr)
210 delete funcname[tid ()]