Blame SOURCES/pyfuntop.stp

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