Move the dexfile support to implementation.
No longer require that NO_LIBDEXFILE_SUPPORT be defined or not
defined when including the header files. Move all of the different
behavior to the implementation, and keep all of the classes the
exact same whether dexfiles are supported or not.
Bug: 144470551
Test: Ran libunwindstack unit tests, libbacktrace unit tests, and
Test: debuggerd unit tests.
Test: Ran host art 137-cfi tests.
Change-Id: I4a04cfbc5d4f1bf765ef154881046c85057006c8
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