LLDB mainline
MemoryRegionInfoCache.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12using namespace lldb;
13using namespace lldb_private;
14
16 std::lock_guard<std::mutex> guard(m_mutex);
17 m_region_infos.clear();
18}
19
21 std::lock_guard<std::mutex> guard(m_mutex);
22 return m_region_infos.size();
23}
24
25std::optional<MemoryRegionInfo>
27 std::lock_guard<std::mutex> guard(m_mutex);
28 auto it = m_region_infos.upper_bound(load_addr);
29 if (it == m_region_infos.begin())
30 return std::nullopt;
31 --it;
32 if (load_addr < it->second.GetRange().GetRangeEnd())
33 return it->second;
34
35 return std::nullopt;
36}
37
39 std::lock_guard<std::mutex> guard(m_mutex);
40 m_region_infos.insert_or_assign(ri.GetRange().GetRangeBase(), ri);
41}
void Clear()
Remove all cached entries.
std::map< lldb::addr_t, MemoryRegionInfo > m_region_infos
void AddRegion(const MemoryRegionInfo &region_info)
Add a MemoryRegionInfo to the collection.
std::optional< MemoryRegionInfo > GetMemoryRegion(lldb::addr_t load_addr)
Return a MemoryRegionInfo that covers load_addr, returns empty optional if there is no entry.
A class that represents a running process on the host machine.
uint64_t addr_t
Definition lldb-types.h:80
BaseType GetRangeBase() const
Definition RangeMap.h:45