image_space.cc revision 57309dbec7a119670bfae722f7399dd308042bbc
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "image_space.h" 18 19#include <random> 20 21#include "base/stl_util.h" 22#include "base/unix_file/fd_file.h" 23#include "base/scoped_flock.h" 24#include "gc/accounting/space_bitmap-inl.h" 25#include "mirror/art_method.h" 26#include "mirror/class-inl.h" 27#include "mirror/object-inl.h" 28#include "oat_file.h" 29#include "os.h" 30#include "space-inl.h" 31#include "utils.h" 32 33namespace art { 34namespace gc { 35namespace space { 36 37Atomic<uint32_t> ImageSpace::bitmap_index_(0); 38 39ImageSpace::ImageSpace(const std::string& image_filename, const char* image_location, 40 MemMap* mem_map, accounting::ContinuousSpaceBitmap* live_bitmap) 41 : MemMapSpace(image_filename, mem_map, mem_map->Begin(), mem_map->End(), mem_map->End(), 42 kGcRetentionPolicyNeverCollect), 43 image_location_(image_location) { 44 DCHECK(live_bitmap != nullptr); 45 live_bitmap_.reset(live_bitmap); 46} 47 48static int32_t ChooseRelocationOffsetDelta(int32_t min_delta, int32_t max_delta) { 49 CHECK_ALIGNED(min_delta, kPageSize); 50 CHECK_ALIGNED(max_delta, kPageSize); 51 CHECK_LT(min_delta, max_delta); 52 53 std::default_random_engine generator; 54 generator.seed(NanoTime() * getpid()); 55 std::uniform_int_distribution<int32_t> distribution(min_delta, max_delta); 56 int32_t r = distribution(generator); 57 if (r % 2 == 0) { 58 r = RoundUp(r, kPageSize); 59 } else { 60 r = RoundDown(r, kPageSize); 61 } 62 CHECK_LE(min_delta, r); 63 CHECK_GE(max_delta, r); 64 CHECK_ALIGNED(r, kPageSize); 65 return r; 66} 67 68static bool GenerateImage(const std::string& image_filename, std::string* error_msg) { 69 const std::string boot_class_path_string(Runtime::Current()->GetBootClassPathString()); 70 std::vector<std::string> boot_class_path; 71 Split(boot_class_path_string, ':', boot_class_path); 72 if (boot_class_path.empty()) { 73 *error_msg = "Failed to generate image because no boot class path specified"; 74 return false; 75 } 76 77 std::vector<std::string> arg_vector; 78 79 std::string dex2oat(Runtime::Current()->GetCompilerExecutable()); 80 arg_vector.push_back(dex2oat); 81 82 std::string image_option_string("--image="); 83 image_option_string += image_filename; 84 arg_vector.push_back(image_option_string); 85 86 for (size_t i = 0; i < boot_class_path.size(); i++) { 87 arg_vector.push_back(std::string("--dex-file=") + boot_class_path[i]); 88 } 89 90 std::string oat_file_option_string("--oat-file="); 91 oat_file_option_string += image_filename; 92 oat_file_option_string.erase(oat_file_option_string.size() - 3); 93 oat_file_option_string += "oat"; 94 arg_vector.push_back(oat_file_option_string); 95 96 Runtime::Current()->AddCurrentRuntimeFeaturesAsDex2OatArguments(&arg_vector); 97 98 int32_t base_offset = ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA, 99 ART_BASE_ADDRESS_MAX_DELTA); 100 LOG(INFO) << "Using an offset of 0x" << std::hex << base_offset << " from default " 101 << "art base address of 0x" << std::hex << ART_BASE_ADDRESS; 102 arg_vector.push_back(StringPrintf("--base=0x%x", ART_BASE_ADDRESS + base_offset)); 103 104 if (!kIsTargetBuild) { 105 arg_vector.push_back("--host"); 106 } 107 108 const std::vector<std::string>& compiler_options = Runtime::Current()->GetImageCompilerOptions(); 109 for (size_t i = 0; i < compiler_options.size(); ++i) { 110 arg_vector.push_back(compiler_options[i].c_str()); 111 } 112 113 std::string command_line(Join(arg_vector, ' ')); 114 LOG(INFO) << "GenerateImage: " << command_line; 115 return Exec(arg_vector, error_msg); 116} 117 118bool ImageSpace::FindImageFilename(const char* image_location, 119 const InstructionSet image_isa, 120 std::string* system_filename, 121 bool* has_system, 122 std::string* cache_filename, 123 bool* dalvik_cache_exists, 124 bool* has_cache) { 125 *has_system = false; 126 *has_cache = false; 127 // image_location = /system/framework/boot.art 128 // system_image_location = /system/framework/<image_isa>/boot.art 129 std::string system_image_filename(GetSystemImageFilename(image_location, image_isa)); 130 if (OS::FileExists(system_image_filename.c_str())) { 131 *system_filename = system_image_filename; 132 *has_system = true; 133 } 134 135 bool have_android_data = false; 136 *dalvik_cache_exists = false; 137 std::string dalvik_cache; 138 GetDalvikCache(GetInstructionSetString(image_isa), true, &dalvik_cache, 139 &have_android_data, dalvik_cache_exists); 140 141 if (have_android_data && *dalvik_cache_exists) { 142 // Always set output location even if it does not exist, 143 // so that the caller knows where to create the image. 144 // 145 // image_location = /system/framework/boot.art 146 // *image_filename = /data/dalvik-cache/<image_isa>/boot.art 147 std::string error_msg; 148 if (!GetDalvikCacheFilename(image_location, dalvik_cache.c_str(), cache_filename, &error_msg)) { 149 LOG(WARNING) << error_msg; 150 return *has_system; 151 } 152 *has_cache = OS::FileExists(cache_filename->c_str()); 153 } 154 return *has_system || *has_cache; 155} 156 157static bool ReadSpecificImageHeader(const char* filename, ImageHeader* image_header) { 158 std::unique_ptr<File> image_file(OS::OpenFileForReading(filename)); 159 if (image_file.get() == nullptr) { 160 return false; 161 } 162 const bool success = image_file->ReadFully(image_header, sizeof(ImageHeader)); 163 if (!success || !image_header->IsValid()) { 164 return false; 165 } 166 return true; 167} 168 169bool ImageSpace::RelocateImage(const char* image_location, const char* dest_filename, 170 InstructionSet isa, std::string* error_msg) { 171 std::string patchoat(Runtime::Current()->GetPatchoatExecutable()); 172 173 std::string input_image_location_arg("--input-image-location="); 174 input_image_location_arg += image_location; 175 176 std::string output_image_filename_arg("--output-image-file="); 177 output_image_filename_arg += dest_filename; 178 179 std::string input_oat_location_arg("--input-oat-location="); 180 input_oat_location_arg += ImageHeader::GetOatLocationFromImageLocation(image_location); 181 182 std::string output_oat_filename_arg("--output-oat-file="); 183 output_oat_filename_arg += ImageHeader::GetOatLocationFromImageLocation(dest_filename); 184 185 std::string instruction_set_arg("--instruction-set="); 186 instruction_set_arg += GetInstructionSetString(isa); 187 188 std::string base_offset_arg("--base-offset-delta="); 189 StringAppendF(&base_offset_arg, "%d", ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA, 190 ART_BASE_ADDRESS_MAX_DELTA)); 191 192 std::vector<std::string> argv; 193 argv.push_back(patchoat); 194 195 argv.push_back(input_image_location_arg); 196 argv.push_back(output_image_filename_arg); 197 198 argv.push_back(input_oat_location_arg); 199 argv.push_back(output_oat_filename_arg); 200 201 argv.push_back(instruction_set_arg); 202 argv.push_back(base_offset_arg); 203 204 std::string command_line(Join(argv, ' ')); 205 LOG(INFO) << "RelocateImage: " << command_line; 206 return Exec(argv, error_msg); 207} 208 209static ImageHeader* ReadSpecificImageHeaderOrDie(const char* filename) { 210 std::unique_ptr<ImageHeader> hdr(new ImageHeader); 211 if (!ReadSpecificImageHeader(filename, hdr.get())) { 212 LOG(FATAL) << "Unable to read image header for " << filename; 213 return nullptr; 214 } 215 return hdr.release(); 216} 217 218ImageHeader* ImageSpace::ReadImageHeaderOrDie(const char* image_location, 219 const InstructionSet image_isa) { 220 std::string system_filename; 221 bool has_system = false; 222 std::string cache_filename; 223 bool has_cache = false; 224 bool dalvik_cache_exists = false; 225 if (FindImageFilename(image_location, image_isa, &system_filename, &has_system, 226 &cache_filename, &dalvik_cache_exists, &has_cache)) { 227 if (Runtime::Current()->ShouldRelocate()) { 228 if (has_system && has_cache) { 229 std::unique_ptr<ImageHeader> sys_hdr(new ImageHeader); 230 std::unique_ptr<ImageHeader> cache_hdr(new ImageHeader); 231 if (!ReadSpecificImageHeader(system_filename.c_str(), sys_hdr.get())) { 232 LOG(FATAL) << "Unable to read image header for " << image_location << " at " 233 << system_filename; 234 return nullptr; 235 } 236 if (!ReadSpecificImageHeader(cache_filename.c_str(), cache_hdr.get())) { 237 LOG(FATAL) << "Unable to read image header for " << image_location << " at " 238 << cache_filename; 239 return nullptr; 240 } 241 if (sys_hdr->GetOatChecksum() != cache_hdr->GetOatChecksum()) { 242 LOG(FATAL) << "Unable to find a relocated version of image file " << image_location; 243 return nullptr; 244 } 245 return cache_hdr.release(); 246 } else if (!has_cache) { 247 LOG(FATAL) << "Unable to find a relocated version of image file " << image_location; 248 return nullptr; 249 } else if (!has_system && has_cache) { 250 // This can probably just use the cache one. 251 return ReadSpecificImageHeaderOrDie(cache_filename.c_str()); 252 } 253 } else { 254 // We don't want to relocate, Just pick the appropriate one if we have it and return. 255 if (has_system && has_cache) { 256 // We want the cache if the checksum matches, otherwise the system. 257 std::unique_ptr<ImageHeader> system(ReadSpecificImageHeaderOrDie(system_filename.c_str())); 258 std::unique_ptr<ImageHeader> cache(ReadSpecificImageHeaderOrDie(cache_filename.c_str())); 259 if (system.get() == nullptr || 260 (cache.get() != nullptr && cache->GetOatChecksum() == system->GetOatChecksum())) { 261 return cache.release(); 262 } else { 263 return system.release(); 264 } 265 } else if (has_system) { 266 return ReadSpecificImageHeaderOrDie(system_filename.c_str()); 267 } else if (has_cache) { 268 return ReadSpecificImageHeaderOrDie(cache_filename.c_str()); 269 } 270 } 271 } 272 273 LOG(FATAL) << "Unable to find image file for: " << image_location; 274 return nullptr; 275} 276 277static bool ChecksumsMatch(const char* image_a, const char* image_b) { 278 ImageHeader hdr_a; 279 ImageHeader hdr_b; 280 return ReadSpecificImageHeader(image_a, &hdr_a) && ReadSpecificImageHeader(image_b, &hdr_b) 281 && hdr_a.GetOatChecksum() == hdr_b.GetOatChecksum(); 282} 283 284ImageSpace* ImageSpace::Create(const char* image_location, 285 const InstructionSet image_isa) { 286 std::string error_msg; 287 std::string system_filename; 288 bool has_system = false; 289 std::string cache_filename; 290 bool has_cache = false; 291 bool dalvik_cache_exists = false; 292 const bool found_image = FindImageFilename(image_location, image_isa, &system_filename, 293 &has_system, &cache_filename, &dalvik_cache_exists, 294 &has_cache); 295 296 ImageSpace* space; 297 bool relocate = Runtime::Current()->ShouldRelocate(); 298 if (found_image) { 299 const std::string* image_filename; 300 bool is_system = false; 301 bool relocated_version_used = false; 302 if (relocate) { 303 CHECK(dalvik_cache_exists) << "Requiring relocation for image " << image_location << " " 304 << "at " << system_filename << " but we do not have any " 305 << "dalvik_cache to find/place it in."; 306 if (has_system) { 307 if (has_cache && ChecksumsMatch(system_filename.c_str(), cache_filename.c_str())) { 308 // We already have a relocated version 309 image_filename = &cache_filename; 310 relocated_version_used = true; 311 } else { 312 // We cannot have a relocated version, Relocate the system one and use it. 313 if (RelocateImage(image_location, cache_filename.c_str(), image_isa, 314 &error_msg)) { 315 relocated_version_used = true; 316 image_filename = &cache_filename; 317 } else { 318 LOG(FATAL) << "Unable to relocate image " << image_location << " " 319 << "from " << system_filename << " to " << cache_filename << ": " 320 << error_msg; 321 return nullptr; 322 } 323 } 324 } else { 325 CHECK(has_cache); 326 // We can just use cache's since it should be fine. This might or might not be relocated. 327 image_filename = &cache_filename; 328 } 329 } else { 330 if (has_system && has_cache) { 331 // Check they have the same cksum. If they do use the cache. Otherwise system. 332 if (ChecksumsMatch(system_filename.c_str(), cache_filename.c_str())) { 333 image_filename = &cache_filename; 334 relocated_version_used = true; 335 } else { 336 image_filename = &system_filename; 337 } 338 } else if (has_system) { 339 image_filename = &system_filename; 340 } else { 341 CHECK(has_cache); 342 image_filename = &cache_filename; 343 } 344 } 345 { 346 // Note that we must not use the file descriptor associated with 347 // ScopedFlock::GetFile to Init the image file. We want the file 348 // descriptor (and the associated exclusive lock) to be released when 349 // we leave Create. 350 ScopedFlock image_lock; 351 image_lock.Init(image_filename->c_str(), &error_msg); 352 LOG(INFO) << "Using image file " << image_filename->c_str() << " for image location " 353 << image_location; 354 space = ImageSpace::Init(image_filename->c_str(), image_location, 355 false, &error_msg); 356 } 357 if (space != nullptr) { 358 return space; 359 } 360 361 // If the /system file exists, it should be up-to-date, don't try to generate it. Same if it is 362 // a relocated copy from something in /system (i.e. checksum's match). 363 // Otherwise, log a warning and fall through to GenerateImage. 364 if (relocated_version_used) { 365 LOG(FATAL) << "Attempted to use relocated version of " << image_location << " " 366 << "at " << cache_filename << " generated from " << system_filename << " " 367 << "but image failed to load: " << error_msg; 368 return nullptr; 369 } else if (is_system) { 370 LOG(FATAL) << "Failed to load /system image '" << *image_filename << "': " << error_msg; 371 return nullptr; 372 } else { 373 LOG(WARNING) << error_msg; 374 } 375 } 376 377 CHECK(dalvik_cache_exists) << "No place to put generated image."; 378 CHECK(GenerateImage(cache_filename, &error_msg)) 379 << "Failed to generate image '" << cache_filename << "': " << error_msg; 380 { 381 // Note that we must not use the file descriptor associated with 382 // ScopedFlock::GetFile to Init the image file. We want the file 383 // descriptor (and the associated exclusive lock) to be released when 384 // we leave Create. 385 ScopedFlock image_lock; 386 image_lock.Init(cache_filename.c_str(), &error_msg); 387 space = ImageSpace::Init(cache_filename.c_str(), image_location, true, &error_msg); 388 } 389 if (space == nullptr) { 390 LOG(FATAL) << "Failed to load generated image '" << cache_filename << "': " << error_msg; 391 } 392 return space; 393} 394 395void ImageSpace::VerifyImageAllocations() { 396 byte* current = Begin() + RoundUp(sizeof(ImageHeader), kObjectAlignment); 397 while (current < End()) { 398 DCHECK_ALIGNED(current, kObjectAlignment); 399 mirror::Object* obj = reinterpret_cast<mirror::Object*>(current); 400 CHECK(live_bitmap_->Test(obj)); 401 CHECK(obj->GetClass() != nullptr) << "Image object at address " << obj << " has null class"; 402 if (kUseBakerOrBrooksReadBarrier) { 403 obj->AssertReadBarrierPointer(); 404 } 405 current += RoundUp(obj->SizeOf(), kObjectAlignment); 406 } 407} 408 409ImageSpace* ImageSpace::Init(const char* image_filename, const char* image_location, 410 bool validate_oat_file, std::string* error_msg) { 411 CHECK(image_filename != nullptr); 412 CHECK(image_location != nullptr); 413 414 uint64_t start_time = 0; 415 if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) { 416 start_time = NanoTime(); 417 LOG(INFO) << "ImageSpace::Init entering image_filename=" << image_filename; 418 } 419 420 std::unique_ptr<File> file(OS::OpenFileForReading(image_filename)); 421 if (file.get() == NULL) { 422 *error_msg = StringPrintf("Failed to open '%s'", image_filename); 423 return nullptr; 424 } 425 ImageHeader image_header; 426 bool success = file->ReadFully(&image_header, sizeof(image_header)); 427 if (!success || !image_header.IsValid()) { 428 *error_msg = StringPrintf("Invalid image header in '%s'", image_filename); 429 return nullptr; 430 } 431 432 // Note: The image header is part of the image due to mmap page alignment required of offset. 433 std::unique_ptr<MemMap> map(MemMap::MapFileAtAddress(image_header.GetImageBegin(), 434 image_header.GetImageSize(), 435 PROT_READ | PROT_WRITE, 436 MAP_PRIVATE, 437 file->Fd(), 438 0, 439 false, 440 image_filename, 441 error_msg)); 442 if (map.get() == NULL) { 443 DCHECK(!error_msg->empty()); 444 return nullptr; 445 } 446 CHECK_EQ(image_header.GetImageBegin(), map->Begin()); 447 DCHECK_EQ(0, memcmp(&image_header, map->Begin(), sizeof(ImageHeader))); 448 449 std::unique_ptr<MemMap> image_map(MemMap::MapFileAtAddress(nullptr, image_header.GetImageBitmapSize(), 450 PROT_READ, MAP_PRIVATE, 451 file->Fd(), image_header.GetBitmapOffset(), 452 false, 453 image_filename, 454 error_msg)); 455 if (image_map.get() == nullptr) { 456 *error_msg = StringPrintf("Failed to map image bitmap: %s", error_msg->c_str()); 457 return nullptr; 458 } 459 uint32_t bitmap_index = bitmap_index_.FetchAndAddSequentiallyConsistent(1); 460 std::string bitmap_name(StringPrintf("imagespace %s live-bitmap %u", image_filename, 461 bitmap_index)); 462 std::unique_ptr<accounting::ContinuousSpaceBitmap> bitmap( 463 accounting::ContinuousSpaceBitmap::CreateFromMemMap(bitmap_name, image_map.release(), 464 reinterpret_cast<byte*>(map->Begin()), 465 map->Size())); 466 if (bitmap.get() == nullptr) { 467 *error_msg = StringPrintf("Could not create bitmap '%s'", bitmap_name.c_str()); 468 return nullptr; 469 } 470 471 std::unique_ptr<ImageSpace> space(new ImageSpace(image_filename, image_location, 472 map.release(), bitmap.release())); 473 474 // VerifyImageAllocations() will be called later in Runtime::Init() 475 // as some class roots like ArtMethod::java_lang_reflect_ArtMethod_ 476 // and ArtField::java_lang_reflect_ArtField_, which are used from 477 // Object::SizeOf() which VerifyImageAllocations() calls, are not 478 // set yet at this point. 479 480 space->oat_file_.reset(space->OpenOatFile(image_filename, error_msg)); 481 if (space->oat_file_.get() == nullptr) { 482 DCHECK(!error_msg->empty()); 483 return nullptr; 484 } 485 486 if (validate_oat_file && !space->ValidateOatFile(error_msg)) { 487 DCHECK(!error_msg->empty()); 488 return nullptr; 489 } 490 491 Runtime* runtime = Runtime::Current(); 492 runtime->SetInstructionSet(space->oat_file_->GetOatHeader().GetInstructionSet()); 493 494 mirror::Object* resolution_method = image_header.GetImageRoot(ImageHeader::kResolutionMethod); 495 runtime->SetResolutionMethod(down_cast<mirror::ArtMethod*>(resolution_method)); 496 mirror::Object* imt_conflict_method = image_header.GetImageRoot(ImageHeader::kImtConflictMethod); 497 runtime->SetImtConflictMethod(down_cast<mirror::ArtMethod*>(imt_conflict_method)); 498 mirror::Object* default_imt = image_header.GetImageRoot(ImageHeader::kDefaultImt); 499 runtime->SetDefaultImt(down_cast<mirror::ObjectArray<mirror::ArtMethod>*>(default_imt)); 500 501 mirror::Object* callee_save_method = image_header.GetImageRoot(ImageHeader::kCalleeSaveMethod); 502 runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kSaveAll); 503 callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsOnlySaveMethod); 504 runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kRefsOnly); 505 callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsAndArgsSaveMethod); 506 runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kRefsAndArgs); 507 508 if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) { 509 LOG(INFO) << "ImageSpace::Init exiting (" << PrettyDuration(NanoTime() - start_time) 510 << ") " << *space.get(); 511 } 512 return space.release(); 513} 514 515OatFile* ImageSpace::OpenOatFile(const char* image_path, std::string* error_msg) const { 516 const ImageHeader& image_header = GetImageHeader(); 517 std::string oat_filename = ImageHeader::GetOatLocationFromImageLocation(image_path); 518 519 OatFile* oat_file = OatFile::Open(oat_filename, oat_filename, image_header.GetOatDataBegin(), 520 !Runtime::Current()->IsCompiler(), error_msg); 521 if (oat_file == NULL) { 522 *error_msg = StringPrintf("Failed to open oat file '%s' referenced from image %s: %s", 523 oat_filename.c_str(), GetName(), error_msg->c_str()); 524 return nullptr; 525 } 526 uint32_t oat_checksum = oat_file->GetOatHeader().GetChecksum(); 527 uint32_t image_oat_checksum = image_header.GetOatChecksum(); 528 if (oat_checksum != image_oat_checksum) { 529 *error_msg = StringPrintf("Failed to match oat file checksum 0x%x to expected oat checksum 0x%x" 530 " in image %s", oat_checksum, image_oat_checksum, GetName()); 531 return nullptr; 532 } 533 int32_t image_patch_delta = image_header.GetPatchDelta(); 534 int32_t oat_patch_delta = oat_file->GetOatHeader().GetImagePatchDelta(); 535 if (oat_patch_delta != image_patch_delta) { 536 // We should have already relocated by this point. Bail out. 537 *error_msg = StringPrintf("Failed to match oat file patch delta %d to expected patch delta %d " 538 "in image %s", oat_patch_delta, image_patch_delta, GetName()); 539 return nullptr; 540 } 541 542 return oat_file; 543} 544 545bool ImageSpace::ValidateOatFile(std::string* error_msg) const { 546 CHECK(oat_file_.get() != NULL); 547 for (const OatFile::OatDexFile* oat_dex_file : oat_file_->GetOatDexFiles()) { 548 const std::string& dex_file_location = oat_dex_file->GetDexFileLocation(); 549 uint32_t dex_file_location_checksum; 550 if (!DexFile::GetChecksum(dex_file_location.c_str(), &dex_file_location_checksum, error_msg)) { 551 *error_msg = StringPrintf("Failed to get checksum of dex file '%s' referenced by image %s: " 552 "%s", dex_file_location.c_str(), GetName(), error_msg->c_str()); 553 return false; 554 } 555 if (dex_file_location_checksum != oat_dex_file->GetDexFileLocationChecksum()) { 556 *error_msg = StringPrintf("ValidateOatFile found checksum mismatch between oat file '%s' and " 557 "dex file '%s' (0x%x != 0x%x)", 558 oat_file_->GetLocation().c_str(), dex_file_location.c_str(), 559 oat_dex_file->GetDexFileLocationChecksum(), 560 dex_file_location_checksum); 561 return false; 562 } 563 } 564 return true; 565} 566 567const OatFile* ImageSpace::GetOatFile() const { 568 return oat_file_.get(); 569} 570 571OatFile* ImageSpace::ReleaseOatFile() { 572 CHECK(oat_file_.get() != NULL); 573 return oat_file_.release(); 574} 575 576void ImageSpace::Dump(std::ostream& os) const { 577 os << GetType() 578 << " begin=" << reinterpret_cast<void*>(Begin()) 579 << ",end=" << reinterpret_cast<void*>(End()) 580 << ",size=" << PrettySize(Size()) 581 << ",name=\"" << GetName() << "\"]"; 582} 583 584} // namespace space 585} // namespace gc 586} // namespace art 587