aboutsummaryrefslogtreecommitdiffstats
path: root/libc/bionic/dlmalloc.c
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2013-08-07 15:01:55 -0700
committerColin Cross <ccross@google.com>2013-08-08 00:42:39 +0000
commit7f4074d17d0e22e5e18e472c7e099490df8efaf2 (patch)
tree49697bf0f46ae1e82e604ad42c35f97074eebe2d /libc/bionic/dlmalloc.c
parent6771b9cef635f0da98932a1f0f877a07257ca088 (diff)
downloadandroid_bionic-7f4074d17d0e22e5e18e472c7e099490df8efaf2.tar.gz
android_bionic-7f4074d17d0e22e5e18e472c7e099490df8efaf2.tar.bz2
android_bionic-7f4074d17d0e22e5e18e472c7e099490df8efaf2.zip
bionic: name malloc'd regions
Use the new __bionic_name_mem function to name malloc'd memory as "libc_malloc" on kernels that support it. Change-Id: I7235eae6918fa107010039b9ab8b7cb362212272
Diffstat (limited to 'libc/bionic/dlmalloc.c')
-rw-r--r--libc/bionic/dlmalloc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c
index 78f2e1d56..66a825b33 100644
--- a/libc/bionic/dlmalloc.c
+++ b/libc/bionic/dlmalloc.c
@@ -16,6 +16,7 @@
#include "dlmalloc.h"
+#include "private/bionic_name_mem.h"
#include "private/libc_logging.h"
// Send dlmalloc errors to the log.
@@ -25,6 +26,11 @@ static void __bionic_heap_usage_error(const char* function, void* address);
#define CORRUPTION_ERROR_ACTION(m) __bionic_heap_corruption_error(__FUNCTION__)
#define USAGE_ERROR_ACTION(m,p) __bionic_heap_usage_error(__FUNCTION__, p)
+/* Bionic named anonymous memory declarations */
+static void* named_anonymous_mmap(size_t length);
+#define MMAP(s) named_anonymous_mmap(s)
+#define DIRECT_MMAP(s) named_anonymous_mmap(s)
+
// Ugly inclusion of C file so that bionic specific #defines configure dlmalloc.
#include "../upstream-dlmalloc/malloc.c"
@@ -42,3 +48,15 @@ static void __bionic_heap_usage_error(const char* function, void* address) {
// TODO: improve the debuggerd protocol so we can tell it to dump an address when we abort.
*((int**) 0xdeadbaad) = (int*) address;
}
+
+static void* named_anonymous_mmap(size_t length)
+{
+ void* ret;
+ ret = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (ret == MAP_FAILED)
+ return ret;
+
+ __bionic_name_mem(ret, length, "libc_malloc");
+
+ return ret;
+}