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