summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2017-03-24 16:23:06 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2017-03-24 16:23:06 +0000
commit34880692ac845a7fd45cacdf43b75e736e451d62 (patch)
tree0bda28b37592b8d6af2911c7e3aae29312b7d66b /lib/libc
parentb189f59dc0c0ceb43f17cd1c51b06320c52c9830 (diff)
add a helper function to print all pools #ifdef MALLOC_STATS
from David CARLIER
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdlib/malloc.c17
1 files changed, 16 insertions, 1 deletions
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 <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -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)
{