Debian Codegraph @

testsuite/systemtap.examples/profiling/fileline-profile.stp

raw
1 #! /usr/bin/env stap
2
3 %( CONFIG_64BIT == "y" %?
4 global profile%[20000], pcount
5 %:
6 # On a 32-bit platform, the profile array must be smaller, otherwise
7 # its allocation will fail on module startup.
8 global profile%[5000], pcount
9 %)
10 // configurable options
11 global symbolname = ""
12
13 probe timer.profile {
14 pcount <<< 1
15
16 uaddrinfo = ""
17 ufileline = ""
18 if (user_mode()) {
19 ufileline = usymfileline(uaddr())
20 if (strtol(ufileline, 16))
21 uaddrinfo = usymdata(uaddr())
22 else {
23 if (symbolname != "")
24 uaddrinfo = usymname(uaddr())."@"
25 uaddrinfo .= ufileline
26 }
27 profile[uaddrinfo, 0] <<< 1
28 } else {
29 profile["", addr()] <<< 1
30 }
31 }
32 probe end {
33 printf ("\n--- %d samples recorded:\n", @count(pcount))
34 foreach ([sfl, address] in profile- limit 20) {
35 if (sfl != "")
36 printf ("u:%-60s\t%6d\n", sfl, @count(profile[sfl, address]))
37 else {
38 addrinfo = ""
39 fileline = symfileline(address)
40 if (strtol(fileline, 16))
41 addrinfo = symdata(address)
42 else {
43 if (symbolname != "")
44 addrinfo = symname(address)."@"
45 addrinfo .= fileline
46 }
47 printf ("k:%-60s\t%6d\n", addrinfo, @count(profile[sfl, address]))
48 }
49 }
50 }