root@debianvm:/home/jinhailang/stapxx# ./samples/sample-bt-leaks.sxx -x 30408 -v --arg time=5 > a.btPass 1: parsed user script and 466 library scripts using 114076virt/46948res/6380shr/40724data kb, in 0usr/190sys/193real ms.semantic error: while resolving probe point: identifier 'process' at <input>:17:7 source: probe process("/usr/local/openresty/lualib/cjson.so").function("malloc").return, ^
semantic error: no match (similar functions: die, _fini, _init, json_decode, json_encode)
semantic error: while resolving probe point: identifier 'process' at :18:7 source: process("/usr/local/openresty/lualib/cjson.so").function("calloc").return, ^
semantic error: no match (similar functions: die, _fini, _init, json_decode, json_encode)
semantic error: while resolving probe point: identifier 'process' at :19:7 source: process("/usr/local/openresty/lualib/cjson.so").function("realloc").return ^
semantic error: no match (similar functions: die, _fini, _init, decode_hex4, json_encode)
semantic error: while resolving probe point: identifier 'process' at :74:7 source: probe process("/usr/local/openresty/lualib/cjson.so").function("free") ^
semantic error: no match (similar functions: die, _fini, strbuf_free, _init, strbuf_new)
Pass 2: analyzed script: 2 probes, 186 functions, 3 embeds, 5 globals using 115792virt/49980res/7728shr/42440data kb, in 0usr/50sys/59real ms.Pass 2: analysis failed. [man error::pass2]Tip: /usr/share/doc/systemtap/README.Debian should help you get started.
root@debianvm:/home/jinhailang/stapxx# ./samples/sample-bt-leaks.sxx -x 30408 -v --arg time=5 --dump-src#!/usr/bin/env stap
# Copyright (C) Yichun Zhang (agentzh)
global ptr2btglobal ptr2sizeglobal bt_statsglobal quitglobal free_misses
probe begin{ warn(sprintf("Start tracing %d (/usr/local/openresty/nginx/sbin/nginx)...", target())) warn("Wait for 5 sec to complete.\n")}
probe process("/usr/local/openresty/lualib/cjson.so").function("malloc").return, process("/usr/local/openresty/lualib/cjson.so").function("calloc").return, process("/usr/local/openresty/lualib/cjson.so").function("realloc").return{ if (pid() == target()) { //printf("Hit %s\n", probefunc()) if (quit) { if (free_misses) { warn(sprintf("free misses: %d", free_misses)) }
foreach (bt in bt_stats) { print_ustack(bt) printf("\t%d\n", @sum(bt_stats[bt])) }
exit()
} else { if (@defined($oldmem)) { //printf("free %p in realloc\n", $oldmem) ptr = $oldmem
bt = ptr2bt[ptr] delete ptr2bt[ptr]
bytes = ptr2size[ptr] delete ptr2size[ptr]
bt_stats[bt] <<< -bytes if (@sum(bt_stats[bt]) == 0) { delete bt_stats[bt] } }
ptr = returnval() if (ptr) { // here we use a hack specific to glibc's implementation // to get the size of the memory block because we // may not get the value of the $bytes parameter reliably.
p = ptr - &@cast(0, "size_t")[1] size = @cast(p, "size_t")[0] & ~(&@cast(0, "size_t")[1] - 1)
//printf("alloc: %p (bytes %d)\n", ptr, size) bt = ubacktrace() ptr2bt[ptr] = bt ptr2size[ptr] = size bt_stats[bt] <<< size
} else { warn("NULL returned") } } }}