================ @@ -0,0 +1,42 @@ +//===-- MemoryRegionInfoCache.h ---------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_TARGET_MEMORYREGIONINFOCACHE_H +#define LLDB_TARGET_MEMORYREGIONINFOCACHE_H + +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/RangeMap.h" + +namespace lldb_private { +class MemoryRegionInfoCache { +public: + MemoryRegionInfoCache(Process &process) + : m_region_infos(), m_process(process) {} + + /// Remove all cached entries. + void Clear(); + + /// Remove cached information about region containing \a addr, if any. + void Flush(lldb::addr_t addr, lldb::addr_t size); + + /// Locate the memory region that contains load_addr. + Status GetMemoryRegionInfo(lldb::addr_t load_addr, ---------------- jasonmolenda wrote:
> I now see this is a "check the cache and if it's not there query the > process". IMO this logic is better moved to the process itself, as the > current design creates a circular dependency (process needs to own a cache, > the cache needs to own a process). I don't think that's true, but I might have misunderstood. Process has a `Process::GetMemoryRegionInfo` API, and subclasses have a `Process::DoGetMemoryRegionInfo`, just like how the base class has `ReadMemory` and the subclasses have `DoReadMemory`. The call to `MemoryRegionInfoCache::GetMemoryRegionInfo()` sits between the base class method and the subclass method calls. We could put the cache entirely in Process of course, it's only four methods and a `RangeDataVector` ivar, but having it in a separate class akin to how `MemoryCache` (a much larger amount of code) seemed natural to me. https://github.com/llvm/llvm-project/pull/202509 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
