diff --git a/libunwindstack/Android.bp b/libunwindstack/Android.bp index 2573b1cbc..512c96227 100644 --- a/libunwindstack/Android.bp +++ b/libunwindstack/Android.bp @@ -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", diff --git a/libunwindstack/DexFiles.cpp b/libunwindstack/DexFiles.cpp index 63a77e50f..2057fad19 100644 --- a/libunwindstack/DexFiles.cpp +++ b/libunwindstack/DexFiles.cpp @@ -27,10 +27,21 @@ #include #include +#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 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 diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp index 0b9b85c65..1bb031947 100644 --- a/libunwindstack/Unwinder.cpp +++ b/libunwindstack/Unwinder.cpp @@ -34,9 +34,7 @@ #include #include -#if !defined(NO_LIBDEXFILE_SUPPORT) #include -#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); diff --git a/libunwindstack/include/unwindstack/Unwinder.h b/libunwindstack/include/unwindstack/Unwinder.h index 11ad9de6f..67762c0bd 100644 --- a/libunwindstack/include/unwindstack/Unwinder.h +++ b/libunwindstack/include/unwindstack/Unwinder.h @@ -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 frames_; std::shared_ptr 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_ptr_; std::unique_ptr jit_debug_ptr_; -#if !defined(NO_LIBDEXFILE_SUPPORT) std::unique_ptr dex_files_ptr_; -#endif }; } // namespace unwindstack