File: tcl-funtop.stp

package info (click to toggle)
systemtap 4.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 38,260 kB
  • sloc: cpp: 77,147; ansic: 61,828; xml: 49,277; exp: 42,244; sh: 11,046; python: 2,772; perl: 2,252; tcl: 1,305; makefile: 1,086; lisp: 105; java: 102; awk: 101; asm: 91; sed: 16
file content (30 lines) | stat: -rwxr-xr-x 822 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/env stap
# Copyright (C) 2018 Red Hat, Inc.
# Written by William Cohen <wcohen@redhat.com>
#
# This script continuously lists the top 20 Tcl functions in the interval 
# 5 seconds
#

global fn_calls

probe process("/usr/lib*/libtcl*.so").mark("proc__info")
{
  funcname = user_string2($arg3, "<unavailable>")
  filename = user_string2($arg4, "<unavailable>")
  lineno = $arg5
  fn_calls[pid(), filename, funcname, lineno] <<< 1
}

probe timer.ms(5000) {
  ansi_clear_screen()
  printf("%6s %-80s %6s %-30s %6s\n",
         "PID", "FILENAME", "LINE", "FUNCTION", "CALLS")
  foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) {
    printf("%6d %-80s %6d %-30s %6d\n",
           pid, filename, lineno, funcname,
           @sum(fn_calls[pid, filename, funcname, lineno]))
  }

  delete fn_calls
}