summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorotto <>2023-06-22 11:04:16 +0000
committerotto <>2023-06-22 11:04:16 +0000
commit9f41a64eb230fd1c343999400564e3e14747c3e9 (patch)
treefeea18069b28cbfa101b72240970a4afce3dde4b /src/lib/libc/stdlib/malloc.c
parent4c0df1809176af2c27699157cf128a4348f6daa5 (diff)
downloadopenbsd-9f41a64eb230fd1c343999400564e3e14747c3e9.tar.gz
openbsd-9f41a64eb230fd1c343999400564e3e14747c3e9.tar.bz2
openbsd-9f41a64eb230fd1c343999400564e3e14747c3e9.zip
Allow to ask for deeper callers for leak reports using malloc options.
ok deraadt@
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
-rw-r--r--src/lib/libc/stdlib/malloc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index 04f211c4ef..7bc660525b 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.286 2023/06/07 12:56:22 aoyama Exp $ */ 1/* $OpenBSD: malloc.c,v 1.287 2023/06/22 11:04:16 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net>
4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> 4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -255,7 +255,11 @@ void malloc_dump(void);
255PROTO_NORMAL(malloc_dump); 255PROTO_NORMAL(malloc_dump);
256static void malloc_exit(void); 256static void malloc_exit(void);
257#endif 257#endif
258#define CALLER (DO_STATS ? __builtin_return_address(0) : NULL) 258#define CALLER ( \
259 DO_STATS == 0 ? NULL : (__builtin_extract_return_addr( \
260 DO_STATS == 1 ? __builtin_return_address(0) : \
261 DO_STATS == 2 ? __builtin_return_address(1) : \
262 DO_STATS == 3 ? __builtin_return_address(2) : NULL)))
259 263
260/* low bits of r->p determine size: 0 means >= page size and r->size holding 264/* low bits of r->p determine size: 0 means >= page size and r->size holding
261 * real size, otherwise low bits is the bucket + 1 265 * real size, otherwise low bits is the bucket + 1
@@ -365,8 +369,15 @@ omalloc_parseopt(char opt)
365 mopts.malloc_stats = 0; 369 mopts.malloc_stats = 0;
366 break; 370 break;
367 case 'D': 371 case 'D':
372 case '1':
368 mopts.malloc_stats = 1; 373 mopts.malloc_stats = 1;
369 break; 374 break;
375 case '2':
376 mopts.malloc_stats = 2;
377 break;
378 case '3':
379 mopts.malloc_stats = 3;
380 break;
370#endif /* MALLOC_STATS */ 381#endif /* MALLOC_STATS */
371 case 'f': 382 case 'f':
372 mopts.malloc_freecheck = 0; 383 mopts.malloc_freecheck = 0;