OSDN Git Service

Emit instance fields for java.lang.Object in hprof
authorMathieu Chartier <mathieuc@google.com>
Wed, 3 Jun 2015 17:51:13 +0000 (10:51 -0700)
committerMathieu Chartier <mathieuc@google.com>
Wed, 3 Jun 2015 18:08:37 +0000 (11:08 -0700)
Previously we omitted these fields.

(cherry picked from commit 0adc90eb0592e220f787f87dbef3a9b5c1db2080)

Bug: 20726205
Change-Id: I81c55919a4bd015bc0a4e7259a41a05dab534e11

runtime/hprof/hprof.cc

index 917fe43..922fc5f 100644 (file)
@@ -1040,7 +1040,7 @@ void Hprof::DumpHeapClass(mirror::Class* klass) {
   }
 
   // Instance fields for this class (no superclass fields)
-  int iFieldCount = klass->IsObjectClass() ? 0 : klass->NumInstanceFields();
+  int iFieldCount = klass->NumInstanceFields();
   if (klass->IsStringClass()) {
     __ AddU2((uint16_t)iFieldCount + 1);
   } else {
@@ -1114,7 +1114,7 @@ void Hprof::DumpHeapInstanceObject(mirror::Object* obj, mirror::Class* klass) {
   // Write the instance data;  fields for this class, followed by super class fields,
   // and so on. Don't write the klass or monitor fields of Object.class.
   mirror::Class* orig_klass = klass;
-  while (!klass->IsObjectClass()) {
+  do {
     int ifieldCount = klass->NumInstanceFields();
     for (int i = 0; i < ifieldCount; ++i) {
       ArtField* f = klass->GetInstanceField(i);
@@ -1146,7 +1146,7 @@ void Hprof::DumpHeapInstanceObject(mirror::Object* obj, mirror::Class* klass) {
     }
 
     klass = klass->GetSuperClass();
-  }
+  } while (klass != nullptr);
 
   // Output native value character array for strings.
   if (orig_klass->IsStringClass()) {