Blame SOURCES/pyfuntop.stp

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