Files
ldb/ebpf/leak_detect/memleak.bpf

36 lines
671 B
Plaintext

BEGIN
{
printf("Start memory leakage detect\n");
}
uprobe:/home/lian/share/9.1-kvstore/kvstore:nMalloc
{
@tmp_size[tid] = arg0;
@tmp_file[tid] = str(arg1);
@tmp_func[tid] = str(arg2);
@tmp_line[tid] = arg3;
}
uretprobe:/home/lian/share/9.1-kvstore/kvstore:nMalloc
{
$ptr = retval;
if ($ptr != 0) {
@allocs[$ptr] = ( @tmp_file[tid], @tmp_line[tid], @tmp_func[tid], @tmp_size[tid]);
}
delete(@tmp_size[tid]);
delete(@tmp_file[tid]);
delete(@tmp_func[tid]);
delete(@tmp_line[tid]);
}
uprobe:/home/lian/share/9.1-kvstore/kvstore:nFree
{
delete(@allocs[arg0]);
}
END
{
printf("\n=== Memory Leaks ===\n");
}