| 1 |
#! /usr/bin/env stap |
| 2 |
|
| 3 |
global bt%[100] |
| 4 |
|
| 5 |
probe process("/lib*/libc.so.*").function("free") { |
| 6 |
// we use @defined($mem) here because on 64 bit systems, the |
| 7 |
// wildcard search takes us through both 64 bit and 32 bit |
| 8 |
// libc (which doesn't have debuginfo), this means the probe |
| 9 |
// point resolved from the 32 bit library has no context info |
| 10 |
if (@defined($mem)) { |
| 11 |
bt[execname(),tid(),$mem,sprint_ubacktrace()] |
| 12 |
<<< local_clock_ns() |
| 13 |
} |
| 14 |
// Any monotonically increasing expression would do. |
| 15 |
// With some arbitrary expression or constant instead, |
| 16 |
// at worst we get the last 100ish results out of order. |
| 17 |
} |
| 18 |
|
| 19 |
probe end,error { |
| 20 |
foreach ([e,t,p,b] in bt @max+) // iterate in increasing index order |
| 21 |
printf("free #%d: %s[%d], pointer %p:\n%s\n\n", |
| 22 |
@max(bt[e,t,p,b]), e, t, p, b) |
| 23 |
} |