ahat: add support for parsing 0x0C HEAP DUMP record

Test: m ahat-test
Test: manually launch ahat on the heap dump from the bug that uses the
      0x0C HEAP DUMP record.
Bug: 111147686
Change-Id: Ibf779c4e066f14777c1931ae76b2b9f64dba27b9
diff --git a/tools/ahat/src/main/com/android/ahat/heapdump/Parser.java b/tools/ahat/src/main/com/android/ahat/heapdump/Parser.java
index fe12c0c..4e7cd43 100644
--- a/tools/ahat/src/main/com/android/ahat/heapdump/Parser.java
+++ b/tools/ahat/src/main/com/android/ahat/heapdump/Parser.java
@@ -274,13 +274,15 @@
             break;
           }
 
+          case 0x0C:   // HEAP DUMP
           case 0x1C: { // HEAP DUMP SEGMENT
+            int endOfRecord = hprof.tell() + recordLength;
             if (classById == null) {
               classById = new Instances<AhatClassObj>(classes);
             }
-            int subtag;
-            while (!isEndOfHeapDumpSegment(subtag = hprof.getU1())) {
+            while (hprof.tell() < endOfRecord) {
               progress.update(hprof.tell());
+              int subtag = hprof.getU1();
               switch (subtag) {
                 case 0x01: { // ROOT JNI GLOBAL
                   long objectId = hprof.getId();
@@ -561,10 +563,6 @@
                       String.format("Unsupported heap dump sub tag 0x%02x", subtag));
               }
             }
-
-            // Reset the file pointer back because we read the first byte into
-            // the next record.
-            hprof.skip(-1);
             break;
           }
 
@@ -675,10 +673,6 @@
     return new AhatSnapshot(superRoot, mInstances, heaps.heaps, rootSite, progress, retained);
   }
 
-  private static boolean isEndOfHeapDumpSegment(int subtag) {
-    return subtag == 0x1C || subtag == 0x2C;
-  }
-
   private static class RootData {
     public long id;
     public RootType type;