Overhaul oatdump options.
Changes:
- `--app-image` (which dumps the app image) no longer requires
`--image`. oatdump infers the boot image location when possible.
- `--app-image` now only dumps the app image, and doesn't fall through
to dumping the boot image anymore.
- `--app-oat` is now deprecated and becomes an alias of `--oat-file`.
- When `--oat-file` (which dumps the oat file) is combined with
`--app-image`, it now correctly takes `--dex-file` as an additional
flag to specify the dex filename. Before this change, oatdump ignored
`--dex-file` when `--app-image` was specified, and it only dumped the
oat header.
- Using `--oat-file` alone now brings up a runtime whenever possible.
This allows dumping more information including BSS mappings for BCP
dex files. Before this change, oat files were dumped with runtime
only if `--boot-image` was specified.
- When the dex code is missing, oatdump now always dumps the oat file
without runtime. Before this change, it tried to dump with runtime and
failed.
- `--boot-image` now accepts a non-existing path, to start the runtime
in imageless mode. This allows dumping with runtime for an oat file
that is generated without a boot image.
- oatdump now checks the BCP checksums before dumping with runtime.
Before this change, it crashed when there was a BCP mismatch.
- When `--image` (which dumps the boot image) is unexpectedly combined
with `--boot-image`, oatdump now ignores `--boot-image`. Before this
change, the behavior was controlled by `--image` but the location was
taken from `--boot-image`.
- The order of precedence of the options is clarified in the code, but
is unchanged for backward compatibility.
Bug: 293335130
Test: Manually tested the examples in the help text added by this CL.
Test: m test-art-host-gtest-art_oatdump_tests
Test: atest art_standalone_oatdump_tests
Change-Id: I3e1dcf403f6fb459bcd91b47e5f4513237813215
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 9848a78..47a3b34 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -32,6 +32,7 @@
#include "base/array_ref.h"
#include "base/compiler_filter.h"
#include "base/file_utils.h"
+#include "base/globals.h"
#include "base/logging.h" // For VLOG.
#include "base/macros.h"
#include "base/os.h"
@@ -200,7 +201,9 @@
vdex_for_oat_.Reset(vdex_file_name, UseFdToReadFiles(), zip_fd, vdex_fd, oat_fd);
std::string dm_file_name = GetDmFilename(dex_location);
dm_for_oat_.Reset(dm_file_name, UseFdToReadFiles(), zip_fd, vdex_fd, oat_fd);
- } else {
+ } else if (kIsTargetAndroid) {
+ // No need to warn on host. We are probably in oatdump, where we only need OatFileAssistant to
+ // validate BCP checksums.
LOG(WARNING) << "Failed to determine oat file name for dex location " << dex_location_ << ": "
<< error_msg;
}