Author: Charles Zablit Date: 2026-02-20T17:46:58Z New Revision: ef20b6a1caf1144ad70d762020564faabdd9626a
URL: https://github.com/llvm/llvm-project/commit/ef20b6a1caf1144ad70d762020564faabdd9626a DIFF: https://github.com/llvm/llvm-project/commit/ef20b6a1caf1144ad70d762020564faabdd9626a.diff LOG: [lldb][windows] keep track of interrupted reads in ConnectionGenericFile (#182536) If a read is interrupted in `ConnectionGenericFile::Read`, the data that has already been read by `ReadFile` is lost. This patch adds `m_read_pending` to mark a read as interrupted. The next read will pick up the results of the previous read and return the number of `bytes_read`. Added: Modified: lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h lldb/source/Host/windows/ConnectionGenericFileWindows.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h b/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h index d8f06a7162b22..62ac1bb35c9f8 100644 --- a/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h +++ b/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h @@ -43,6 +43,7 @@ class ConnectionGenericFile : public lldb_private::Connection { protected: OVERLAPPED m_overlapped; + bool m_read_pending = false; HANDLE m_file; HANDLE m_event_handles[2]; bool m_owns_file; diff --git a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp index 6a6153d6e34a0..dd317a6e217c2 100644 --- a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp +++ b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -176,6 +176,13 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, goto finish; } + if (m_read_pending) { + if (::GetOverlappedResult(m_file, &m_overlapped, &bytes_read, FALSE)) { + m_read_pending = false; + return bytes_read; + } + } + m_overlapped.hEvent = m_event_handles[kBytesAvailableEvent]; result = ::ReadFile(m_file, dst, dst_len, NULL, &m_overlapped); @@ -234,6 +241,7 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, goto finish; finish: + m_read_pending = return_info.GetStatus() == eConnectionStatusInterrupted; status = return_info.GetStatus(); if (error_ptr) *error_ptr = return_info.GetError().Clone(); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
