From: Jan Kratochvil Date: Fri, 24 Dec 2010 23:14:59 +0000 (+0100) Subject: fixes X-Git-Url: https://git.jankratochvil.net/?p=staptrace.git;a=commitdiff_plain;h=da088df8ae44d008a8609e365b1951c2b8bf00de fixes --- diff --git a/src/staptrace.c b/src/staptrace.c index 74282fc..2f6f328 100644 --- a/src/staptrace.c +++ b/src/staptrace.c @@ -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; diff --git a/src/staptrace.stp b/src/staptrace.stp index bcb9b3f..4b61712 100755 --- a/src/staptrace.stp +++ b/src/staptrace.stp @@ -15,23 +15,27 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -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); }