diff options
author | David Srbecky <dsrbecky@google.com> | 2021-05-11 23:43:43 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-11 23:43:43 +0000 |
commit | c1918cd8094be88c829894dd43d04dc65320f2cc (patch) | |
tree | 2b7da870277a71a77983c7b9be9174073c1f85c6 | |
parent | b893cdd52d73b22083d6f460b7f6255efab750c7 (diff) | |
parent | 86ba539a908e14c61f674e33d3bdb2e8a7baae43 (diff) | |
download | unwinding-c1918cd8094be88c829894dd43d04dc65320f2cc.tar.gz |
Merge "Skip memory caches in JitDebug interface" am: 00ce8ad373 am: bd41ecaad2 am: 86ba539a90
Original change: https://android-review.googlesource.com/c/platform/system/unwinding/+/1699730
Change-Id: I619dc438753c33429ef6173cc2e482b3d60d3e6a
-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 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 @@ 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() {} |