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