[all-commits] [llvm/llvm-project] adb9ef: [lldb-dap] Partially reverting OutputRedirector ch...
John Harrison via All-commits
all-commits at lists.llvm.org
Thu Jan 30 16:35:36 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: adb9ef035552d7fc42a34560677f89f4f6421295
https://github.com/llvm/llvm-project/commit/adb9ef035552d7fc42a34560677f89f4f6421295
Author: John Harrison <harjohn at google.com>
Date: 2025-01-30 (Thu, 30 Jan 2025)
Changed paths:
M lldb/tools/lldb-dap/OutputRedirector.cpp
M lldb/tools/lldb-dap/OutputRedirector.h
Log Message:
-----------
[lldb-dap] Partially reverting OutputRedirector changes. (#125136)
I just noticed with these changes lldb-dap was using 200% of my CPU and
root causing the issue it seems that lldb_private::Pipe::Read() (without
a timeout) is using a timeout of `std::chrono::microseconds::zero()`
which ends up setting the SelectHelper timeout to `now + 0` (see
https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L314
and
https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Utility/SelectHelper.cpp#L46)
which causes SelectHelper to return immediately with a timeout error. As
a result the `lldb_dap::OutputRedirector::RedirectTo()` to turn into a
busy loop.
Additionally, the 'read' call is waiting until the output buffer is full
before returning, which prevents any partial output (see
https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L325C9-L326C17).
This is not the desired behavior for lldb-dap. Instead we want a write
to the FD to result in a callback to send the DAP Output event, which
mean we want partial output.
To mitigate this, I'm reverting the reading operation to the previous
behavior before 873426bea3dd67d80dd10650e64e91c69796614f but keeping the
refactored structure and thread management.
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