OSDN Git Service

ART: Dump referenced type in IRT overflows
authorAndreas Gampe <agampe@google.com>
Wed, 28 Sep 2016 01:45:02 +0000 (18:45 -0700)
committerAndreas Gampe <agampe@google.com>
Wed, 28 Sep 2016 01:45:02 +0000 (18:45 -0700)
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

runtime/reference_table.cc

index 49b6a38..d4bd6dd 100644 (file)
@@ -192,6 +192,13 @@ void ReferenceTable::Dump(std::ostream& os, Table& entries) {
       } 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";
   }