Merge "Move the dexfile support to implementation."
This commit is contained in:
commit
adebae2ca6
4 changed files with 26 additions and 16 deletions
|
|
@ -77,6 +77,7 @@ cc_library {
|
||||||
],
|
],
|
||||||
|
|
||||||
cflags: [
|
cflags: [
|
||||||
|
"-DDEXFILE_SUPPORT",
|
||||||
"-Wexit-time-destructors",
|
"-Wexit-time-destructors",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -89,20 +90,18 @@ cc_library {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
vendor: {
|
vendor: {
|
||||||
cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
|
cflags: ["-UDEXFILE_SUPPORT"],
|
||||||
exclude_srcs: [
|
exclude_srcs: [
|
||||||
"DexFile.cpp",
|
"DexFile.cpp",
|
||||||
"DexFiles.cpp",
|
|
||||||
],
|
],
|
||||||
exclude_shared_libs: [
|
exclude_shared_libs: [
|
||||||
"libdexfile_support",
|
"libdexfile_support",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
recovery: {
|
recovery: {
|
||||||
cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
|
cflags: ["-UDEXFILE_SUPPORT"],
|
||||||
exclude_srcs: [
|
exclude_srcs: [
|
||||||
"DexFile.cpp",
|
"DexFile.cpp",
|
||||||
"DexFiles.cpp",
|
|
||||||
],
|
],
|
||||||
exclude_shared_libs: [
|
exclude_shared_libs: [
|
||||||
"libdexfile_support",
|
"libdexfile_support",
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,21 @@
|
||||||
#include <unwindstack/Maps.h>
|
#include <unwindstack/Maps.h>
|
||||||
#include <unwindstack/Memory.h>
|
#include <unwindstack/Memory.h>
|
||||||
|
|
||||||
|
#if defined(DEXFILE_SUPPORT)
|
||||||
#include "DexFile.h"
|
#include "DexFile.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace unwindstack {
|
namespace unwindstack {
|
||||||
|
|
||||||
|
#if !defined(DEXFILE_SUPPORT)
|
||||||
|
// Empty class definition.
|
||||||
|
class DexFile {
|
||||||
|
public:
|
||||||
|
DexFile() = default;
|
||||||
|
virtual ~DexFile() = default;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct DEXFileEntry32 {
|
struct DEXFileEntry32 {
|
||||||
uint32_t next;
|
uint32_t next;
|
||||||
uint32_t prev;
|
uint32_t prev;
|
||||||
|
|
@ -128,6 +139,7 @@ void DexFiles::Init(Maps* maps) {
|
||||||
FindAndReadVariable(maps, "__dex_debug_descriptor");
|
FindAndReadVariable(maps, "__dex_debug_descriptor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(DEXFILE_SUPPORT)
|
||||||
DexFile* DexFiles::GetDexFile(uint64_t dex_file_offset, MapInfo* info) {
|
DexFile* DexFiles::GetDexFile(uint64_t dex_file_offset, MapInfo* info) {
|
||||||
// Lock while processing the data.
|
// Lock while processing the data.
|
||||||
DexFile* dex_file;
|
DexFile* dex_file;
|
||||||
|
|
@ -141,6 +153,11 @@ DexFile* DexFiles::GetDexFile(uint64_t dex_file_offset, MapInfo* info) {
|
||||||
}
|
}
|
||||||
return dex_file;
|
return dex_file;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
DexFile* DexFiles::GetDexFile(uint64_t, MapInfo*) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool DexFiles::GetAddr(size_t index, uint64_t* addr) {
|
bool DexFiles::GetAddr(size_t index, uint64_t* addr) {
|
||||||
if (index < addrs_.size()) {
|
if (index < addrs_.size()) {
|
||||||
|
|
@ -154,6 +171,7 @@ bool DexFiles::GetAddr(size_t index, uint64_t* addr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(DEXFILE_SUPPORT)
|
||||||
void DexFiles::GetMethodInformation(Maps* maps, MapInfo* info, uint64_t dex_pc,
|
void DexFiles::GetMethodInformation(Maps* maps, MapInfo* info, uint64_t dex_pc,
|
||||||
std::string* method_name, uint64_t* method_offset) {
|
std::string* method_name, uint64_t* method_offset) {
|
||||||
std::lock_guard<std::mutex> guard(lock_);
|
std::lock_guard<std::mutex> guard(lock_);
|
||||||
|
|
@ -175,5 +193,8 @@ void DexFiles::GetMethodInformation(Maps* maps, MapInfo* info, uint64_t dex_pc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void DexFiles::GetMethodInformation(Maps*, MapInfo*, uint64_t, std::string*, uint64_t*) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace unwindstack
|
} // namespace unwindstack
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,7 @@
|
||||||
#include <unwindstack/Memory.h>
|
#include <unwindstack/Memory.h>
|
||||||
#include <unwindstack/Unwinder.h>
|
#include <unwindstack/Unwinder.h>
|
||||||
|
|
||||||
#if !defined(NO_LIBDEXFILE_SUPPORT)
|
|
||||||
#include <unwindstack/DexFiles.h>
|
#include <unwindstack/DexFiles.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
// Use the demangler from libc++.
|
// Use the demangler from libc++.
|
||||||
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int* status);
|
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int* status);
|
||||||
|
|
@ -84,7 +82,7 @@ void Unwinder::FillInDexFrame() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(NO_LIBDEXFILE_SUPPORT)
|
#if defined(DEXFILE_SUPPORT)
|
||||||
if (dex_files_ == nullptr) {
|
if (dex_files_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -367,12 +365,10 @@ void Unwinder::SetJitDebug(JitDebug* jit_debug, ArchEnum arch) {
|
||||||
jit_debug_ = jit_debug;
|
jit_debug_ = jit_debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(NO_LIBDEXFILE_SUPPORT)
|
|
||||||
void Unwinder::SetDexFiles(DexFiles* dex_files, ArchEnum arch) {
|
void Unwinder::SetDexFiles(DexFiles* dex_files, ArchEnum arch) {
|
||||||
dex_files->SetArch(arch);
|
dex_files->SetArch(arch);
|
||||||
dex_files_ = dex_files;
|
dex_files_ = dex_files;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool UnwinderFromPid::Init(ArchEnum arch) {
|
bool UnwinderFromPid::Init(ArchEnum arch) {
|
||||||
if (pid_ == getpid()) {
|
if (pid_ == getpid()) {
|
||||||
|
|
@ -390,7 +386,7 @@ bool UnwinderFromPid::Init(ArchEnum arch) {
|
||||||
jit_debug_ptr_.reset(new JitDebug(process_memory_));
|
jit_debug_ptr_.reset(new JitDebug(process_memory_));
|
||||||
jit_debug_ = jit_debug_ptr_.get();
|
jit_debug_ = jit_debug_ptr_.get();
|
||||||
SetJitDebug(jit_debug_, arch);
|
SetJitDebug(jit_debug_, arch);
|
||||||
#if !defined(NO_LIBDEXFILE_SUPPORT)
|
#if defined(DEXFILE_SUPPORT)
|
||||||
dex_files_ptr_.reset(new DexFiles(process_memory_));
|
dex_files_ptr_.reset(new DexFiles(process_memory_));
|
||||||
dex_files_ = dex_files_ptr_.get();
|
dex_files_ = dex_files_ptr_.get();
|
||||||
SetDexFiles(dex_files_, arch);
|
SetDexFiles(dex_files_, arch);
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,7 @@ class Unwinder {
|
||||||
|
|
||||||
void SetDisplayBuildID(bool display_build_id) { display_build_id_ = display_build_id; }
|
void SetDisplayBuildID(bool display_build_id) { display_build_id_ = display_build_id; }
|
||||||
|
|
||||||
#if !defined(NO_LIBDEXFILE_SUPPORT)
|
|
||||||
void SetDexFiles(DexFiles* dex_files, ArchEnum arch);
|
void SetDexFiles(DexFiles* dex_files, ArchEnum arch);
|
||||||
#endif
|
|
||||||
|
|
||||||
bool elf_from_memory_not_file() { return elf_from_memory_not_file_; }
|
bool elf_from_memory_not_file() { return elf_from_memory_not_file_; }
|
||||||
|
|
||||||
|
|
@ -128,9 +126,7 @@ class Unwinder {
|
||||||
std::vector<FrameData> frames_;
|
std::vector<FrameData> frames_;
|
||||||
std::shared_ptr<Memory> process_memory_;
|
std::shared_ptr<Memory> process_memory_;
|
||||||
JitDebug* jit_debug_ = nullptr;
|
JitDebug* jit_debug_ = nullptr;
|
||||||
#if !defined(NO_LIBDEXFILE_SUPPORT)
|
|
||||||
DexFiles* dex_files_ = nullptr;
|
DexFiles* dex_files_ = nullptr;
|
||||||
#endif
|
|
||||||
bool resolve_names_ = true;
|
bool resolve_names_ = true;
|
||||||
bool embedded_soname_ = true;
|
bool embedded_soname_ = true;
|
||||||
bool display_build_id_ = false;
|
bool display_build_id_ = false;
|
||||||
|
|
@ -151,9 +147,7 @@ class UnwinderFromPid : public Unwinder {
|
||||||
pid_t pid_;
|
pid_t pid_;
|
||||||
std::unique_ptr<Maps> maps_ptr_;
|
std::unique_ptr<Maps> maps_ptr_;
|
||||||
std::unique_ptr<JitDebug> jit_debug_ptr_;
|
std::unique_ptr<JitDebug> jit_debug_ptr_;
|
||||||
#if !defined(NO_LIBDEXFILE_SUPPORT)
|
|
||||||
std::unique_ptr<DexFiles> dex_files_ptr_;
|
std::unique_ptr<DexFiles> dex_files_ptr_;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace unwindstack
|
} // namespace unwindstack
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue