Use bionic's dlmalloc 2.8.5.
Also fix free space computations for DDMS.
Change-Id: Icbc045b5461af89a0516f37f01acaaa815205348
diff --git a/src/native/dalvik_system_VMRuntime.cc b/src/native/dalvik_system_VMRuntime.cc
index 33ece66..9e4ecd1 100644
--- a/src/native/dalvik_system_VMRuntime.cc
+++ b/src/native/dalvik_system_VMRuntime.cc
@@ -27,9 +27,6 @@
#include "thread_list.h"
#include "toStringArray.h"
-extern "C" int dlmalloc_trim(size_t);
-extern "C" void dlmalloc_walk_free_pages(void(*)(void*, void*, void*), void*);
-
namespace art {
static jfloat VMRuntime_getTargetHeapUtilization(JNIEnv*, jobject) {
diff --git a/src/native/dalvik_system_VMStack.cc b/src/native/dalvik_system_VMStack.cc
index 3284c97..091ecd6 100644
--- a/src/native/dalvik_system_VMStack.cc
+++ b/src/native/dalvik_system_VMStack.cc
@@ -44,6 +44,10 @@
Runtime::Current()->GetThreadList()->Resume(thread, true);
return trace;
} else {
+ if (timeout) {
+ LOG(ERROR) << "Trying to get thread's stack failed as the thread failed to suspend within a "
+ "generous timeout.";
+ }
return NULL;
}
}
diff --git a/src/native/java_lang_Thread.cc b/src/native/java_lang_Thread.cc
index 65042e4..a0c90ee 100644
--- a/src/native/java_lang_Thread.cc
+++ b/src/native/java_lang_Thread.cc
@@ -106,18 +106,31 @@
}
}
-static void Thread_nativeSetName(JNIEnv* env, jobject java_thread, jstring java_name) {
- ScopedObjectAccess soa(env);
- MutexLock mu(*GlobalSynchronization::thread_list_lock_);
- Thread* thread = Thread::FromManagedThread(soa, java_thread);
- if (thread == NULL) {
- return;
- }
+static void Thread_nativeSetName(JNIEnv* env, jobject peer, jstring java_name) {
ScopedUtfChars name(env, java_name);
- if (name.c_str() == NULL) {
- return;
+ {
+ ScopedObjectAccess soa(env);
+ Thread* self = Thread::Current();
+ if (soa.Decode<Object*>(peer) == self->GetPeer()) {
+ self->SetThreadName(name.c_str());
+ return;
+ }
}
- thread->SetThreadName(name.c_str());
+ // Suspend thread to avoid it from killing itself while we set its name. We don't just hold the
+ // thread list lock to avoid this, as setting the thread name causes mutator to lock/unlock
+ // in the DDMS send code.
+ bool timeout;
+ Thread* thread = Thread::SuspendForDebugger(peer, true, &timeout);
+ if (thread != NULL) {
+ {
+ ScopedObjectAccess soa(env);
+ thread->SetThreadName(name.c_str());
+ }
+ Runtime::Current()->GetThreadList()->Resume(thread, true);
+ } else if (timeout) {
+ LOG(ERROR) << "Trying to set thread name to '" << name.c_str() << "' failed as the thread "
+ "failed to suspend within a generous timeout.";
+ }
}
/*
diff --git a/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
index b14d6ff..9bcea04 100644
--- a/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
+++ b/src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
@@ -90,6 +90,10 @@
Runtime::Current()->GetThreadList()->Resume(thread, true);
return Thread::InternalStackTraceToStackTraceElementArray(env, trace);
} else {
+ if (timeout) {
+ LOG(ERROR) << "Trying to get thread's stack by id failed as the thread failed to suspend "
+ "within a generous timeout.";
+ }
return NULL;
}
}