torsava / rpms / python3

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