Merge "Skip memory caches in JitDebug interface"
diff --git a/libunwindstack/GlobalDebugImpl.h b/libunwindstack/GlobalDebugImpl.h
index 0ad9598..b3e3316 100644
--- a/libunwindstack/GlobalDebugImpl.h
+++ b/libunwindstack/GlobalDebugImpl.h
@@ -29,6 +29,7 @@
#include "Check.h"
#include "GlobalDebugInterface.h"
+#include "MemoryCache.h"
#include "MemoryRange.h"
// This implements the JIT Compilation Interface.
@@ -389,6 +390,14 @@
ArchEnum arch, std::shared_ptr<Memory>& memory, std::vector<std::string> search_libs,
const char* global_variable_name) {
CHECK(arch != ARCH_UNKNOWN);
+
+ // The interface needs to see real-time changes in memory for synchronization with the
+ // concurrently running ART JIT compiler. Skip caching and read the memory directly.
+ MemoryCacheBase* cached_memory = memory->AsMemoryCacheBase();
+ if (cached_memory != nullptr) {
+ memory = cached_memory->UnderlyingMemory();
+ }
+
switch (arch) {
case ARCH_X86: {
using Impl = GlobalDebugImpl<Symfile, uint32_t, Uint64_P>;
diff --git a/libunwindstack/MemoryCache.h b/libunwindstack/MemoryCache.h
index ebc8708..523a4a1 100644
--- a/libunwindstack/MemoryCache.h
+++ b/libunwindstack/MemoryCache.h
@@ -34,6 +34,10 @@
MemoryCacheBase(Memory* memory) : impl_(memory) {}
virtual ~MemoryCacheBase() = default;
+ MemoryCacheBase* AsMemoryCacheBase() override { return this; }
+
+ const std::shared_ptr<Memory>& UnderlyingMemory() { return impl_; }
+
size_t Read(uint64_t addr, void* dst, size_t size) override {
// Only look at the cache for small reads.
if (size > 64) {
@@ -55,7 +59,7 @@
size_t InternalCachedRead(uint64_t addr, void* dst, size_t size, CacheDataType* cache);
- std::unique_ptr<Memory> impl_;
+ std::shared_ptr<Memory> impl_;
};
class MemoryCache : public MemoryCacheBase {
diff --git a/libunwindstack/include/unwindstack/Memory.h b/libunwindstack/include/unwindstack/Memory.h
index c719544..b7bede6 100644
--- a/libunwindstack/include/unwindstack/Memory.h
+++ b/libunwindstack/include/unwindstack/Memory.h
@@ -26,6 +26,8 @@
namespace unwindstack {
+class MemoryCacheBase;
+
class Memory {
public:
Memory() = default;
@@ -39,6 +41,8 @@
static std::unique_ptr<Memory> CreateFileMemory(const std::string& path, uint64_t offset,
uint64_t size = UINT64_MAX);
+ virtual MemoryCacheBase* AsMemoryCacheBase() { return nullptr; }
+
virtual bool ReadString(uint64_t addr, std::string* dst, size_t max_read);
virtual void Clear() {}