Merge "Move the dexfile support to implementation."
diff --git a/libunwindstack/Android.bp b/libunwindstack/Android.bp
index 2573b1c..512c962 100644
--- a/libunwindstack/Android.bp
+++ b/libunwindstack/Android.bp
@@ -77,6 +77,7 @@
],
cflags: [
+ "-DDEXFILE_SUPPORT",
"-Wexit-time-destructors",
],
@@ -89,20 +90,18 @@
],
},
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 63a77e5..2057fad 100644
--- a/libunwindstack/DexFiles.cpp
+++ b/libunwindstack/DexFiles.cpp
@@ -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 @@
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 @@
}
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 @@
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 @@
}
}
}
+#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 0b9b85c..1bb0319 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -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 @@
return;
}
-#if !defined(NO_LIBDEXFILE_SUPPORT)
+#if defined(DEXFILE_SUPPORT)
if (dex_files_ == nullptr) {
return;
}
@@ -367,12 +365,10 @@
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 @@
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 11ad9de..67762c0 100644
--- a/libunwindstack/include/unwindstack/Unwinder.h
+++ b/libunwindstack/include/unwindstack/Unwinder.h
@@ -107,9 +107,7 @@
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 @@
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 @@
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