diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-12-05 22:16:14 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-12-05 22:16:14 +0000 |
commit | 4d5a44907aac4575e14651ef0f82b8413d323b9d (patch) | |
tree | 9e902a94d5e9997d582dbc403d08e7a8f4e83616 /sys | |
parent | c7512fd6222f8607869c0aa0ef323ed86c8cd9eb (diff) |
Do not use debug_malloc if it hasn't been initialized.
This can happen when debug_malloc_init calls pool_init which calls
malloc (because the kernel is built with POOL_DIAGNOSTIC) which in turn
calls debug_malloc and debug_malloc just happens to trigger on all memory
allocations.
This allows us to run a kernel debugging _all_ allocations.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_malloc_debug.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/kern/kern_malloc_debug.c b/sys/kern/kern_malloc_debug.c index 1e67b0d3a36..b12f7a6edc3 100644 --- a/sys/kern/kern_malloc_debug.c +++ b/sys/kern/kern_malloc_debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc_debug.c,v 1.18 2002/07/01 23:04:09 art Exp $ */ +/* $OpenBSD: kern_malloc_debug.c,v 1.19 2002/12/05 22:16:13 art Exp $ */ /* * Copyright (c) 1999, 2000 Artur Grabowski <art@openbsd.org> @@ -75,8 +75,8 @@ * if any memory chunks of this type are used. It's ok to change the size * in runtime. */ -int debug_malloc_type = -1; -int debug_malloc_size = -1; +int debug_malloc_type = 0; +int debug_malloc_size = 0; int debug_malloc_size_lo = -1; int debug_malloc_size_hi = -1; @@ -104,6 +104,8 @@ int debug_malloc_frees; int debug_malloc_pages; int debug_malloc_chunks_on_freelist; +int debug_malloc_initialized; + struct pool debug_malloc_pool; int @@ -116,7 +118,8 @@ debug_malloc(unsigned long size, int type, int flags, void **addr) if ((type != debug_malloc_type && debug_malloc_type != 0) || (size != debug_malloc_size && debug_malloc_size != 0) || (debug_malloc_size_lo != -1 && size < debug_malloc_size_lo) || - (debug_malloc_size_hi != -1 && size > debug_malloc_size_hi)) + (debug_malloc_size_hi != -1 && size > debug_malloc_size_hi) || + !debug_malloc_initialized) return (0); /* XXX - fix later */ @@ -217,6 +220,8 @@ debug_malloc_init(void) pool_init(&debug_malloc_pool, sizeof(struct debug_malloc_entry), 0, 0, 0, "mdbepl", NULL); + + debug_malloc_initialized = 1; } /* |