Improve the location of the input vdex, for debugging.
Also comment that it's confusing when the input vdex is given by fd.
Test: Check logcat output from `adb shell pm bg-dexopt-job`
Bug: 256664509
Change-Id: Ib7fd3944657b30a57d354aceb8104f688bb1efa2
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index f4c3e2a..acc6267 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -128,6 +128,7 @@
static constexpr size_t kDefaultMinDexFilesForSwap = 2;
static constexpr size_t kDefaultMinDexFileCumulativeSizeForSwap = 20 * MB;
+static constexpr char kInputVdexPlaceholderName[] = "vdex";
// Compiler filter override for very large apps.
static constexpr CompilerFilter::Filter kLargeAppFilter = CompilerFilter::kVerify;
@@ -695,7 +696,7 @@
}
if ((image_fd_ != -1) && (oat_fd_ == -1)) {
- Usage("--image-fd must be used with --oat_fd and --output_vdex_fd");
+ Usage("--image-fd must be used with --oat-fd and --output-vdex-fd");
}
if (!parser_options->oat_symbols.empty() && oat_fd_ != -1) {
@@ -1336,7 +1337,7 @@
std::string error_msg;
input_vdex_file_ = VdexFile::Open(input_vdex_fd_,
s.st_size,
- "vdex",
+ kInputVdexPlaceholderName,
/* writable */ false,
/* low_4gb */ false,
&error_msg);
@@ -2616,7 +2617,12 @@
TimingLogger::ScopedTiming t2("AddDexFileSources", timings_);
if (input_vdex_file_ != nullptr && input_vdex_file_->HasDexSection()) {
DCHECK_EQ(oat_writers_.size(), 1u);
- const std::string& name = zip_location_.empty() ? dex_locations_[0] : zip_location_;
+ const std::string& name =
+ input_vdex_file_->GetName() != kInputVdexPlaceholderName ?
+ input_vdex_file_->GetName() :
+ // We don't strictly know the input vdex location. Use the input
+ // dex instead - it's better than nothing.
+ "vdex for " + (zip_location_.empty() ? dex_locations_[0] : zip_location_);
DCHECK(!name.empty());
if (!oat_writers_[0]->AddVdexDexFilesSource(*input_vdex_file_.get(), name.c_str())) {
return false;
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 413d71f..a552bbd 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -486,12 +486,12 @@
for (; i < vdex_file.GetNumberOfDexFiles(); ++i) {
current_dex_data = vdex_file.GetNextDexFileData(current_dex_data, i);
if (current_dex_data == nullptr) {
- LOG(ERROR) << "Unexpected number of dex files in vdex " << location;
+ LOG(ERROR) << "Unexpected number of dex files in " << location;
return false;
}
if (!DexFileLoader::IsMagicValid(current_dex_data)) {
- LOG(ERROR) << "Invalid magic in vdex file created from " << location;
+ LOG(ERROR) << "Invalid magic in " << location;
return false;
}
// We used `zipped_dex_file_locations_` to keep the strings in memory.
@@ -505,12 +505,12 @@
}
if (vdex_file.GetNextDexFileData(current_dex_data, i) != nullptr) {
- LOG(ERROR) << "Unexpected number of dex files in vdex " << location;
+ LOG(ERROR) << "Unexpected number of dex files in " << location;
return false;
}
if (oat_dex_files_.empty()) {
- LOG(ERROR) << "No dex files in vdex file created from " << location;
+ LOG(ERROR) << "No dex files in " << location;
return false;
}
return true;