Skip to content

Cherrypick commits to synchronize the debugger output and error stream #10368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 28, 2025

Conversation

JDevlieghere
Copy link

No description provided.

Remove Debugger::GetOutputStream and Debugger::GetErrorStream in
preparation for replacing both with a new variant that needs to be
locked and hence can't be handed out like we do right now.

The patch replaces most uses with GetAsyncOutputStream and
GetAsyncErrorStream respectively. There methods return new StreamSP
objects that automatically get flushed on destruction.

See llvm#126630 for more details.

(cherry picked from commit eff3c34)
 - Remove _ap (auto_ptr) suffix with _up (unique_ptr) suffix
 - Move forward declaration from IOHandler.h to IOHandlerCursesGUI.h
 - Move curses namespace under lldb_private

Motivated by Alex' comment in llvm#126630.

(cherry picked from commit 776fa2d)
…7682)

This makes GetOutputStreamSP and GetErrorStreamSP protected members of
Debugger. Users who want to print to the debugger's stream should use
GetAsyncOutputStreamSP and GetAsyncErrorStreamSP instead and the few
remaining stragglers have been migrated.

(cherry picked from commit 65998ab)
A handful of minor improvements to StreamAsynchronousIO:

 - Document the class.
 - Use a named enum value to distinguishing between stdout and stderr.
 - Add missing period to comment.
 - Clear the string instead of assigning to it.
 - Eliminate color argument.

(cherry picked from commit 70e693c)
Implement ansi::StripAnsiTerminalCodes and fix a long standing bug where
using format strings in lldb's prompt resulted in an incorrect prompt
column width.

(cherry picked from commit 2841cdb)
This patch improves the synchronization of the debugger's output and error
streams using two new abstractions: `LockableStreamFile` and
`LockedStreamFile`.

 - `LockableStreamFile` is a wrapper around a `StreamFile` and a mutex. Client
   cannot use the `StreamFile` without calling `Lock`, which returns a
   `LockedStreamFile`.

 - `LockedStreamFile` is an RAII object that locks the stream for the duration
   of its existence.  As long as you hold on to the returned object you are
   permitted to write to the stream. The destruction of the object
   automatically flush the output stream.

(cherry picked from commit 58279d1)
Make StreamAsynchronousIO an unique_ptr instead of a shared_ptr. I tried
passing the class by value, but the llvm::raw_ostream forwarder stored
in the Stream parent class isn't movable and I don't think it's worth
changing that. Additionally, there's a few places that expect a
StreamSP, which are easily created from a StreamUP.

(cherry picked from commit 78d82d3)
@JDevlieghere JDevlieghere requested a review from a team as a code owner March 27, 2025 23:01
@JDevlieghere
Copy link
Author

@swift-ci test

@JDevlieghere JDevlieghere merged commit e52baa8 into stable/20240723 Mar 28, 2025
2 of 3 checks passed
@JDevlieghere JDevlieghere deleted the cherrypick-output-error-stream-locking branch March 28, 2025 01:26
@JDevlieghere JDevlieghere restored the cherrypick-output-error-stream-locking branch March 28, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants