Bug 12508

Summary: event-counting command line option
Product: systemtap Reporter: Frank Ch. Eigler <fche>
Component: translatorAssignee: Lukas Berk <lberk>
Status: RESOLVED FIXED    
Severity: normal CC: lberk
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Frank Ch. Eigler 2011-02-23 12:58:01 UTC
People seem to find useful the basic "perf -e EVENT -e EVENT2 CMD" type of
invocation, where the tool reports overall event counts.  We could support
such a shortcut too, for example:

    stap -E perf.sw_clock -E 'syscall.*' -c CMD

to be rewritten into something close to

    stap -e 'global c; probe perf.sw_clock,syscall.* { c[pn()]<<<1 }'
         -c CMD

except perhaps the automatic global-c printing loop could restrict itself
to @count() only.
Comment 1 Frank Ch. Eigler 2011-04-27 23:55:14 UTC
Note that this may be achievable with no translator code changes,
but rather just a systemtap script that's parametrized with the
probe points, ie.

% stap eventcount.stp perf.sw_clock 'syscall.*'
Comment 2 Lukas Berk 2011-05-03 19:25:22 UTC
commit: eb521ae66706271bd0687db92fcb346cff3fee90

An eventcount.stp script has now been added which allows for event
counting in the format of 'stap eventcount.stp syscall.* process.end ...'
with a printout of tid's event and count.

NEWS - news blurb
testsuite/systemtap.examples/general/eventcount.meta - meta file
testsuite/systemtap.examples/general/eventcount.stp - script itself