summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Fiala <tfiala@google.com>2014-02-12 07:29:44 +0000
committerTodd Fiala <tfiala@google.com>2014-02-12 07:29:44 +0000
commit729c001ec35a666b47fb05ade56ddcc83f50eb27 (patch)
tree5c01a50d63a04fb7a571d6de6c600d9f11ade86a
parent167c15a98feb898c13eca325678b73d0c59dffa2 (diff)
downloadbcm5719-llvm-729c001ec35a666b47fb05ade56ddcc83f50eb27.tar.gz
bcm5719-llvm-729c001ec35a666b47fb05ade56ddcc83f50eb27.zip
Fix elf core file VMA-contiguous region collapsing.
Elf core files were collapsing core segments when the virtual memory addresses were contiguous without checking if the core-file-backed memory region was the same size as the segment's VMA region. Without this extra check, any time regions were collapsed but the core-backed region was smaller (and thus had a zero-filled hole at the end), the collapse operation would break VMA to core file lookups for subsequent collapsed regions. This change fixes the following bug: http://llvm.org/bugs/show_bug.cgi?id=18769 llvm-svn: 201214
-rw-r--r--lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 93641ede1bc..a2b02d26d82 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -131,7 +131,8 @@ ProcessElfCore::AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader *head
VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back();
if (last_entry &&
last_entry->GetRangeEnd() == range_entry.GetRangeBase() &&
- last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase())
+ last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase() &&
+ last_entry->GetByteSize() == last_entry->data.GetByteSize())
{
last_entry->SetRangeEnd (range_entry.GetRangeEnd());
last_entry->data.SetRangeEnd (range_entry.data.GetRangeEnd());
@@ -294,9 +295,13 @@ ProcessElfCore::DoReadMemory (lldb::addr_t addr, void *buf, size_t size, Error &
size_t zero_fill_size = 0; // Padding
lldb::addr_t bytes_left = 0; // Number of bytes available in the core file from the given address
- if (file_end > offset)
- bytes_left = file_end - offset;
+ // Figure out how many on-disk bytes remain in this segment
+ // starting at the given offset
+ if (file_end > file_start + offset)
+ bytes_left = file_end - (file_start + offset);
+ // Figure out how many bytes we need to zero-fill if we are
+ // reading more bytes than available in the on-disk segment
if (bytes_to_read > bytes_left)
{
zero_fill_size = bytes_to_read - bytes_left;
OpenPOWER on IntegriCloud