[Lldb-commits] [lldb] [lldb][windows] keep track of interrupted reads in ConnectionGenericFile (PR #182536)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 20 08:58:07 PST 2026
https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/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`.
>From f5688837a040f62f54cf1ca98798d4aee56bf105 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Fri, 20 Feb 2026 16:54:17 +0000
Subject: [PATCH] [lldb][windows] keep track of interrupted reads in
ConnectionGenericFile
---
.../lldb/Host/windows/ConnectionGenericFileWindows.h | 1 +
.../Host/windows/ConnectionGenericFileWindows.cpp | 10 ++++++++++
2 files changed, 11 insertions(+)
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..28727c82f6e37 100644
--- a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp
+++ b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp
@@ -176,9 +176,17 @@ 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);
+ m_read_pending = true;
if (result || ::GetLastError() == ERROR_IO_PENDING) {
if (!result) {
// The expected return path. The operation is pending. Wait for the
@@ -234,6 +242,8 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len,
goto finish;
finish:
+ if (return_info.GetStatus() != eConnectionStatusInterrupted)
+ m_read_pending = false;
status = return_info.GetStatus();
if (error_ptr)
*error_ptr = return_info.GetError().Clone();
More information about the lldb-commits
mailing list