[all-commits] [llvm/llvm-project] c0b545: [lldb] Assorted improvements to the Pipe class (#1...

Pavel Labath via All-commits all-commits at lists.llvm.org
Thu Feb 27 02:16:21 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c0b5451129bba52e33cd7957d58af897a58d14c6
      https://github.com/llvm/llvm-project/commit/c0b5451129bba52e33cd7957d58af897a58d14c6
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2025-02-27 (Thu, 27 Feb 2025)

  Changed paths:
    M lldb/include/lldb/Host/PipeBase.h
    M lldb/include/lldb/Host/posix/PipePosix.h
    M lldb/include/lldb/Host/windows/PipeWindows.h
    M lldb/source/Host/common/PipeBase.cpp
    M lldb/source/Host/common/Socket.cpp
    M lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
    M lldb/source/Host/posix/MainLoopPosix.cpp
    M lldb/source/Host/posix/PipePosix.cpp
    M lldb/source/Host/windows/PipeWindows.cpp
    M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
    M lldb/source/Target/Process.cpp
    M lldb/tools/lldb-server/lldb-gdbserver.cpp
    M lldb/unittests/Host/PipeTest.cpp

  Log Message:
  -----------
  [lldb] Assorted improvements to the Pipe class (#128719)

The main motivation for this was the inconsistency in handling of
partial reads/writes between the windows and posix implementations
(windows was returning partial reads, posix was trying to fill the
buffer completely). I settle on the windows implementation, as that's
the more common behavior, and the "eager" version can be implemented on
top of that (in most cases, it isn't necessary, since we're writing just
a single byte).

Since this also required auditing the callers to make sure they're
handling partial reads/writes correctly, I used the opportunity to
modernize the function signatures as a forcing function. They now use
the `Timeout` class (basically an `optional<duration>`) to support both
polls (timeout=0) and blocking (timeout=nullopt) operations in a single
function, and use an `Expected` instead of a by-ref result to return the
number of bytes read/written.

As a drive-by, I also fix a problem with the windows implementation
where we were rounding the timeout value down, which meant that calls
could time out slightly sooner than expected.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list