Blame SOURCES/pyfuntop.stp

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