summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/stdlib/malloc.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index 3f544006fc..54b3cd427d 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.164 2014/05/18 17:49:47 tedu Exp $ */ 1/* $OpenBSD: malloc.c,v 1.165 2014/05/21 15:47:51 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>
@@ -1643,7 +1643,7 @@ dump_leaks(int fd)
1643 1643
1644 snprintf(buf, sizeof(buf), "Leak report\n"); 1644 snprintf(buf, sizeof(buf), "Leak report\n");
1645 write(fd, buf, strlen(buf)); 1645 write(fd, buf, strlen(buf));
1646 snprintf(buf, sizeof(buf), " f sum # avg\n"); 1646 snprintf(buf, sizeof(buf), " f sum # avg\n");
1647 write(fd, buf, strlen(buf)); 1647 write(fd, buf, strlen(buf));
1648 /* XXX only one page of summary */ 1648 /* XXX only one page of summary */
1649 if (malloc_leaks == NULL) 1649 if (malloc_leaks == NULL)
@@ -1651,7 +1651,7 @@ dump_leaks(int fd)
1651 if (malloc_leaks != MAP_FAILED) 1651 if (malloc_leaks != MAP_FAILED)
1652 memset(malloc_leaks, 0, MALLOC_PAGESIZE); 1652 memset(malloc_leaks, 0, MALLOC_PAGESIZE);
1653 RB_FOREACH(p, leaktree, &leakhead) { 1653 RB_FOREACH(p, leaktree, &leakhead) {
1654 snprintf(buf, sizeof(buf), "%12p %7zu %6u %6zu\n", p->d.f, 1654 snprintf(buf, sizeof(buf), "%18p %7zu %6u %6zu\n", p->d.f,
1655 p->d.total_size, p->d.count, p->d.total_size / p->d.count); 1655 p->d.total_size, p->d.count, p->d.total_size / p->d.count);
1656 write(fd, buf, strlen(buf)); 1656 write(fd, buf, strlen(buf));
1657 if (malloc_leaks == MAP_FAILED || 1657 if (malloc_leaks == MAP_FAILED ||
@@ -1670,7 +1670,7 @@ dump_chunk(int fd, struct chunk_info *p, void *f, int fromfreelist)
1670 char buf[64]; 1670 char buf[64];
1671 1671
1672 while (p != NULL) { 1672 while (p != NULL) {
1673 snprintf(buf, sizeof(buf), "chunk %12p %12p %4d %d/%d\n", 1673 snprintf(buf, sizeof(buf), "chunk %18p %18p %4d %d/%d\n",
1674 p->page, ((p->bits[0] & 1) ? NULL : f), 1674 p->page, ((p->bits[0] & 1) ? NULL : f),
1675 p->size, p->free, p->total); 1675 p->size, p->free, p->total);
1676 write(fd, buf, strlen(buf)); 1676 write(fd, buf, strlen(buf));
@@ -1696,25 +1696,26 @@ static void
1696dump_free_chunk_info(int fd, struct dir_info *d) 1696dump_free_chunk_info(int fd, struct dir_info *d)
1697{ 1697{
1698 char buf[64]; 1698 char buf[64];
1699 int i, count; 1699 int i, j, count;
1700 struct chunk_info *p;
1700 1701
1701 snprintf(buf, sizeof(buf), "Free chunk structs:\n"); 1702 snprintf(buf, sizeof(buf), "Free chunk structs:\n");
1702 write(fd, buf, strlen(buf)); 1703 write(fd, buf, strlen(buf));
1703 for (i = 0; i <= MALLOC_MAXSHIFT; i++) { 1704 for (i = 0; i <= MALLOC_MAXSHIFT; i++) {
1704 struct chunk_info *p;
1705
1706 count = 0; 1705 count = 0;
1707 LIST_FOREACH(p, &d->chunk_info_list[i], entries) 1706 LIST_FOREACH(p, &d->chunk_info_list[i], entries)
1708 count++; 1707 count++;
1709 p = LIST_FIRST(&d->chunk_dir[i]); 1708 for (j = 0; j < MALLOC_CHUNK_LISTS; j++) {
1710 if (p == NULL && count == 0) 1709 p = LIST_FIRST(&d->chunk_dir[i][j]);
1711 continue; 1710 if (p == NULL && count == 0)
1712 snprintf(buf, sizeof(buf), "%2d) %3d ", i, count); 1711 continue;
1713 write(fd, buf, strlen(buf)); 1712 snprintf(buf, sizeof(buf), "%2d) %3d ", i, count);
1714 if (p != NULL) 1713 write(fd, buf, strlen(buf));
1715 dump_chunk(fd, p, NULL, 1); 1714 if (p != NULL)
1716 else 1715 dump_chunk(fd, p, NULL, 1);
1717 write(fd, "\n", 1); 1716 else
1717 write(fd, "\n", 1);
1718 }
1718 } 1719 }
1719 1720
1720} 1721}
@@ -1742,7 +1743,7 @@ dump_free_page_info(int fd, struct dir_info *d)
1742static void 1743static void
1743malloc_dump1(int fd, struct dir_info *d) 1744malloc_dump1(int fd, struct dir_info *d)
1744{ 1745{
1745 char buf[64]; 1746 char buf[100];
1746 size_t i, realsize; 1747 size_t i, realsize;
1747 1748
1748 snprintf(buf, sizeof(buf), "Malloc dir of %s at %p\n", __progname, d); 1749 snprintf(buf, sizeof(buf), "Malloc dir of %s at %p\n", __progname, d);
@@ -1767,7 +1768,7 @@ malloc_dump1(int fd, struct dir_info *d)
1767 dump_free_chunk_info(fd, d); 1768 dump_free_chunk_info(fd, d);
1768 dump_free_page_info(fd, d); 1769 dump_free_page_info(fd, d);
1769 snprintf(buf, sizeof(buf), 1770 snprintf(buf, sizeof(buf),
1770 "slot) hash d type page f size [free/n]\n"); 1771 "slot) hash d type page f size [free/n]\n");
1771 write(fd, buf, strlen(buf)); 1772 write(fd, buf, strlen(buf));
1772 for (i = 0; i < d->regions_total; i++) { 1773 for (i = 0; i < d->regions_total; i++) {
1773 if (d->r[i].p != NULL) { 1774 if (d->r[i].p != NULL) {