summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc/heap_debug.c
diff options
context:
space:
mode:
authorMiles Bader <miles@lsi.nec.co.jp>2002-11-21 06:06:22 +0000
committerMiles Bader <miles@lsi.nec.co.jp>2002-11-21 06:06:22 +0000
commit4d952dfe7756644a4e7f92081906fd7d4194209c (patch)
tree3ae59605aa27796cd2f1bc7d9bb852d3cb588a83 /libc/stdlib/malloc/heap_debug.c
parentac6d271cf95d6994c88ff8dcc096b98f33c50644 (diff)
Improve malloc debugging support.
Diffstat (limited to 'libc/stdlib/malloc/heap_debug.c')
-rw-r--r--libc/stdlib/malloc/heap_debug.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/libc/stdlib/malloc/heap_debug.c b/libc/stdlib/malloc/heap_debug.c
index 85ed15609..c1a127317 100644
--- a/libc/stdlib/malloc/heap_debug.c
+++ b/libc/stdlib/malloc/heap_debug.c
@@ -16,6 +16,7 @@
#include <stdarg.h>
#include <string.h>
+#include "malloc.h"
#include "heap.h"
@@ -29,14 +30,14 @@ __heap_dump_freelist (struct heap *heap)
{
struct heap_free_area *fa;
for (fa = heap->free_areas; fa; fa = fa->next)
- fprintf (stderr,
- " 0x%lx: 0x%lx - 0x%lx (%d)\tP=0x%lx, N=0x%lx\n",
- (long)fa,
- (long)HEAP_FREE_AREA_START (fa),
- (long)HEAP_FREE_AREA_END (fa),
- fa->size,
- (long)fa->prev,
- (long)fa->next);
+ __malloc_debug_printf (0,
+ "0x%lx: 0x%lx - 0x%lx (%d)\tP=0x%lx, N=0x%lx",
+ (long)fa,
+ (long)HEAP_FREE_AREA_START (fa),
+ (long)HEAP_FREE_AREA_END (fa),
+ fa->size,
+ (long)fa->prev,
+ (long)fa->next);
}
/* Output a text representation of HEAP to stderr, labelling it with STR. */
@@ -51,8 +52,9 @@ __heap_dump (struct heap *heap, const char *str)
recursed = 1;
- fprintf (stderr, " %s: heap @0x%lx:\n", str, (long)heap);
+ __malloc_debug_printf (1, "%s: heap @0x%lx:", str, (long)heap);
__heap_dump_freelist (heap);
+ __malloc_debug_indent (-1);
recursed = 0;
}
@@ -76,7 +78,10 @@ __heap_check_failure (struct heap *heap, struct heap_free_area *fa,
vfprintf (stderr, fmt, val);
va_end (val);
- fprintf (stderr, "\nheap dump:\n");
+ putc ('\n', stderr);
+
+ __malloc_debug_set_indent (0);
+ __malloc_debug_printf (1, "heap dump:");
__heap_dump_freelist (heap);
exit (22);