Blame SOURCES/pyfuntop.stp

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