File: last_100_frees.stp

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (23 lines) | stat: -rwxr-xr-x 808 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/env stap

global bt%[100]

probe process("/lib*/libc.so.*").function("free") {
  // we use @defined($mem) here because on 64 bit systems, the
  // wildcard search takes us through both 64 bit and 32 bit
  // libc (which doesn't have debuginfo), this means the probe
  // point resolved from the 32 bit library has no context info
  if (@defined($mem)) {
    bt[execname(),tid(),$mem,sprint_ubacktrace()]
      <<< local_clock_ns()
  }
  // Any monotonically increasing expression would do.
  // With some arbitrary expression or constant instead,
  // at worst we get the last 100ish results out of order.
}

probe end,error {
  foreach ([e,t,p,b] in bt @max+) // iterate in increasing index order
     printf("free #%d: %s[%d], pointer %p:\n%s\n\n",
            @max(bt[e,t,p,b]), e, t, p, b)
}