Rosalloc should print unreachable page map type
When rosalloc receives unexpected page map type, it is not
printed in error message because it has 'byte' type. When printed
to LOG(FATAL), it is interpreted as symbol (usually unprintable).
This patch allows to see unexpected page map types as integers.
Change-Id: Ic9d472f933862f4e2671904277990d8a83bc4c89
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc
index 0cea89d..a3da532 100644
--- a/runtime/gc/allocator/rosalloc.cc
+++ b/runtime/gc/allocator/rosalloc.cc
@@ -264,7 +264,7 @@
}
break;
default:
- LOG(FATAL) << "Unreachable - page map type: " << page_map_type;
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(page_map_type);
break;
}
if (kIsDebugBuild) {
@@ -499,7 +499,7 @@
case kPageMapLargeObject:
return FreePages(self, ptr, false);
case kPageMapLargeObjectPart:
- LOG(FATAL) << "Unreachable - page map type: " << page_map_[pm_idx];
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(page_map_[pm_idx]);
return 0;
case kPageMapRunPart: {
// Find the beginning of the run.
@@ -514,11 +514,11 @@
break;
case kPageMapReleased:
case kPageMapEmpty:
- LOG(FATAL) << "Unreachable - page map type: " << page_map_[pm_idx];
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(page_map_[pm_idx]);
return 0;
}
default:
- LOG(FATAL) << "Unreachable - page map type: " << page_map_[pm_idx];
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(page_map_[pm_idx]);
return 0;
}
}
@@ -1189,7 +1189,7 @@
freed_bytes += FreePages(self, ptr, false);
continue;
} else {
- LOG(FATAL) << "Unreachable - page map type: " << page_map_entry;
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(page_map_entry);
}
} else {
// Read the page map entries with a lock.
@@ -1215,7 +1215,7 @@
freed_bytes += FreePages(self, ptr, false);
continue;
} else {
- LOG(FATAL) << "Unreachable - page map type: " << page_map_entry;
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(page_map_entry);
}
}
DCHECK(run != nullptr);
@@ -1477,7 +1477,7 @@
return IndexToBracketSize(idx);
}
default: {
- LOG(FATAL) << "Unreachable - page map type: " << page_map_[pm_idx];
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(page_map_[pm_idx]);
break;
}
}
@@ -1593,7 +1593,7 @@
break;
}
case kPageMapLargeObjectPart:
- LOG(FATAL) << "Unreachable - page map type: " << pm;
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(pm);
break;
case kPageMapRun: {
// The start of a run.
@@ -1613,10 +1613,10 @@
break;
}
case kPageMapRunPart:
- LOG(FATAL) << "Unreachable - page map type: " << pm;
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(pm);
break;
default:
- LOG(FATAL) << "Unreachable - page map type: " << pm;
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(pm);
break;
}
}
@@ -1929,7 +1929,7 @@
break;
}
case kPageMapLargeObjectPart:
- LOG(FATAL) << "Unreachable - page map type: " << pm << std::endl << DumpPageMap();
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(pm) << std::endl << DumpPageMap();
break;
case kPageMapRun: {
// The start of a run.
@@ -1957,7 +1957,7 @@
case kPageMapRunPart:
// Fall-through.
default:
- LOG(FATAL) << "Unreachable - page map type: " << pm << std::endl << DumpPageMap();
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(pm) << std::endl << DumpPageMap();
break;
}
}
@@ -2146,7 +2146,7 @@
++i;
break; // Skip.
default:
- LOG(FATAL) << "Unreachable - page map type: " << pm;
+ LOG(FATAL) << "Unreachable - page map type: " << static_cast<int>(pm);
break;
}
}