summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2017-02-22 23:42:55 +0000
committerGreg Clayton <gclayton@apple.com>2017-02-22 23:42:55 +0000
commit98f9bcc1c92845e4a0d3995f39bf1cb0d6b28795 (patch)
treeda0dea8eaa26b8278e2c74f2a6a5786ed6f8ff10
parent6181c62b9555e07b55b236545f599c99760cb967 (diff)
downloadbcm5719-llvm-98f9bcc1c92845e4a0d3995f39bf1cb0d6b28795.tar.gz
bcm5719-llvm-98f9bcc1c92845e4a0d3995f39bf1cb0d6b28795.zip
Fixed errors in AllocatedBlock:
- Allow zero byte size request for memory and ensure it gets a unique address - Exit the free block loop when we find an appropriate free block <rdar://problem/30644888> llvm-svn: 295907
-rw-r--r--lldb/source/Target/Memory.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp
index 92c29937b65..0a014d5ef84 100644
--- a/lldb/source/Target/Memory.cpp
+++ b/lldb/source/Target/Memory.cpp
@@ -263,7 +263,9 @@ AllocatedBlock::AllocatedBlock(lldb::addr_t addr, uint32_t byte_size,
AllocatedBlock::~AllocatedBlock() {}
lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) {
- addr_t addr = LLDB_INVALID_ADDRESS;
+ // We must return something valid for zero bytes.
+ if (size == 0)
+ size = 1;
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
const size_t free_count = m_free_blocks.GetSize();
@@ -276,7 +278,7 @@ lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) {
// We found a free block that is big enough for our data. Figure out how
// many chunks we will need and calculate the resulting block size we will
// reserve.
- addr = free_block.GetRangeBase();
+ addr_t addr = free_block.GetRangeBase();
size_t num_chunks = CalculateChunksNeededForSize(size);
lldb::addr_t block_size = num_chunks * m_chunk_size;
lldb::addr_t bytes_left = range_size - block_size;
@@ -301,11 +303,14 @@ lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) {
free_block.SetRangeBase(reserved_block.GetRangeEnd());
free_block.SetByteSize(bytes_left);
}
+ LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, addr);
+ return addr;
}
}
- LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, addr);
- return addr;
+ LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size,
+ LLDB_INVALID_ADDRESS);
+ return LLDB_INVALID_ADDRESS;
}
bool AllocatedBlock::FreeBlock(addr_t addr) {
OpenPOWER on IntegriCloud