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
18 return m_region_infos.Lock()->size();
19}
20
21std::optional<MemoryRegionInfo>
23 auto region_infos = m_region_infos.Lock();
24 auto it = region_infos->upper_bound(load_addr);
25 if (it == region_infos->begin())
26 return std::nullopt;
27 --it;
28 if (load_addr < it->second.GetRange().GetRangeEnd())
29 return it->second;
30
31 return std::nullopt;
32}
33
35 m_region_infos.Lock()->insert_or_assign(ri.GetRange().GetRangeBase(), ri);
36}
void Clear()
Remove all cached entries.
void AddRegion(const MemoryRegionInfo &region_info)
Add a MemoryRegionInfo to the collection.
Guarded< std::map< lldb::addr_t, MemoryRegionInfo >, std::mutex > m_region_infos
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