| 1 |
#! /usr/bin/env stap |
| 2 |
# Copyright (C) 2018 Red Hat, Inc. |
| 3 |
# Written by William Cohen <[email protected]> |
| 4 |
# |
| 5 |
# This script continuously lists the top 20 Tcl functions in the interval |
| 6 |
# 5 seconds |
| 7 |
# |
| 8 |
|
| 9 |
global fn_calls |
| 10 |
|
| 11 |
probe process("/usr/lib*/libtcl*.so").mark("proc__info") |
| 12 |
{ |
| 13 |
funcname = user_string2($arg3, "<unavailable>") |
| 14 |
filename = user_string2($arg4, "<unavailable>") |
| 15 |
lineno = $arg5 |
| 16 |
fn_calls[pid(), filename, funcname, lineno] <<< 1 |
| 17 |
} |
| 18 |
|
| 19 |
probe timer.ms(5000) { |
| 20 |
ansi_clear_screen() |
| 21 |
printf("%6s %-80s %6s %-30s %6s\n", |
| 22 |
"PID", "FILENAME", "LINE", "FUNCTION", "CALLS") |
| 23 |
foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) { |
| 24 |
printf("%6d %-80s %6d %-30s %6d\n", |
| 25 |
pid, filename, lineno, funcname, |
| 26 |
@sum(fn_calls[pid, filename, funcname, lineno])) |
| 27 |
} |
| 28 |
|
| 29 |
delete fn_calls |
| 30 |
} |