-.\" $OpenBSD: malloc.9,v 1.64 2017/10/27 16:11:00 visa Exp $
+.\" $OpenBSD: malloc.9,v 1.65 2017/11/27 09:23:44 mpi Exp $
.\" $NetBSD: malloc.9,v 1.2 1996/10/30 05:29:54 lukem Exp $
.\"
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: October 27 2017 $
+.Dd $Mdocdate: November 27 2017 $
.Dt MALLOC 9
.Os
.Sh NAME
Should be on free list.
.It Dv M_DEVBUF
Device driver memory.
-.It Dv M_DEBUG
-.Nm malloc
-debug structures.
.It Dv M_PCB
Protocol control blocks.
.It Dv M_RTABLE
.It
.Dq Data modified on freelist: Aq data object description
.El
-.Sh DEBUGGING
-A kernel compiled with the
-.Cm MALLOC_DEBUG
-option allows for more extensive debugging of memory allocations.
-The
-.Va debug_malloc_type ,
-.Va debug_malloc_size ,
-.Va debug_malloc_size_lo
-and
-.Va debug_malloc_size_hi
-variables choose which allocation to debug.
-.Va debug_malloc_type
-should be set to the memory type and
-.Va debug_malloc_size
-should be set to the memory size to debug.
-0 can be used as a wildcard.
-.Va debug_malloc_size_lo
-and
-.Va debug_malloc_size_hi
-can be used to specify a range of sizes if the exact size to debug is not
-known.
-When those are used,
-.Va debug_malloc_size
-needs to be set to the wildcard.
-.Dv M_DEBUG
-can also be specified as an allocation type to force allocation with
-debugging.
-.Pp
-Every call to
-.Fn malloc
-or
-.Fn mallocarray
-with a memory type and size that matches the debugged type and size will
-allocate two virtual pages.
-The pointer returned will be aligned so that
-the requested area will end at the page boundary and the second virtual page
-will be left unmapped.
-This way we can catch reads and writes outside the allocated area.
-.Pp
-Every call to
-.Fn free
-with memory that was returned by the debugging allocators will cause the memory
-area to become unmapped so that we can catch dangling reads and writes to
-freed memory.
-.Pp
-There are no special diagnostics if any errors are caught by the debugging
-malloc.
-The errors will look like normal access to unmapped memory.
-On a memory access error, the
-.Ic show malloc
-command in
-.Xr ddb 4
-can be invoked to see what memory areas are allocated and freed.
-If the faulting address is within two pages from an address on the allocated
-list, there was an access outside the allocated area.
-If the faulting address is within two pages from an address on the free list,
-there was an access to freed memory.
-.Pp
-Care needs to be taken when using the
-.Cm MALLOC_DEBUG
-option: the memory consumption can run away pretty quickly and there is
-a severe performance degradation when allocating and freeing debugged memory
-types.
.Sh SEE ALSO
.Xr systat 1 ,
.Xr vmstat 8
-/* $OpenBSD: db_command.c,v 1.79 2017/10/19 16:58:05 bluhm Exp $ */
+/* $OpenBSD: db_command.c,v 1.80 2017/11/27 09:23:44 mpi Exp $ */
/* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */
/*
void
db_malloc_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
{
-#if defined(MALLOC_DEBUG)
- extern void debug_malloc_printit(int (*)(const char *, ...), vaddr_t);
-
- if (!have_addr)
- addr = 0;
-
- debug_malloc_printit(db_printf, (vaddr_t)addr);
-#else
malloc_printit(db_printf);
-#endif
}
/*ARGSUSED*/
-/* $OpenBSD: malloc.h,v 1.115 2017/10/27 16:11:00 visa Exp $ */
+/* $OpenBSD: malloc.h,v 1.116 2017/11/27 09:23:44 mpi Exp $ */
/* $NetBSD: malloc.h,v 1.39 1998/07/12 19:52:01 augustss Exp $ */
/*
#define M_FREE 0 /* should be on free list */
/* 1 - free */
#define M_DEVBUF 2 /* device driver memory */
-#define M_DEBUG 3 /* debug chunk */
+/* 3 - free */
#define M_PCB 4 /* protocol control block */
#define M_RTABLE 5 /* routing tables */
/* 6 - free */
"free", /* 0 M_FREE */ \
NULL, \
"devbuf", /* 2 M_DEVBUF */ \
- "debug", /* 3 M_DEBUG */ \
+ NULL, \
"pcb", /* 4 M_PCB */ \
"rtable", /* 5 M_RTABLE */ \
NULL, /* 6 */ \
int poison_check(void *, size_t, size_t *, uint32_t *);
uint32_t poison_value(void *);
-#ifdef MALLOC_DEBUG
-int debug_malloc(unsigned long, int, int, void **);
-int debug_free(void *, int);
-void debug_malloc_init(void);
-void debug_malloc_assert_allocated(void *, const char *);
-#define DEBUG_MALLOC_ASSERT_ALLOCATED(addr) \
- debug_malloc_assert_allocated(addr, __func__)
-
-void debug_malloc_print(void);
-void debug_malloc_printit(int (*)(const char *, ...), vaddr_t);
-#endif /* MALLOC_DEBUG */
#endif /* _KERNEL */
#endif /* !_SYS_MALLOC_H_ */