From 34880692ac845a7fd45cacdf43b75e736e451d62 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 24 Mar 2017 16:23:06 +0000 Subject: add a helper function to print all pools #ifdef MALLOC_STATS from David CARLIER --- lib/libc/stdlib/malloc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/libc/stdlib/malloc.c') diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index c67607e8fee..688354f1e01 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.216 2017/03/24 16:15:31 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.217 2017/03/24 16:23:05 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -211,6 +211,8 @@ static void fill_canary(char *ptr, size_t sz, size_t allocated); #ifdef MALLOC_STATS void malloc_dump(int, int, struct dir_info *); PROTO_NORMAL(malloc_dump); +void malloc_gdump(int); +PROTO_NORMAL(malloc_gdump); static void malloc_exit(void); #define CALLER __builtin_return_address(0) #else @@ -2244,6 +2246,19 @@ malloc_dump(int fd, int poolno, struct dir_info *pool) } DEF_WEAK(malloc_dump); +void +malloc_gdump(int fd) +{ + int i; + int saved_errno = errno; + + for (i = 0; i < _MALLOC_MUTEXES; i++) + malloc_dump(fd, i, mopts.malloc_pool[i]); + + errno = saved_errno; +} +DEF_WEAK(malloc_gdump); + static void malloc_exit(void) { -- cgit v1.2.3