Annotate References with their referent.
Also, don't include annotations in an object's link. That way we can
distinguish between the object link and any links in the annotations.
Change-Id: I3fef3f5b2c343699f527cad9efa7c93a4b35a3a4
diff --git a/tools/ahat/src/Value.java b/tools/ahat/src/Value.java
index 4eb27b1..7c969b3 100644
--- a/tools/ahat/src/Value.java
+++ b/tools/ahat/src/Value.java
@@ -45,25 +45,36 @@
}
link.append(inst.toString());
+ URI objTarget = DocString.formattedUri("object?id=%d", inst.getId());
+ DocString formatted = DocString.link(objTarget, link);
// Annotate Strings with their values.
String stringValue = InstanceUtils.asString(inst, kMaxChars);
if (stringValue != null) {
- link.appendFormat("\"%s", stringValue);
- link.append(kMaxChars == stringValue.length() ? "..." : "\"");
+ formatted.appendFormat(" \"%s", stringValue);
+ formatted.append(kMaxChars == stringValue.length() ? "..." : "\"");
+ }
+
+ // Annotate Reference with its referent
+ Instance referent = InstanceUtils.getReferent(inst);
+ if (referent != null) {
+ formatted.append(" for ");
+
+ // It should not be possible for a referent to refer back to the
+ // reference object, even indirectly, so there shouldn't be any issues
+ // with infinite recursion here.
+ formatted.append(renderInstance(referent));
}
// Annotate DexCache with its location.
String dexCacheLocation = InstanceUtils.getDexCacheLocation(inst, kMaxChars);
if (dexCacheLocation != null) {
- link.appendFormat(" for %s", dexCacheLocation);
+ formatted.appendFormat(" for %s", dexCacheLocation);
if (kMaxChars == dexCacheLocation.length()) {
- link.append("...");
+ formatted.append("...");
}
}
- URI objTarget = DocString.formattedUri("object?id=%d", inst.getId());
- DocString formatted = DocString.link(objTarget, link);
// Annotate bitmaps with a thumbnail.
Instance bitmap = InstanceUtils.getAssociatedBitmapInstance(inst);