ART: Dump referenced type in IRT overflows

When the runtime dumps a reference table, e.g., when aborting for
an overflow, dump the type of stored referents for reference types
to aid in debugging leaks.

Bug: 31600693
Change-Id: Ia892dc84ca8827dd93a8b75d6f571c392f94859c
diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc
index 49b6a38..d4bd6dd 100644
--- a/runtime/reference_table.cc
+++ b/runtime/reference_table.cc
@@ -192,6 +192,13 @@
       } else {
         StringAppendF(&extras, " \"%.16s... (%d chars)", utf8.c_str(), s->GetLength());
       }
+    } else if (ref->IsReferenceInstance()) {
+      mirror::Object* referent = ref->AsReference()->GetReferent();
+      if (referent == nullptr) {
+        extras = " (storing null)";
+      } else {
+        extras = StringPrintf(" (storing a %s)", PrettyTypeOf(referent).c_str());
+      }
     }
     os << StringPrintf("    %5d: ", idx) << ref << " " << className << extras << "\n";
   }