ART: Print debug info in test 913
In case we find an unexpected thread root, dump all stacks.
Bug: 31385354
Test: m test-art-host-run-test-913-heaps
Change-Id: I62635950d5afe639d0f86f2b436809d75375956f
diff --git a/test/913-heaps/heaps.cc b/test/913-heaps/heaps.cc
index 4087abd..0c627d6 100644
--- a/test/913-heaps/heaps.cc
+++ b/test/913-heaps/heaps.cc
@@ -27,9 +27,11 @@
#include "base/stringprintf.h"
#include "jit/jit.h"
#include "jni.h"
+#include "native_stack_dump.h"
#include "openjdkjvmti/jvmti.h"
#include "runtime.h"
#include "thread-inl.h"
+#include "thread_list.h"
#include "ti-agent/common_helper.h"
#include "ti-agent/common_load.h"
@@ -191,6 +193,20 @@
class_tag,
adapted_size,
length));
+
+ if (reference_kind == JVMTI_HEAP_REFERENCE_THREAD && *tag_ptr == 1000) {
+ DumpStacks();
+ }
+ }
+
+ static void DumpStacks() NO_THREAD_SAFETY_ANALYSIS {
+ auto dump_function = [](art::Thread* t, void* data ATTRIBUTE_UNUSED) {
+ std::string name;
+ t->GetThreadName(name);
+ LOG(ERROR) << name;
+ art::DumpNativeStack(LOG_STREAM(ERROR), t->GetTid());
+ };
+ art::Runtime::Current()->GetThreadList()->ForEach(dump_function, nullptr);
}
static std::string GetReferenceTypeStr(jvmtiHeapReferenceKind reference_kind,