libcorkscrew native stacks, mutex ranking, and better ScopedThreadListLock.
This change uses libcorkscrew to show native stacks for threads in kNative or,
unlike dalvikvm, kVmWait --- working on the runtime directly I've found it
somewhat useful to be able to see _which_ internal resource we're waiting on.
We can always take that back out (or make it oatexecd-only) if it turns out to
be too noisy/confusing for app developers.
This change also lets us rank mutexes and enforce -- in oatexecd -- that you
take locks in a specific order.
Both of these helped me test the third novelty: removing the heap locking from
ScopedThreadListLock. I've manually inspected all the callers and added a
ScopedHeapLock where I think one is necessary. In manual testing, this makes
jdb a lot less prone to locking us up. There still seems to be a problem with
the JDWP VirtualMachine.Resume command, but I'll look at that separately. This
is a big enough and potentially disruptive enough change already.
Change-Id: Iad974358919d0e00674662dc8a69cc65878cfb5c
diff --git a/src/thread.h b/src/thread.h
index 7963091..02fa87c 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -161,9 +161,13 @@
return tid_;
}
- // Returns the java.lang.Thread's name, or NULL.
+ // Returns the java.lang.Thread's name, or NULL if this Thread* doesn't have a peer.
String* GetThreadName() const;
+ // Sets 'name' to the java.lang.Thread's name. This requires no transition to managed code,
+ // allocation, or locking.
+ void GetThreadName(std::string& name) const;
+
// Sets the thread's name.
void SetThreadName(const char* name);
@@ -418,6 +422,8 @@
return frame;
}
+ void CheckRank(MutexRank rank, bool is_locking);
+
private:
Thread();
~Thread();
@@ -428,6 +434,7 @@
void DumpState(std::ostream& os) const;
void DumpStack(std::ostream& os) const;
+ void DumpNativeStack(std::ostream& os) const;
// Out-of-line conveniences for debugging in gdb.
static Thread* CurrentFromGdb(); // Like Thread::Current.
@@ -563,6 +570,8 @@
// A cached copy of the java.lang.Thread's name.
std::string* name_;
+ uint32_t held_mutexes_[kMaxMutexRank + 1];
+
public:
// Runtime support function pointers
void (*pDebugMe)(Method*, uint32_t);