Merge "Continue without DEX support if libdexfile_external.so fails to load."
This commit is contained in:
commit
58ee7e3ae1
1 changed files with 24 additions and 0 deletions
|
|
@ -22,6 +22,9 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#define LOG_TAG "unwind"
|
||||||
|
#include <log/log.h>
|
||||||
|
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <art_api/dex_file_support.h>
|
#include <art_api/dex_file_support.h>
|
||||||
|
|
||||||
|
|
@ -32,6 +35,19 @@
|
||||||
|
|
||||||
namespace unwindstack {
|
namespace unwindstack {
|
||||||
|
|
||||||
|
static bool CheckDexSupport() {
|
||||||
|
if (std::string err_msg; !art_api::dex::TryLoadLibdexfileExternal(&err_msg)) {
|
||||||
|
ALOGW("Failed to initialize DEX file support: %s", err_msg.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HasDexSupport() {
|
||||||
|
static bool has_dex_support = CheckDexSupport();
|
||||||
|
return has_dex_support;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<DexFile> DexFile::Create(uint64_t dex_file_offset_in_memory, Memory* memory,
|
std::unique_ptr<DexFile> DexFile::Create(uint64_t dex_file_offset_in_memory, Memory* memory,
|
||||||
MapInfo* info) {
|
MapInfo* info) {
|
||||||
if (!info->name.empty()) {
|
if (!info->name.empty()) {
|
||||||
|
|
@ -57,6 +73,10 @@ bool DexFile::GetMethodInformation(uint64_t dex_offset, std::string* method_name
|
||||||
|
|
||||||
std::unique_ptr<DexFileFromFile> DexFileFromFile::Create(uint64_t dex_file_offset_in_file,
|
std::unique_ptr<DexFileFromFile> DexFileFromFile::Create(uint64_t dex_file_offset_in_file,
|
||||||
const std::string& file) {
|
const std::string& file) {
|
||||||
|
if (UNLIKELY(!HasDexSupport())) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(file.c_str(), O_RDONLY | O_CLOEXEC)));
|
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(file.c_str(), O_RDONLY | O_CLOEXEC)));
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -75,6 +95,10 @@ std::unique_ptr<DexFileFromFile> DexFileFromFile::Create(uint64_t dex_file_offse
|
||||||
std::unique_ptr<DexFileFromMemory> DexFileFromMemory::Create(uint64_t dex_file_offset_in_memory,
|
std::unique_ptr<DexFileFromMemory> DexFileFromMemory::Create(uint64_t dex_file_offset_in_memory,
|
||||||
Memory* memory,
|
Memory* memory,
|
||||||
const std::string& name) {
|
const std::string& name) {
|
||||||
|
if (UNLIKELY(!HasDexSupport())) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> backing_memory;
|
std::vector<uint8_t> backing_memory;
|
||||||
|
|
||||||
for (size_t size = 0;;) {
|
for (size_t size = 0;;) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue