[Bug 45310] New: Save file fails while debugging is active on Windows

Bug ID 45310
Summary Save file fails while debugging is active on Windows
Product lldb
Version unspecified
Hardware PC
OS Windows NT
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter emrekultursay@google.com
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

On Windows, when LLDB hits a breakpoint in a large source file, the file is
locked and users can no longer edit the file. This causes trouble for users of
IDEs such as Android Studio, where users expect to be able to edit and save
files while they are debugging.

LLDB MemoryBuffer uses mmap for files larger than (4 * 4096) bytes. On Windows,
as long as the mapping is active, files cannot be overwritten.


1. SourceManager keeps m_last_file_sp to remember the most recently used file.
This keeps the mmapped region alive while a breakpoint is hit.

2. SourceFileCache keeps m_file_cache to remember all previously opened files.
This keeps all mmapped regions alive as long as LLDB is running. (see next

3. SourceFileCache.AddSourceFile is broken: It always adds bogus entry to the
cache, and therefore, cache insertions always conflict and cache lookups never

// Android Studio reported bug: [https://issuetracker.google.com/143436652](https://issuetracker.google.com/143436652)

Emre Kultursay changed bug 45310