torsava / rpms / python3

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