summaryrefslogtreecommitdiffstats
path: root/vm/Thread.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-06-07 16:39:20 -0700
committerElliott Hughes <enh@google.com>2011-06-07 16:39:20 -0700
commit708f143f318bb2167c810f9506102f4ad656545c (patch)
tree97e9b578ea7175f56a335cad1548bbf4ef0d0fbb /vm/Thread.cpp
parenta0f945f21dd38df48946fcea57d798a9692734b8 (diff)
downloadandroid_dalvik-708f143f318bb2167c810f9506102f4ad656545c.tar.gz
android_dalvik-708f143f318bb2167c810f9506102f4ad656545c.tar.bz2
android_dalvik-708f143f318bb2167c810f9506102f4ad656545c.zip
Improve "waiting on"/"waiting to lock" SIGQUIT dump info.
In particular, when we're waiting on a Class, say which class: I(16573) - waiting on <0xf5ed54f8> (java.lang.Class<java.lang.ref.ReferenceQueue>) versus: I(16573) - waiting on <0xf5feda38> (a java.util.LinkedList) Bug: http://code.google.com/p/android/issues/detail?id=17349 Change-Id: I844d02c008b1499adb02995ff3da25ba8cad0e0a
Diffstat (limited to 'vm/Thread.cpp')
-rw-r--r--vm/Thread.cpp35
1 files changed, 10 insertions, 25 deletions
diff --git a/vm/Thread.cpp b/vm/Thread.cpp
index 494731662..bef4bc623 100644
--- a/vm/Thread.cpp
+++ b/vm/Thread.cpp
@@ -554,10 +554,9 @@ void dvmSlayDaemons()
threadId, target->threadId);
}
- char* threadName = dvmGetThreadName(target);
+ std::string threadName(dvmGetThreadName(target));
LOGV("threadid=%d: suspending daemon id=%d name='%s'",
- threadId, target->threadId, threadName);
- free(threadName);
+ threadId, target->threadId, threadName.c_str());
/* mark as suspended */
lockThreadSuspendCount();
@@ -1455,9 +1454,8 @@ static void* interpThreadStart(void* arg)
{
Thread* self = (Thread*) arg;
- char *threadName = dvmGetThreadName(self);
- setThreadName(threadName);
- free(threadName);
+ std::string threadName(dvmGetThreadName(self));
+ setThreadName(threadName.c_str());
/*
* Finish initializing the Thread struct.
@@ -3121,13 +3119,11 @@ void dvmChangeThreadPriority(Thread* thread, int newPriority)
}
if (setpriority(PRIO_PROCESS, pid, newNice) != 0) {
- char* str = dvmGetThreadName(thread);
+ std::string threadName(dvmGetThreadName(thread));
LOGI("setPriority(%d) '%s' to prio=%d(n=%d) failed: %s",
- pid, str, newPriority, newNice, strerror(errno));
- free(str);
+ pid, threadName.c_str(), newPriority, newNice, strerror(errno));
} else {
- LOGV("setPriority(%d) to prio=%d(n=%d)",
- pid, newPriority, newNice);
+ LOGV("setPriority(%d) to prio=%d(n=%d)", pid, newPriority, newNice);
}
}
@@ -3414,24 +3410,13 @@ void dvmDumpThreadEx(const DebugOutputTarget* target, Thread* thread,
free(groupName);
}
-/*
- * Get the name of a thread.
- *
- * For correctness, the caller should hold the thread list lock to ensure
- * that the thread doesn't go away mid-call.
- *
- * Returns a newly-allocated string, or NULL if the Thread doesn't have a name.
- */
-char* dvmGetThreadName(Thread* thread)
-{
- StringObject* nameObj;
-
+std::string dvmGetThreadName(Thread* thread) {
if (thread->threadObj == NULL) {
LOGW("threadObj is NULL, name not available");
- return strdup("-unknown-");
+ return "-unknown-";
}
- nameObj = (StringObject*)
+ StringObject* nameObj = (StringObject*)
dvmGetFieldObject(thread->threadObj, gDvm.offJavaLangThread_name);
return dvmCreateCstrFromString(nameObj);
}