71040c
#!/usr/bin/stap 
71040c
71040c
global fn_calls;
71040c
71040c
probe python.function.entry
71040c
{ 
71040c
  fn_calls[pid(), filename, funcname, lineno] += 1;
71040c
}
71040c
71040c
probe timer.ms(1000) {
71040c
    printf("\033[2J\033[1;1H") /* clear screen */
71040c
    printf("%6s %80s %6s %30s %6s\n",
71040c
           "PID", "FILENAME", "LINE", "FUNCTION", "CALLS")
71040c
    foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) {
71040c
        printf("%6d %80s %6d %30s %6d\n",
71040c
            pid, filename, lineno, funcname,
71040c
            fn_calls[pid, filename, funcname, lineno]);
71040c
    }
71040c
71040c
    delete fn_calls;
71040c
}