aboutsummaryrefslogtreecommitdiffstats
path: root/source/Target/Memory.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
commitf3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch)
tree48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /source/Target/Memory.cpp
parent2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff)
downloadsrc-f3fbd1c0586ff6ec7895991e6c28f61a503c36a8.tar.gz
src-f3fbd1c0586ff6ec7895991e6c28f61a503c36a8.zip
Vendor import of lldb release_39 branch r276489:vendor/lldb/lldb-release_39-r276489
Notes
Notes: svn path=/vendor/lldb/dist/; revision=303241 svn path=/vendor/lldb/lldb-release_39-r276489/; revision=303242; tag=vendor/lldb/lldb-release_39-r276489
Diffstat (limited to 'source/Target/Memory.cpp')
-rw-r--r--source/Target/Memory.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp
index c89fd5101147..9f0114812125 100644
--- a/source/Target/Memory.cpp
+++ b/source/Target/Memory.cpp
@@ -25,13 +25,13 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// MemoryCache constructor
//----------------------------------------------------------------------
-MemoryCache::MemoryCache(Process &process) :
- m_mutex (Mutex::eMutexTypeRecursive),
- m_L1_cache (),
- m_L2_cache (),
- m_invalid_ranges (),
- m_process (process),
- m_L2_cache_line_byte_size (process.GetMemoryCacheLineSize())
+MemoryCache::MemoryCache(Process &process)
+ : m_mutex(),
+ m_L1_cache(),
+ m_L2_cache(),
+ m_invalid_ranges(),
+ m_process(process),
+ m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize())
{
}
@@ -45,7 +45,7 @@ MemoryCache::~MemoryCache()
void
MemoryCache::Clear(bool clear_invalid_ranges)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_L1_cache.clear();
m_L2_cache.clear();
if (clear_invalid_ranges)
@@ -62,7 +62,7 @@ MemoryCache::AddL1CacheData(lldb::addr_t addr, const void *src, size_t src_len)
void
MemoryCache::AddL1CacheData(lldb::addr_t addr, const DataBufferSP &data_buffer_sp)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_L1_cache[addr] = data_buffer_sp;
}
@@ -72,13 +72,17 @@ MemoryCache::Flush (addr_t addr, size_t size)
if (size == 0)
return;
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Erase any blocks from the L1 cache that intersect with the flush range
if (!m_L1_cache.empty())
{
AddrRange flush_range(addr, size);
- BlockMap::iterator pos = m_L1_cache.lower_bound(addr);
+ BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
+ if (pos != m_L1_cache.begin())
+ {
+ --pos;
+ }
while (pos != m_L1_cache.end())
{
AddrRange chunk_range(pos->first, pos->second->GetByteSize());
@@ -119,7 +123,7 @@ MemoryCache::AddInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size)
{
if (byte_size > 0)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
InvalidRanges::Entry range (base_addr, byte_size);
m_invalid_ranges.Append(range);
m_invalid_ranges.Sort();
@@ -131,7 +135,7 @@ MemoryCache::RemoveInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size)
{
if (byte_size > 0)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
const uint32_t idx = m_invalid_ranges.FindEntryIndexThatContains(base_addr);
if (idx != UINT32_MAX)
{
@@ -160,7 +164,7 @@ MemoryCache::Read (addr_t addr,
// m_L2_cache_line_byte_size bytes in size, so we don't try anything
// tricky when reading from them (no partial reads from the L1 cache).
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_L1_cache.empty())
{
AddrRange read_range(addr, dst_len);
@@ -432,11 +436,7 @@ AllocatedBlock::FreeBlock (addr_t addr)
return success;
}
-
-AllocatedMemoryCache::AllocatedMemoryCache (Process &process) :
- m_process (process),
- m_mutex (Mutex::eMutexTypeRecursive),
- m_memory_map()
+AllocatedMemoryCache::AllocatedMemoryCache(Process &process) : m_process(process), m_mutex(), m_memory_map()
{
}
@@ -448,7 +448,7 @@ AllocatedMemoryCache::~AllocatedMemoryCache ()
void
AllocatedMemoryCache::Clear()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process.IsAlive())
{
PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
@@ -494,8 +494,8 @@ AllocatedMemoryCache::AllocateMemory (size_t byte_size,
uint32_t permissions,
Error &error)
{
- Mutex::Locker locker (m_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
addr_t addr = LLDB_INVALID_ADDRESS;
std::pair<PermissionsToBlockMap::iterator, PermissionsToBlockMap::iterator> range = m_memory_map.equal_range (permissions);
@@ -522,7 +522,7 @@ AllocatedMemoryCache::AllocateMemory (size_t byte_size,
bool
AllocatedMemoryCache::DeallocateMemory (lldb::addr_t addr)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
bool success = false;