summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2015-12-12 03:06:10 +0000
committerJason Molenda <jmolenda@apple.com>2015-12-12 03:06:10 +0000
commita38312a9a4eeb8ab8976adf5712fadd68dd763cf (patch)
tree488c373fa05a834c9bc20df27ad1512323eaf92f
parent97047d8cb6eeb4898a0808da52a401dae8b9767e (diff)
downloadbcm5719-llvm-a38312a9a4eeb8ab8976adf5712fadd68dd763cf.tar.gz
bcm5719-llvm-a38312a9a4eeb8ab8976adf5712fadd68dd763cf.zip
Fix the L1 cache search in MemoryCache::Read to use the
stl upper_bound method instead of lower_bound - we were failing to find some cached data in the L1 cache resulting in extra memory read packets while stepping. The bug with the existing code looked like this: If the L1 cache has 8 bytes at address 0x1000 and 8 bytes at address 0x2000 and we are searching for 4 bytes at 0x2004, the use of lower_bound would return the end() of the container and so we would incorrectly treat the memory as uncached. (the L1 cache is memory seeded from debugserver in the T aka questionmark packet, where debugserver will send up the stack memory that likely contains the caller's stack pointer and frame pointer values.) <rdar://problem/23869227> llvm-svn: 255421
-rw-r--r--lldb/source/Target/Memory.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp
index e61b3ab91e7..c89fd510114 100644
--- a/lldb/source/Target/Memory.cpp
+++ b/lldb/source/Target/Memory.cpp
@@ -164,24 +164,16 @@ MemoryCache::Read (addr_t addr,
if (!m_L1_cache.empty())
{
AddrRange read_range(addr, dst_len);
- BlockMap::iterator pos = m_L1_cache.lower_bound(addr);
- if (pos != m_L1_cache.end())
+ BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
+ if (pos != m_L1_cache.begin ())
{
- AddrRange chunk_range(pos->first, pos->second->GetByteSize());
- bool match = chunk_range.Contains(read_range);
- if (!match && pos != m_L1_cache.begin())
- {
- --pos;
- chunk_range.SetRangeBase(pos->first);
- chunk_range.SetByteSize(pos->second->GetByteSize());
- match = chunk_range.Contains(read_range);
- }
-
- if (match)
- {
- memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), dst_len);
- return dst_len;
- }
+ --pos;
+ }
+ AddrRange chunk_range(pos->first, pos->second->GetByteSize());
+ if (chunk_range.Contains(read_range))
+ {
+ memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), dst_len);
+ return dst_len;
}
}
OpenPOWER on IntegriCloud