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);
109 #probe kprocess.start
117 probe kprocess.create
119 if (opt_f && trace[tid ()] != 0)
121 new_tid = task_tid (task)
125 printf ("Process %d attached", new_tid);
131 probe kprocess.release
133 tid = task_tid (task)
139 /* FIXME: Do not assume "exit" for the nested calls. */
140 printf ("<... %s resumed> = ?",
141 funcname[tid] != "" ? funcname[tid] : "exit")
149 printf ("Process %d detached", tid);
156 if (trace[tid ()] != 0 && lock ())
158 /* Why is mmap() called recursively twice? */
159 if (nest[last_tid] && funcname[last_tid] != "")
161 if (last_tid != tid ())
166 print (" <unfinished ...>\n")
170 print (" <unfinished ...>")
175 funcname[tid ()] = name
178 printf ("%s(%s",name, argstr)
182 probe syscall.*.return
184 if (trace[tid ()] != 0 && lock ())
186 if (last_tid != tid () && nest[last_tid] && funcname[last_tid] != "")
191 print (" <unfinished ...>\n")
193 if (last_tid != tid ())
197 printf ("<... %s resumed> ", name);
199 if (last_tid == tid () && funcname[last_tid] == "")
202 printf ("<... %s resumed> ", name);
205 printf (") = %s", retstr)
209 delete funcname[tid ()]