This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Event-Counting Script


Hey again,

Just as a follow up, it was requested that I supply an example with the
script along with some sample output.

In this example I'm building and running a multi-threaded C program
within eclipse, looking for the system calls and hotspot markers hit.

Running:

$stap eventcount.stp syscall.* hotspot.* -c 'eclipse'

At this point, building and running my program.

Output:

TID     EVENT: COUNT
 7442   syscall.execve: 4
 7442   syscall.rt_sigprocmask: 18
 7442   syscall.rt_sigaction: 11
 7442   syscall.rt_sigreturn: 2
 7442   syscall.exit_group: 1
 7442   syscall.wait4: 2
 7442   syscall.fork: 1
 7442   syscall.dup2: 1
 7442   syscall.fcntl: 3
 7442   syscall.lseek: 4
 7442   syscall.ioctl: 1
 7442   syscall.getrlimit: 2
 7442   syscall.getpgid: 1
 7442   syscall.getpgrp: 1
 7442   syscall.getppid: 1
 7442   syscall.getpid: 1
 7442   syscall.stat: 2
 7442   syscall.uname: 1
 7442   syscall.getegid: 1
 7442   syscall.geteuid: 1
 7442   syscall.getgid: 1
 7442   syscall.getuid: 1
 7442   syscall.munmap: 2
 7442   syscall.arch_prctl: 1
 7442   syscall.mprotect: 6
 7442   syscall.read: 8
 7442   syscall.fstat: 8
...
[abridged]
...
 7479   syscall.rt_sigprocmask: 3
 7479   syscall.gettid: 1
 7479   hotspot.thread_start: 1
 7480   hotspot.thread_start: 1
 7480   syscall.sched_getaffinity: 2
 7480   syscall.mprotect: 2
 7480   syscall.munmap: 1
 7480   syscall.mmap2: 2
 7480   syscall.futex: 4
 7480   syscall.rt_sigprocmask: 3
 7480   syscall.gettid: 1
 7481   hotspot.class_loaded: 176
 7481   syscall.mmap2: 8
 7481   syscall.close: 1
 7481   syscall.fcntl: 14
 7481   syscall.fstat: 8
 7481   syscall.open: 7
 7481   syscall.stat: 8
 7481   syscall.write: 11
 7481   syscall.mprotect: 75
 7481   syscall.read: 465
 7481   syscall.lseek: 384
 7481   syscall.futex: 45
 7481   hotspot.thread_start: 1
 7481   syscall.sched_getaffinity: 2
 7481   syscall.rt_sigprocmask: 3
 7481   syscall.gettid: 1


Hopefully this provides further insight on the possibilities and
capabilities of this script.

Thanks,

Lukas

* Lukas Berk <lberk@redhat.com> [2011-05-03 15:47]:
> Hey All,
> 
> I put together eventcount.stp (attached) to address PR12508 which allows
> for per event counting in the format of 'stap eventcount.stp
> syscall.exit syscall.exit_group process.end ...'.  The event count is
> reported with the corresponding thread id to support multi-threaded
> applications. You can find it in testsuite/systemtap.examples/general/.
> Please check it out!
> 
> Lukas Berk
> 
> 

> #! /usr/bin/env stap
> 
> global c
> 
> probe %($# == 0 || $# > 32 %? begin %: never %)
> {
>   printf("Please specify between 1 and 32 events to count.\n")
>   exit()
> }
> 
> //paramaterize up to 32 arguments
> probe %($# >= 1 %? $1 %: never %),
>       %($# >= 2 %? $2 %: never %),
>       %($# >= 3 %? $3 %: never %),
>       %($# >= 4 %? $4 %: never %),
>       %($# >= 5 %? $5 %: never %),
>       %($# >= 6 %? $6 %: never %),
>       %($# >= 7 %? $7 %: never %),
>       %($# >= 8 %? $8 %: never %),
>       %($# >= 9 %? $9 %: never %),
>       %($# >= 10 %? $10 %: never %),
>       %($# >= 11 %? $11 %: never %),
>       %($# >= 12 %? $12 %: never %),
>       %($# >= 13 %? $13 %: never %),
>       %($# >= 14 %? $14 %: never %),
>       %($# >= 15 %? $15 %: never %),
>       %($# >= 16 %? $16 %: never %),
>       %($# >= 17 %? $17 %: never %),
>       %($# >= 18 %? $18 %: never %),
>       %($# >= 19 %? $19 %: never %),
>       %($# >= 20 %? $20 %: never %),
>       %($# >= 21 %? $21 %: never %),
>       %($# >= 22 %? $22 %: never %),
>       %($# >= 23 %? $23 %: never %),
>       %($# >= 24 %? $24 %: never %),
>       %($# >= 25 %? $25 %: never %),
>       %($# >= 26 %? $26 %: never %),
>       %($# >= 27 %? $27 %: never %),
>       %($# >= 28 %? $28 %: never %),
>       %($# >= 29 %? $29 %: never %),
>       %($# >= 30 %? $30 %: never %),
>       %($# >= 31 %? $32 %: never %),
>       %($# >= 32 %? $32 %: never %)
> {
>   if (target() && pid() != target())
>     next
>   c[tid(), pn()]<<<1
> }
> 
> probe end {
>   printf("%s\t%s\n", "TID", "EVENT: COUNT")
>   foreach([tid+, name] in c)
>     printf("%5d\t%s: %d\n",tid, name, @count(c[tid, name]))
>   delete c
> }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]