diff options
author | David Srbecky <dsrbecky@google.com> | 2021-05-07 16:21:10 +0100 |
---|---|---|
committer | David Srbecky <dsrbecky@google.com> | 2021-05-08 00:07:21 +0100 |
commit | f3d3b1def77df73f0b1d58fb19b9949836a67081 (patch) | |
tree | fa182e063ed64e0a7ef3eea688430a0304be4252 | |
parent | c606cf71c464bb32d662ab280113931692041d01 (diff) | |
download | unwinding-f3d3b1def77df73f0b1d58fb19b9949836a67081.tar.gz |
Skip memory caches in JitDebug interface
The JitDebug interface relies on being able to re-read memory to
see the latest entries and to do cross-process synchronization.
Test: Run ART gcstress tests manually
Change-Id: Ic4aca458a6b013265f573aa84f4a11822ec5cefb
-rw-r--r-- | libunwindstack/GlobalDebugImpl.h | 9 | ||||
-rw-r--r-- | libunwindstack/MemoryCache.h | 6 | ||||
-rw-r--r-- | libunwindstack/include/unwindstack/Memory.h | 4 |
3 files changed, 18 insertions, 1 deletions
diff --git a/libunwindstack/GlobalDebugImpl.h b/libunwindstack/GlobalDebugImpl.h index be7d40c..5ba772c 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. @@ -362,6 +363,14 @@ std::unique_ptr<GlobalDebugInterface<Symfile>> CreateGlobalDebugImpl( 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 @@ class MemoryCacheBase : public Memory { 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 @@ class MemoryCacheBase : public Memory { 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 @@ class Memory { 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() {} |