Skip to content

Commit 9a5f04e

Browse files
committed
Revert "[lldb] Synchronize output through the IOHandler"
This reverts commit 242c574 because it breaks the following tests on the bots: - TestGuiExpandThreadsTree.py - TestBreakpointCallbackCommandSource.py
1 parent 1c99f65 commit 9a5f04e

File tree

7 files changed

+19
-38
lines changed

7 files changed

+19
-38
lines changed

lldb/include/lldb/Core/IOHandler.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,11 @@ class IOHandler {
165165

166166
virtual void PrintAsync(const char *s, size_t len, bool is_stdout);
167167

168-
std::mutex &GetOutputMutex() { return m_output_mutex; }
169-
170168
protected:
171169
Debugger &m_debugger;
172170
lldb::FileSP m_input_sp;
173171
lldb::StreamFileSP m_output_sp;
174172
lldb::StreamFileSP m_error_sp;
175-
std::mutex m_output_mutex;
176173
repro::DataRecorder *m_data_recorder;
177174
Predicate<bool> m_popped;
178175
Flags m_flags;

lldb/include/lldb/Host/Editline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ using namespace line_editor;
154154
class Editline {
155155
public:
156156
Editline(const char *editor_name, FILE *input_file, FILE *output_file,
157-
FILE *error_file, std::mutex &output_mutex, bool color_prompts);
157+
FILE *error_file, bool color_prompts);
158158

159159
~Editline();
160160

@@ -402,7 +402,7 @@ class Editline {
402402
std::string m_suggestion_ansi_suffix;
403403

404404
std::size_t m_previous_autosuggestion_size = 0;
405-
std::mutex &m_output_mutex;
405+
std::mutex m_output_mutex;
406406
};
407407
}
408408

lldb/include/lldb/Interpreter/CommandInterpreter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,7 @@ class CommandInterpreter : public Broadcaster,
655655
const CommandObject::CommandMap &command_map);
656656

657657
// An interruptible wrapper around the stream output
658-
void PrintCommandOutput(IOHandler &io_handler, llvm::StringRef str,
659-
bool is_stdout);
658+
void PrintCommandOutput(Stream &stream, llvm::StringRef str);
660659

661660
bool EchoCommandNonInteractive(llvm::StringRef line,
662661
const Flags &io_handler_flags) const;

lldb/source/Core/IOHandler.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ void IOHandler::SetPopped(bool b) { m_popped.SetValue(b, eBroadcastOnChange); }
123123
void IOHandler::WaitForPop() { m_popped.WaitForValueEqualTo(true); }
124124

125125
void IOHandler::PrintAsync(const char *s, size_t len, bool is_stdout) {
126-
std::lock_guard<std::mutex> guard(m_output_mutex);
127126
lldb::StreamFileSP stream = is_stdout ? m_output_sp : m_error_sp;
128127
stream->Write(s, len);
129128
stream->Flush();
@@ -267,9 +266,9 @@ IOHandlerEditline::IOHandlerEditline(
267266
m_input_sp && m_input_sp->GetIsRealTerminal();
268267

269268
if (use_editline) {
270-
m_editline_up = std::make_unique<Editline>(
271-
editline_name, GetInputFILE(), GetOutputFILE(), GetErrorFILE(),
272-
GetOutputMutex(), m_color_prompts);
269+
m_editline_up = std::make_unique<Editline>(editline_name, GetInputFILE(),
270+
GetOutputFILE(), GetErrorFILE(),
271+
m_color_prompts);
273272
m_editline_up->SetIsInputCompleteCallback(
274273
[this](Editline *editline, StringList &lines) {
275274
return this->IsInputCompleteCallback(editline, lines);
@@ -620,7 +619,6 @@ void IOHandlerEditline::GotEOF() {
620619
void IOHandlerEditline::PrintAsync(const char *s, size_t len, bool is_stdout) {
621620
#if LLDB_ENABLE_LIBEDIT
622621
if (m_editline_up) {
623-
std::lock_guard<std::mutex> guard(m_output_mutex);
624622
lldb::StreamFileSP stream = is_stdout ? m_output_sp : m_error_sp;
625623
m_editline_up->PrintAsync(stream.get(), s, len);
626624
} else

lldb/source/Host/common/Editline.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,12 +1376,10 @@ Editline *Editline::InstanceFor(EditLine *editline) {
13761376
}
13771377

13781378
Editline::Editline(const char *editline_name, FILE *input_file,
1379-
FILE *output_file, FILE *error_file,
1380-
std::mutex &output_mutex, bool color_prompts)
1379+
FILE *output_file, FILE *error_file, bool color_prompts)
13811380
: m_editor_status(EditorStatus::Complete), m_color_prompts(color_prompts),
13821381
m_input_file(input_file), m_output_file(output_file),
1383-
m_error_file(error_file), m_input_connection(fileno(input_file), false),
1384-
m_output_mutex(output_mutex) {
1382+
m_error_file(error_file), m_input_connection(fileno(input_file), false) {
13851383
// Get a shared history instance
13861384
m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name;
13871385
m_history_sp = EditlineHistory::GetHistory(m_editor_name);

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,12 +2975,8 @@ bool CommandInterpreter::WasInterrupted() const {
29752975
return was_interrupted;
29762976
}
29772977

2978-
void CommandInterpreter::PrintCommandOutput(IOHandler &io_handler,
2979-
llvm::StringRef str,
2980-
bool is_stdout) {
2981-
2982-
lldb::StreamFileSP stream = is_stdout ? io_handler.GetOutputStreamFileSP()
2983-
: io_handler.GetErrorStreamFileSP();
2978+
void CommandInterpreter::PrintCommandOutput(Stream &stream,
2979+
llvm::StringRef str) {
29842980
// Split the output into lines and poll for interrupt requests
29852981
const char *data = str.data();
29862982
size_t size = str.size();
@@ -2993,19 +2989,15 @@ void CommandInterpreter::PrintCommandOutput(IOHandler &io_handler,
29932989
break;
29942990
}
29952991
}
2996-
{
2997-
std::lock_guard<std::mutex> guard(io_handler.GetOutputMutex());
2998-
chunk_size = stream->Write(data, chunk_size);
2999-
}
2992+
chunk_size = stream.Write(data, chunk_size);
30002993
lldbassert(size >= chunk_size);
30012994
data += chunk_size;
30022995
size -= chunk_size;
30032996
}
3004-
3005-
std::lock_guard<std::mutex> guard(io_handler.GetOutputMutex());
3006-
if (size > 0)
3007-
stream->Printf("\n... Interrupted.\n");
3008-
stream->Flush();
2997+
if (size > 0) {
2998+
stream.Printf("\n... Interrupted.\n");
2999+
}
3000+
stream.Flush();
30093001
}
30103002

30113003
bool CommandInterpreter::EchoCommandNonInteractive(
@@ -3041,11 +3033,9 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
30413033
// When using a non-interactive file handle (like when sourcing commands
30423034
// from a file) we need to echo the command out so we don't just see the
30433035
// command output and no command...
3044-
if (EchoCommandNonInteractive(line, io_handler.GetFlags())) {
3045-
std::lock_guard<std::mutex> guard(io_handler.GetOutputMutex());
3036+
if (EchoCommandNonInteractive(line, io_handler.GetFlags()))
30463037
io_handler.GetOutputStreamFileSP()->Printf(
30473038
"%s%s\n", io_handler.GetPrompt(), line.c_str());
3048-
}
30493039
}
30503040

30513041
StartHandlingCommand();
@@ -3067,13 +3057,13 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
30673057

30683058
if (!result.GetImmediateOutputStream()) {
30693059
llvm::StringRef output = result.GetOutputData();
3070-
PrintCommandOutput(io_handler, output, true);
3060+
PrintCommandOutput(*io_handler.GetOutputStreamFileSP(), output);
30713061
}
30723062

30733063
// Now emit the command error text from the command we just executed
30743064
if (!result.GetImmediateErrorStream()) {
30753065
llvm::StringRef error = result.GetErrorData();
3076-
PrintCommandOutput(io_handler, error, false);
3066+
PrintCommandOutput(*io_handler.GetErrorStreamFileSP(), error);
30773067
}
30783068
}
30793069

lldb/unittests/Editline/EditlineTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class EditlineAdapter {
8484
bool IsInputComplete(lldb_private::Editline *editline,
8585
lldb_private::StringList &lines);
8686

87-
std::mutex output_mutex;
8887
std::unique_ptr<lldb_private::Editline> _editline_sp;
8988

9089
PseudoTerminal _pty;
@@ -118,7 +117,7 @@ EditlineAdapter::EditlineAdapter()
118117
// Create an Editline instance.
119118
_editline_sp.reset(new lldb_private::Editline(
120119
"gtest editor", *_el_secondary_file, *_el_secondary_file,
121-
*_el_secondary_file, output_mutex, false));
120+
*_el_secondary_file, false));
122121
_editline_sp->SetPrompt("> ");
123122

124123
// Hookup our input complete callback.

0 commit comments

Comments
 (0)