diff options
Diffstat (limited to 'tools/memleak.py')
-rwxr-xr-x | tools/memleak.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/memleak.py b/tools/memleak.py index 6cda1506..27a2e095 100755 --- a/tools/memleak.py +++ b/tools/memleak.py @@ -272,6 +272,19 @@ int realloc_exit(struct pt_regs *ctx) { return gen_alloc_exit(ctx); } +int mmap_enter(struct pt_regs *ctx) { + size_t size = (size_t)PT_REGS_PARM2(ctx); + return gen_alloc_enter(ctx, size); +} + +int mmap_exit(struct pt_regs *ctx) { + return gen_alloc_exit(ctx); +} + +int munmap_enter(struct pt_regs *ctx, void *address) { + return gen_free_enter(ctx, address); +} + int posix_memalign_enter(struct pt_regs *ctx, void **memptr, size_t alignment, size_t size) { u64 memptr64 = (u64)(size_t)memptr; @@ -449,6 +462,7 @@ if not kernel_trace: attach_probes("malloc") attach_probes("calloc") attach_probes("realloc") + attach_probes("mmap") attach_probes("posix_memalign") attach_probes("valloc", can_fail=True) # failed on Android, is deprecated in libc.so from bionic directory attach_probes("memalign") @@ -456,6 +470,8 @@ if not kernel_trace: attach_probes("aligned_alloc", can_fail=True) # added in C11 bpf.attach_uprobe(name=obj, sym="free", fn_name="free_enter", pid=pid) + bpf.attach_uprobe(name=obj, sym="munmap", fn_name="munmap_enter", + pid=pid) else: print("Attaching to kernel allocators, Ctrl+C to quit.") @@ -494,7 +510,7 @@ def print_outstanding(): stack = list(stack_traces.walk(info.stack_id)) combined = [] for addr in stack: - combined.append(bpf.sym(addr, pid, + combined.append(('0x'+format(addr, '016x')+'\t').encode('utf-8') + bpf.sym(addr, pid, show_module=True, show_offset=True)) alloc_info[info.stack_id] = Allocation(combined, info.size) |