diff options
author | Greg Clayton <gclayton@apple.com> | 2013-02-06 17:22:03 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-02-06 17:22:03 +0000 |
commit | 5ce9c5657cb77c0f1919be0aa3c990009a7bc60b (patch) | |
tree | aca6aa117e81783b21300ba0ff86b126ef7035e6 /lldb/source/Core/DataBufferMemoryMap.cpp | |
parent | 0e1cf09c89343dbbe14490c550ab1fc74b642003 (diff) | |
download | bcm5719-llvm-5ce9c5657cb77c0f1919be0aa3c990009a7bc60b.tar.gz bcm5719-llvm-5ce9c5657cb77c0f1919be0aa3c990009a7bc60b.zip |
<rdar://problem/13159777>
lldb was mmap'ing archive files once per .o file it loads, now it correctly shares the archive between modules.
LLDB was also always mapping entire contents of universal mach-o files, now it maps just the slice that is required.
Added a new logging channel for "lldb" called "mmap" to help track future regressions.
Modified the ObjectFile and ObjectContainer plugin interfaces to take a data offset along with the file offset and size so we can implement the correct caching and efficient reading of parts of files without mmap'ing the entire file like we used to.
The current implementation still keeps entire .a files mmaped (once) and entire slices from universal files mmaped to ensure that if a client builds their binaries during a debug session we don't lose our data and get corrupt object file info and debug info.
llvm-svn: 174524
Diffstat (limited to 'lldb/source/Core/DataBufferMemoryMap.cpp')
-rw-r--r-- | lldb/source/Core/DataBufferMemoryMap.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lldb/source/Core/DataBufferMemoryMap.cpp b/lldb/source/Core/DataBufferMemoryMap.cpp index 0a94f57e40a..2b85ef49549 100644 --- a/lldb/source/Core/DataBufferMemoryMap.cpp +++ b/lldb/source/Core/DataBufferMemoryMap.cpp @@ -19,7 +19,10 @@ #include "lldb/Host/File.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" +#include "lldb/Core/Log.h" +#include "lldb/lldb-private-log.h" +using namespace lldb; using namespace lldb_private; //---------------------------------------------------------------------- @@ -80,6 +83,9 @@ DataBufferMemoryMap::Clear() { if (m_mmap_addr != NULL) { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP)); + if (log) + log->Printf("DataBufferMemoryMap::Clear() m_mmap_addr = %p, m_mmap_size = %zu", m_mmap_addr, m_mmap_size); ::munmap((void *)m_mmap_addr, m_mmap_size); m_mmap_addr = NULL; m_mmap_size = 0; @@ -104,6 +110,18 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec, { if (filespec != NULL) { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP)); + if (log) + { + log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(file=\"%s/%s\", offset=0x%" PRIx64 ", length=0x%zx, writeable=%i", + filespec->GetDirectory().GetCString(), + filespec->GetFilename().GetCString(), + offset, + length, + writeable); + } + if (length > 0x20000000) + puts("remove this line"); char path[PATH_MAX]; if (filespec->GetPath(path, sizeof(path))) { @@ -148,6 +166,16 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, Clear(); if (fd >= 0) { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP|LIBLLDB_LOG_VERBOSE)); + if (log) + { + log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%i, offset=0x%" PRIx64 ", length=0x%zx, writeable=%i, fd_is_file=%i)", + fd, + offset, + length, + writeable, + fd_is_file); + } struct stat stat; if (::fstat(fd, &stat) == 0) { @@ -175,10 +203,10 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, flags |= MAP_FILE; m_mmap_addr = (uint8_t *)::mmap(NULL, length, prot, flags, fd, offset); + Error error; if (m_mmap_addr == (void*)-1) { - Error error; error.SetErrorToErrno (); if (error.GetError() == EINVAL) { @@ -219,6 +247,12 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, m_data = m_mmap_addr; m_size = length; } + + if (log) + { + log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec() m_mmap_addr = %p, m_mmap_size = %zu, error = %s", + m_mmap_addr, m_mmap_size, error.AsCString()); + } } } } |