Add a debug check for unsaved callee-save register for diagnosis.
Bug: 29231980
Bug: 12687968
Test: test-art-host with CC.
Change-Id: I385ce7712e63072a0664d86414605d23ef44401b
diff --git a/runtime/thread.cc b/runtime/thread.cc
index dde3640..43ef1cb 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -2835,6 +2835,14 @@
for (size_t i = 0; i < BitSizeOf<uint32_t>(); ++i) {
if (register_mask & (1 << i)) {
mirror::Object** ref_addr = reinterpret_cast<mirror::Object**>(GetGPRAddress(i));
+ if (kIsDebugBuild && ref_addr == nullptr) {
+ std::string thread_name;
+ GetThread()->GetThreadName(thread_name);
+ LOG(INTERNAL_FATAL) << "On thread " << thread_name;
+ DescribeStack(GetThread());
+ LOG(FATAL) << "Found an unsaved callee-save register " << i << " (null GPRAddress) "
+ << "set in register_mask=" << register_mask << " at " << DescribeLocation();
+ }
if (*ref_addr != nullptr) {
visitor_(ref_addr, -1, this);
}