2 * libc/stdlib/malloc/malloc_debug.c -- malloc debugging support
4 * Copyright (C) 2002 NEC Corporation
5 * Copyright (C) 2002 Miles Bader <miles@gnu.org>
7 * This file is subject to the terms and conditions of the GNU Lesser
8 * General Public License. See the file COPYING.LIB in the main
9 * directory of this archive for more details.
11 * Written by Miles Bader <miles@gnu.org>
23 int __malloc_debug = 0, __malloc_check = 0;
25 #ifdef MALLOC_MMB_DEBUGGING
26 int __malloc_mmb_debug = 0;
29 /* Debugging output is indented this may levels. */
30 int __malloc_debug_cur_indent = 0;
33 /* Print FMT and args indented at the current debug print level, followed
34 by a newline, and change the level by INDENT. */
36 __malloc_debug_printf (int indent, const char *fmt, ...)
38 unsigned spaces = __malloc_debug_cur_indent * MALLOC_DEBUG_INDENT_SIZE;
48 vfprintf (stderr, fmt, val);
53 __malloc_debug_indent (indent);
57 __malloc_debug_init (void)
59 char *ev = getenv ("MALLOC_DEBUG");
70 #ifdef MALLOC_MMB_DEBUGGING
72 __malloc_mmb_debug = 1;
82 (0, "malloc_debug: initialized to %d (check = %d, dump = %d, dump_mmb = %d, dump_heap = %d)",
84 !!(val & 1), !!(val & 2),
85 !!(val & 4), !!(val & 8));