diff options
author | otto <> | 2016-04-09 14:08:40 +0000 |
---|---|---|
committer | otto <> | 2016-04-09 14:08:40 +0000 |
commit | 9daf4463cbdb387d00cdaabe38143bef6fe1ee9e (patch) | |
tree | 689e68a4515770515e94c419c9e8fbbb2c7c53d2 /src | |
parent | 769e6f5d94f0fdefc7c578523fde8fb355b8bc4e (diff) | |
download | openbsd-9daf4463cbdb387d00cdaabe38143bef6fe1ee9e.tar.gz openbsd-9daf4463cbdb387d00cdaabe38143bef6fe1ee9e.tar.bz2 openbsd-9daf4463cbdb387d00cdaabe38143bef6fe1ee9e.zip |
tweak MALLOC_STATS printing (switched off by default), prodded by
Michael McConville
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/malloc.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 536cd435d9..fe010f18d8 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: malloc.c,v 1.186 2016/04/09 12:23:59 otto Exp $ */ | 1 | /* $OpenBSD: malloc.c,v 1.187 2016/04/09 14:08:40 otto Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2008, 2010, 2011 Otto Moerbeek <otto@drijf.net> | 3 | * Copyright (c) 2008, 2010, 2011 Otto Moerbeek <otto@drijf.net> |
4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> | 4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> |
@@ -172,7 +172,7 @@ struct chunk_info { | |||
172 | u_short size; /* size of this page's chunks */ | 172 | u_short size; /* size of this page's chunks */ |
173 | u_short shift; /* how far to shift for this size */ | 173 | u_short shift; /* how far to shift for this size */ |
174 | u_short free; /* how many free chunks */ | 174 | u_short free; /* how many free chunks */ |
175 | u_short total; /* how many chunk */ | 175 | u_short total; /* how many chunks */ |
176 | /* which chunks are free */ | 176 | /* which chunks are free */ |
177 | u_short bits[1]; | 177 | u_short bits[1]; |
178 | }; | 178 | }; |
@@ -1758,16 +1758,20 @@ putleakinfo(void *f, size_t sz, int cnt) | |||
1758 | static struct malloc_leak *malloc_leaks; | 1758 | static struct malloc_leak *malloc_leaks; |
1759 | 1759 | ||
1760 | static void | 1760 | static void |
1761 | writestr(int fd, const char *p) | ||
1762 | { | ||
1763 | write(fd, p, strlen(p)); | ||
1764 | } | ||
1765 | |||
1766 | static void | ||
1761 | dump_leaks(int fd) | 1767 | dump_leaks(int fd) |
1762 | { | 1768 | { |
1763 | struct leaknode *p; | 1769 | struct leaknode *p; |
1764 | char buf[64]; | 1770 | char buf[64]; |
1765 | int i = 0; | 1771 | int i = 0; |
1766 | 1772 | ||
1767 | snprintf(buf, sizeof(buf), "Leak report\n"); | 1773 | writestr(fd, "Leak report\n"); |
1768 | write(fd, buf, strlen(buf)); | 1774 | writestr(fd, " f sum # avg\n"); |
1769 | snprintf(buf, sizeof(buf), " f sum # avg\n"); | ||
1770 | write(fd, buf, strlen(buf)); | ||
1771 | /* XXX only one page of summary */ | 1775 | /* XXX only one page of summary */ |
1772 | if (malloc_leaks == NULL) | 1776 | if (malloc_leaks == NULL) |
1773 | malloc_leaks = MMAP(MALLOC_PAGESIZE); | 1777 | malloc_leaks = MMAP(MALLOC_PAGESIZE); |
@@ -1808,10 +1812,8 @@ dump_chunk(int fd, struct chunk_info *p, void *f, int fromfreelist) | |||
1808 | break; | 1812 | break; |
1809 | } | 1813 | } |
1810 | p = LIST_NEXT(p, entries); | 1814 | p = LIST_NEXT(p, entries); |
1811 | if (p != NULL) { | 1815 | if (p != NULL) |
1812 | snprintf(buf, sizeof(buf), " "); | 1816 | writestr(fd, " "); |
1813 | write(fd, buf, strlen(buf)); | ||
1814 | } | ||
1815 | } | 1817 | } |
1816 | } | 1818 | } |
1817 | 1819 | ||
@@ -1822,8 +1824,7 @@ dump_free_chunk_info(int fd, struct dir_info *d) | |||
1822 | int i, j, count; | 1824 | int i, j, count; |
1823 | struct chunk_info *p; | 1825 | struct chunk_info *p; |
1824 | 1826 | ||
1825 | snprintf(buf, sizeof(buf), "Free chunk structs:\n"); | 1827 | writestr(fd, "Free chunk structs:\n"); |
1826 | write(fd, buf, strlen(buf)); | ||
1827 | for (i = 0; i <= MALLOC_MAXSHIFT; i++) { | 1828 | for (i = 0; i <= MALLOC_MAXSHIFT; i++) { |
1828 | count = 0; | 1829 | count = 0; |
1829 | LIST_FOREACH(p, &d->chunk_info_list[i], entries) | 1830 | LIST_FOREACH(p, &d->chunk_info_list[i], entries) |
@@ -1890,9 +1891,8 @@ malloc_dump1(int fd, struct dir_info *d) | |||
1890 | write(fd, buf, strlen(buf)); | 1891 | write(fd, buf, strlen(buf)); |
1891 | dump_free_chunk_info(fd, d); | 1892 | dump_free_chunk_info(fd, d); |
1892 | dump_free_page_info(fd, d); | 1893 | dump_free_page_info(fd, d); |
1893 | snprintf(buf, sizeof(buf), | 1894 | writestr(fd, |
1894 | "slot) hash d type page f size [free/n]\n"); | 1895 | "slot) hash d type page f size [free/n]\n"); |
1895 | write(fd, buf, strlen(buf)); | ||
1896 | for (i = 0; i < d->regions_total; i++) { | 1896 | for (i = 0; i < d->regions_total; i++) { |
1897 | if (d->r[i].p != NULL) { | 1897 | if (d->r[i].p != NULL) { |
1898 | size_t h = hash(d->r[i].p) & | 1898 | size_t h = hash(d->r[i].p) & |