ART: Show invalid oat header cause in error message
Include the IsValid failure cause in the error message of opening
an oat file.
Make oat magic and version constexpr so we can have static_asserts
over the lengths.
Bug: 17187621
Change-Id: I8cef1c6cc9cb2faa052167a3437e81b4c2cbefa7
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index aa85ff0..1c6cc8b 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -227,7 +227,9 @@
bool OatFile::Setup(std::string* error_msg) {
if (!GetOatHeader().IsValid()) {
- *error_msg = StringPrintf("Invalid oat magic for '%s'", GetLocation().c_str());
+ std::string cause = GetOatHeader().GetValidationErrorMessage();
+ *error_msg = StringPrintf("Invalid oat header for '%s': %s", GetLocation().c_str(),
+ cause.c_str());
return false;
}
const uint8_t* oat = Begin();