diff options
author | 2023-07-31 11:01:45 +0100 | |
---|---|---|
committer | 2023-08-02 15:18:55 +0000 | |
commit | 0187b188b3f992362dfba829dcba11205e774608 (patch) | |
tree | a27df4cc2adfed7a4cc65e62ba8d893a69a400da /libartbase/base/file_utils.cc | |
parent | 0e09c653ca085043e910e799358bd96ae16a0879 (diff) |
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
Diffstat (limited to 'libartbase/base/file_utils.cc')
-rw-r--r-- | libartbase/base/file_utils.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc index b3f42ee0e4..cb2aee2979 100644 --- a/libartbase/base/file_utils.cc +++ b/libartbase/base/file_utils.cc @@ -19,6 +19,7 @@ #include <inttypes.h> #include <sys/stat.h> #include <sys/types.h> + #ifndef _WIN32 #include <sys/wait.h> #endif @@ -44,6 +45,7 @@ #include "android-base/file.h" #include "android-base/logging.h" +#include "android-base/properties.h" #include "android-base/stringprintf.h" #include "android-base/strings.h" #include "base/bit_utils.h" @@ -70,6 +72,8 @@ namespace art { +using android::base::GetBoolProperty; +using android::base::GetProperty; using android::base::StringPrintf; static constexpr const char* kClassesDex = "classes.dex"; @@ -518,6 +522,34 @@ std::string GetJitZygoteBootImageLocation() { return "/nonx/boot.art!/apex/com.android.art/etc/boot-image.prof!/system/etc/boot-image.prof"; } +std::string GetBootImageLocationForDefaultBcp(bool no_boot_image, + std::string user_defined_boot_image, + bool deny_art_apex_data_files, + std::string* error_msg) { + if (no_boot_image) { + return GetJitZygoteBootImageLocation(); + } + if (!user_defined_boot_image.empty()) { + return user_defined_boot_image; + } + std::string android_root = GetAndroidRootSafe(error_msg); + if (!error_msg->empty()) { + return ""; + } + return GetDefaultBootImageLocationSafe(android_root, deny_art_apex_data_files, error_msg); +} + +std::string GetBootImageLocationForDefaultBcpRespectingSysProps(std::string* error_msg) { + bool no_boot_image = + GetBoolProperty("persist.device_config.runtime_native_boot.profilebootclasspath", + GetBoolProperty("dalvik.vm.profilebootclasspath", /*default_value=*/false)); + std::string user_defined_boot_image = GetProperty("dalvik.vm.boot-image", /*default_value=*/""); + bool deny_art_apex_data_files = + !GetBoolProperty("odsign.verification.success", /*default_value=*/false); + return GetBootImageLocationForDefaultBcp( + no_boot_image, user_defined_boot_image, deny_art_apex_data_files, error_msg); +} + static /*constinit*/ std::string_view dalvik_cache_sub_dir = "dalvik-cache"; void OverrideDalvikCacheSubDirectory(std::string sub_dir) { |