Blame SOURCES/pyfuntop.stp

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