fixes
authorJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 24 Dec 2010 23:14:59 +0000 (00:14 +0100)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 24 Dec 2010 23:14:59 +0000 (00:14 +0100)
src/staptrace.c
src/staptrace.stp

index 74282fc..2f6f328 100644 (file)
@@ -126,7 +126,7 @@ main (int argc, char **argv)
        len += 3 + strlen (argv[i]) * 4;
 
       d = *argp++ = xmalloc (len);
-      d = stpcpy (d, "exec");
+      d = stpcpy (d, "(exec");
       for (i = optind; i < argc; i++)
        {
          *d++ = ' ';
@@ -145,6 +145,7 @@ main (int argc, char **argv)
              }
          *d++ = '\'';
        }
+      *d++ = ')';
       *d++ = 0;
     }
   *argp++ = opt_Z;
index bcb9b3f..4b61712 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-global opt_f
-global opt_q
+# ` = 0' is there to prevent: WARNING: never-assigned global variable
+global opt_f = 0
+global opt_q = 0
+
+/* systemtap bug?  /usr/share/doc/systemtap-1.3/SystemTap_Beginners_Guide.pdf
+   Example 3.19 reads or writes?  */
 
 global trace
-# FIXME: count()?
-global trace_count
 global last_tid
 probe begin
 {
   trace[target ()] = 1
-  trace_count = 1
   last_tid = target ()
 }
 
 function heading:string ()
 {
-  if (trace_count > 1)
+  foreach (tidi in trace limit 2)
+    tid_count++
+
+  if (tid_count > 1)
     {
       /* strace really calls TID a "pid".  */
       return sprintf ("[pid %5d] ", tid ())
@@ -75,12 +79,10 @@ function unlock () { dummy = 1; }
 #probe kprocess.start
 #{
 #  trace[pid ()] = 1
-#  trace_count++
 #}
 #probe kprocess.exit
 #{
 #  trace[pid ()] = 0
-#  trace_count--
 #}
 probe kprocess.create
 {
@@ -89,7 +91,6 @@ probe kprocess.create
       /* systemtap bug?  Why `new_pid' is provided but `new_tid' is not?  */
       new_tid = task_tid (task)
       trace[new_tid] = 1
-      trace_count++
       if (!opt_q)
        printf ("Process %d attached\n", new_tid);
     }
@@ -121,7 +122,6 @@ probe kprocess.release
          unlock ()
        }
       delete trace[tid]
-      trace_count--
       if (!opt_q)
        printf ("Process %d detached\n", tid);
     }