[asan] better diagnostics for mmap failure

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161874 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/tests/asan_test.cc b/lib/asan/tests/asan_test.cc
index 994e78a..4fa0b39 100644
--- a/lib/asan/tests/asan_test.cc
+++ b/lib/asan/tests/asan_test.cc
@@ -1879,7 +1879,7 @@
     char *x = (char*)malloc(kAllocSize);
     memset(x, 0, kAllocSize);
     total_size += kAllocSize;
-    fprintf(stderr, "total: %ldM\n", (long)total_size >> 20);
+    fprintf(stderr, "total: %ldM %p\n", (long)total_size >> 20, x);
   }
 }
 
diff --git a/lib/sanitizer_common/sanitizer_posix.cc b/lib/sanitizer_common/sanitizer_posix.cc
index 4caee3b..1b52e15 100644
--- a/lib/sanitizer_common/sanitizer_posix.cc
+++ b/lib/sanitizer_common/sanitizer_posix.cc
@@ -17,10 +17,12 @@
 #include "sanitizer_libc.h"
 #include "sanitizer_procmaps.h"
 
+#include <errno.h>
 #include <pthread.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/mman.h>
 #include <sys/resource.h>
 #include <sys/time.h>
@@ -45,8 +47,9 @@
                             PROT_READ | PROT_WRITE,
                             MAP_PRIVATE | MAP_ANON, -1, 0);
   if (res == (void*)-1) {
-    Report("ERROR: Failed to allocate 0x%zx (%zd) bytes of %s\n",
-           size, size, mem_type);
+    Report("ERROR: Failed to allocate 0x%zx (%zd) bytes of %s: %s\n",
+           size, size, mem_type, strerror(errno));
+    DumpProcessMap();
     CHECK("unable to mmap" && 0);
   }
   return res;