Revert "Make dexlayout and profman build without libart"
This reverts commit 2b80ed488c497393270c98f7a767d8495166db8e.
Bug: 78652467
Reason for revert: ASAN tests failing
Change-Id: Id4bba2711d8b69c0a64e3e8eb335a18facab9fdd
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index 5285c08..b009774 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -27,7 +27,6 @@
],
export_include_dirs: ["."],
shared_libs: [
- "libartbase",
"libbase",
],
static_libs: ["libz"],
@@ -40,6 +39,7 @@
"dex2oat-pgo-defaults",
],
shared_libs: [
+ "libart",
"libdexfile",
"libprofile",
],
@@ -60,6 +60,7 @@
"art_debug_defaults",
],
shared_libs: [
+ "libartd",
"libdexfiled",
"libprofiled",
],
@@ -79,9 +80,8 @@
name: "dexlayout",
defaults: ["dexlayout-defaults"],
shared_libs: [
- "libartbase",
- "libdexfile",
"libprofile",
+ "libart",
"libart-dexlayout",
],
}
@@ -93,9 +93,8 @@
"dexlayout-defaults",
],
shared_libs: [
- "libartbased",
- "libdexfiled",
"libprofiled",
+ "libartd",
"libartd-dexlayout",
],
}
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 03dfee3..62dd1a9 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -36,8 +36,8 @@
#include "base/logging.h" // For VLOG_IS_ON.
#include "base/mem_map.h"
#include "base/os.h"
-#include "base/unix_file/fd_file.h"
#include "base/utils.h"
+#include "dex/art_dex_file_loader.h"
#include "dex/descriptors_names.h"
#include "dex/dex_file-inl.h"
#include "dex/dex_file_layout.h"
@@ -1930,7 +1930,7 @@
std::string location = "memory mapped file for " + std::string(file_name);
// Dex file verifier cannot handle compact dex.
bool verify = options_.compact_dex_level_ == CompactDexLevel::kCompactDexLevelNone;
- const DexFileLoader dex_file_loader;
+ const ArtDexFileLoader dex_file_loader;
DexContainer::Section* const main_section = (*dex_container)->GetMainSection();
DexContainer::Section* const data_section = (*dex_container)->GetDataSection();
DCHECK_EQ(file_size, main_section->Size())
@@ -1980,32 +1980,10 @@
// all of which are Zip archives with "classes.dex" inside.
const bool verify_checksum = !options_.ignore_bad_checksum_;
std::string error_msg;
- std::unique_ptr<File> input_file(OS::OpenFileForReading(file_name));
- if (input_file == nullptr) {
- LOG(ERROR) << "Could not open file " << file_name << " for reading";
- return -1;
- }
- std::unique_ptr<MemMap> mmap(MemMap::MapFile(input_file->GetLength(),
- PROT_READ,
- MAP_PRIVATE,
- input_file->Fd(),
- /*start*/0,
- /*low_4gb*/false,
- file_name,
- &error_msg));
- if (mmap == nullptr) {
- LOG(ERROR) << "MemMap failed for '" << file_name << "' " << error_msg;
- return -1;
- }
- const DexFileLoader dex_file_loader;
+ const ArtDexFileLoader dex_file_loader;
std::vector<std::unique_ptr<const DexFile>> dex_files;
- if (!dex_file_loader.OpenAll(mmap->Begin(),
- mmap->Size(),
- file_name,
- /*verify*/true,
- verify_checksum,
- &error_msg,
- &dex_files)) {
+ if (!dex_file_loader.Open(
+ file_name, file_name, /* verify */ true, verify_checksum, &error_msg, &dex_files)) {
// Display returned error message to user. Note that this error behavior
// differs from the error messages shown by the original Dalvik dexdump.
LOG(ERROR) << error_msg;
diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc
index 3f92d50..185c142 100644
--- a/dexlayout/dexlayout_main.cc
+++ b/dexlayout/dexlayout_main.cc
@@ -34,6 +34,7 @@
#include "base/logging.h" // For InitLogging.
#include "base/mem_map.h"
#include "profile/profile_compilation_info.h"
+#include "runtime.h"
namespace art {
@@ -65,17 +66,12 @@
LOG(ERROR) << " -x : compact dex generation level, either 'none' or 'fast'";
}
-NO_RETURN static void Abort(const char* msg) {
- LOG(ERROR) << "Aborted: " << msg;
- exit(1);
-}
-
/*
* Main driver of the dexlayout utility.
*/
int DexlayoutDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv, Abort);
+ InitLogging(argv, Runtime::Abort);
MemMap::Init();
Options options;
diff --git a/libprofile/Android.bp b/libprofile/Android.bp
index 5afe73b..bcb90cb 100644
--- a/libprofile/Android.bp
+++ b/libprofile/Android.bp
@@ -40,6 +40,7 @@
],
},
},
+ //generated_sources: ["art_libartbase_operator_srcs"],
cflags: ["-DBUILDING_LIBART=1"],
shared_libs: [
"libartbase",
diff --git a/profman/Android.bp b/profman/Android.bp
index c9c92e6..3c8c72c 100644
--- a/profman/Android.bp
+++ b/profman/Android.bp
@@ -39,7 +39,7 @@
name: "profman",
defaults: ["profman-defaults"],
shared_libs: [
- "libartbase",
+ "libart",
"libprofile",
"libdexfile",
],
@@ -52,7 +52,7 @@
"profman-defaults",
],
shared_libs: [
- "libartbased",
+ "libartd",
"libprofiled",
"libdexfiled",
],
diff --git a/profman/profman.cc b/profman/profman.cc
index c16fadd..cd88d03 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
-#include <sys/mman.h>
#include <sys/param.h>
#include <unistd.h>
@@ -41,6 +40,7 @@
#include "base/utils.h"
#include "base/zip_archive.h"
#include "boot_image_profile.h"
+#include "dex/art_dex_file_loader.h"
#include "dex/bytecode_utils.h"
#include "dex/code_item_accessors-inl.h"
#include "dex/dex_file.h"
@@ -49,6 +49,7 @@
#include "dex/type_reference.h"
#include "profile/profile_compilation_info.h"
#include "profile_assistant.h"
+#include "runtime.h"
namespace art {
@@ -176,11 +177,6 @@
static constexpr char kMethodFlagStringStartup = 'S';
static constexpr char kMethodFlagStringPostStartup = 'P';
-NO_RETURN static void Abort(const char* msg) {
- LOG(ERROR) << "Aborted: " << msg;
- exit(1);
-}
-
// TODO(calin): This class has grown too much from its initial design. Split the functionality
// into smaller, more contained pieces.
class ProfMan FINAL {
@@ -206,8 +202,8 @@
original_argc = argc;
original_argv = argv;
- MemMap::Init();
- InitLogging(argv, Abort);
+ Locks::Init();
+ InitLogging(argv, Runtime::Abort);
// Skip over the command name.
argv++;
@@ -417,49 +413,36 @@
}
static constexpr bool kVerifyChecksum = true;
for (size_t i = 0; i < dex_locations_.size(); ++i) {
- std::unique_ptr<File> apk_file;
+ std::string error_msg;
+ const ArtDexFileLoader dex_file_loader;
+ std::vector<std::unique_ptr<const DexFile>> dex_files_for_location;
// We do not need to verify the apk for processing profiles.
if (use_apk_fd_list) {
- apk_file.reset(new File(apks_fd_[i], false/*checkUsage*/));
- } else {
- apk_file.reset(new File(apk_files_[i], O_RDONLY, false/*checkUsage*/));
- if (apk_file == nullptr) {
- LOG(ERROR) << "Open failed for '" << dex_locations_[i] << "' ";
+ if (dex_file_loader.OpenZip(apks_fd_[i],
+ dex_locations_[i],
+ /* verify */ false,
+ kVerifyChecksum,
+ &error_msg,
+ &dex_files_for_location)) {
+ } else {
+ LOG(ERROR) << "OpenZip failed for '" << dex_locations_[i] << "' " << error_msg;
return false;
}
- }
- std::string error_msg;
- std::unique_ptr<MemMap> mmap(MemMap::MapFile(apk_file->GetLength(),
- PROT_READ,
- MAP_PRIVATE,
- apk_file->Fd(),
- /*start*/0,
- /*low_4gb*/false,
- dex_locations_[i].c_str(),
- &error_msg));
- if (mmap == nullptr) {
- LOG(ERROR) << "MemMap failed for '" << dex_locations_[i] << "' " << error_msg;
- return false;
- }
- const DexFileLoader dex_file_loader;
- std::vector<std::unique_ptr<const DexFile>> dex_files_for_location;
- if (!dex_file_loader.OpenAll(mmap->Begin(),
- mmap->Size(),
- dex_locations_[i],
- /* verify */ false,
- kVerifyChecksum,
- &error_msg,
- &dex_files_for_location)) {
- LOG(ERROR) << "OpenAll failed for '" << dex_locations_[i] << "' " << error_msg;
- return false;
+ } else {
+ if (dex_file_loader.Open(apk_files_[i].c_str(),
+ dex_locations_[i],
+ /* verify */ false,
+ kVerifyChecksum,
+ &error_msg,
+ &dex_files_for_location)) {
+ } else {
+ LOG(ERROR) << "Open failed for '" << dex_locations_[i] << "' " << error_msg;
+ return false;
+ }
}
for (std::unique_ptr<const DexFile>& dex_file : dex_files_for_location) {
process_fn(std::move(dex_file));
}
- // Leak apk_file and mmap for now.
- // TODO: close fds, etc.
- apk_file.release();
- mmap.release();
}
return true;
}