summaryrefslogtreecommitdiffstats
path: root/runtime/debugger.cc
diff options
context:
space:
mode:
authorPavel Vyssotski <pavel.n.vyssotski@intel.com>2014-12-08 13:38:26 +0600
committerPavel Vyssotski <pavel.n.vyssotski@intel.com>2014-12-08 13:38:26 +0600
commit7522c741d9660a56da2dd6a8e20b8cdf01a6c333 (patch)
tree2ac37a51bda6a9f1fdbfbcfc2e6bf89cf00fd006 /runtime/debugger.cc
parentab6572b564db69e2877456ca6fbd3a00f4cc4b6b (diff)
downloadart-7522c741d9660a56da2dd6a8e20b8cdf01a6c333.tar.gz
art-7522c741d9660a56da2dd6a8e20b8cdf01a6c333.tar.bz2
art-7522c741d9660a56da2dd6a8e20b8cdf01a6c333.zip
ART: Fix DDM client hang transmitting native heap dump with MALLOC_IMPL=dlmalloc
VM acting as a DDM client hangs transmitting native heap segment data when dlmalloc is used instead of default jemalloc. dlmalloc_inspect_all disallow any memory allocation inside heap callback. So cannot send any data walking the heap, the same for logging. Callback function also needs to acquire the heap bitmap lock. Finally, need to indicate end of a space to flush data. Change-Id: I9541962268dd58c2a4237fe1550c9e153252ab4a Signed-off-by: Pavel Vyssotski <pavel.n.vyssotski@intel.com>
Diffstat (limited to 'runtime/debugger.cc')
-rw-r--r--runtime/debugger.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index a9b70cbaa1..c726c8299c 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -4316,6 +4316,12 @@ class HeapChunkContext {
size_t needed = (((length/ALLOCATION_UNIT_SIZE + 255) / 256) * 2) + 17;
size_t bytesLeft = buf_.size() - (size_t)(p_ - &buf_[0]);
if (bytesLeft < needed) {
+#if defined(HAVE_ANDROID_OS) && defined(USE_DLMALLOC)
+ // Cannot trigger memory allocation while walking native heap.
+ if (type_ == CHUNK_TYPE("NHSG")) {
+ return;
+ }
+#endif
Flush();
}
@@ -4435,7 +4441,9 @@ void Dbg::DdmSendHeapSegments(bool native) {
HeapChunkContext context((what == HPSG_WHAT_MERGED_OBJECTS), native);
if (native) {
#if defined(HAVE_ANDROID_OS) && defined(USE_DLMALLOC)
+ ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_);
dlmalloc_inspect_all(HeapChunkContext::HeapChunkCallback, &context);
+ HeapChunkContext::HeapChunkCallback(NULL, NULL, 0, &context); // Indicate end of a space.
#else
UNIMPLEMENTED(WARNING) << "Native heap inspection is only supported with dlmalloc";
#endif