Skip to content

Commit df2e611

Browse files
author
git apple-llvm automerger
committed
Merge commit '65998ab2cb50' from llvm.org/main into next
2 parents d21ca01 + 65998ab commit df2e611

File tree

13 files changed

+62
-57
lines changed

13 files changed

+62
-57
lines changed

lldb/include/lldb/Core/Debugger.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,13 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
131131

132132
void SetAsyncExecution(bool async);
133133

134-
lldb::FileSP GetInputFileSP() { return m_input_file_sp; }
135-
136-
lldb::StreamFileSP GetOutputStreamSP() { return m_output_stream_sp; }
137-
138-
lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
139-
140134
File &GetInputFile() { return *m_input_file_sp; }
141135

142-
File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
136+
lldb::FileSP GetInputFileSP() { return m_input_file_sp; }
137+
138+
lldb::FileSP GetOutputFileSP() { return m_output_stream_sp->GetFileSP(); }
143139

144-
File &GetErrorFile() { return m_error_stream_sp->GetFile(); }
140+
lldb::FileSP GetErrorFileSP() { return m_error_stream_sp->GetFileSP(); }
145141

146142
repro::DataRecorder *GetInputRecorder();
147143

@@ -658,6 +654,14 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
658654

659655
void PrintProgress(const ProgressEventData &data);
660656

657+
/// Except for Debugger and IOHandler, GetOutputStreamSP and GetErrorStreamSP
658+
/// should not be used directly. Use GetAsyncOutputStream and
659+
/// GetAsyncErrorStream instead.
660+
/// @{
661+
lldb::StreamFileSP GetOutputStreamSP() { return m_output_stream_sp; }
662+
lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
663+
/// @}
664+
661665
void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
662666
bool cancel_top_handler = true);
663667

lldb/include/lldb/Target/ThreadPlanTracer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ThreadPlanTracer {
5656
Process &m_process;
5757
lldb::tid_t m_tid;
5858

59-
Stream *GetLogStream();
59+
lldb::StreamSP GetLogStreamSP();
6060

6161
virtual void Log();
6262

lldb/source/API/SBDebugger.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,30 +509,30 @@ SBFile SBDebugger::GetInputFile() {
509509
FILE *SBDebugger::GetOutputFileHandle() {
510510
LLDB_INSTRUMENT_VA(this);
511511
if (m_opaque_sp)
512-
return m_opaque_sp->GetOutputStreamSP()->GetFile().GetStream();
512+
return m_opaque_sp->GetOutputFileSP()->GetStream();
513513
return nullptr;
514514
}
515515

516516
SBFile SBDebugger::GetOutputFile() {
517517
LLDB_INSTRUMENT_VA(this);
518518
if (m_opaque_sp)
519-
return SBFile(m_opaque_sp->GetOutputStreamSP()->GetFileSP());
519+
return SBFile(m_opaque_sp->GetOutputFileSP());
520520
return SBFile();
521521
}
522522

523523
FILE *SBDebugger::GetErrorFileHandle() {
524524
LLDB_INSTRUMENT_VA(this);
525525

526526
if (m_opaque_sp)
527-
return m_opaque_sp->GetErrorStreamSP()->GetFile().GetStream();
527+
return m_opaque_sp->GetErrorFileSP()->GetStream();
528528
return nullptr;
529529
}
530530

531531
SBFile SBDebugger::GetErrorFile() {
532532
LLDB_INSTRUMENT_VA(this);
533533
SBFile file;
534534
if (m_opaque_sp)
535-
return SBFile(m_opaque_sp->GetErrorStreamSP()->GetFileSP());
535+
return SBFile(m_opaque_sp->GetErrorFileSP());
536536
return SBFile();
537537
}
538538

@@ -573,8 +573,8 @@ void SBDebugger::HandleCommand(const char *command) {
573573

574574
sb_interpreter.HandleCommand(command, result, false);
575575

576-
result.PutError(m_opaque_sp->GetErrorStreamSP()->GetFileSP());
577-
result.PutOutput(m_opaque_sp->GetOutputStreamSP()->GetFileSP());
576+
result.PutError(m_opaque_sp->GetErrorFileSP());
577+
result.PutOutput(m_opaque_sp->GetOutputFileSP());
578578

579579
if (!m_opaque_sp->GetAsyncExecution()) {
580580
SBProcess process(GetCommandInterpreter().GetProcess());

lldb/source/Commands/CommandObjectGUI.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ void CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
2828
#if LLDB_ENABLE_CURSES
2929
Debugger &debugger = GetDebugger();
3030

31-
File &input = debugger.GetInputFile();
32-
File &output = debugger.GetOutputFile();
33-
if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
34-
input.GetIsInteractive()) {
31+
FileSP input_sp = debugger.GetInputFileSP();
32+
FileSP output_sp = debugger.GetOutputFileSP();
33+
if (input_sp->GetStream() && output_sp->GetStream() &&
34+
input_sp->GetIsRealTerminal() && input_sp->GetIsInteractive()) {
3535
IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
3636
if (io_handler_sp)
3737
debugger.RunIOHandlerAsync(io_handler_sp);

lldb/source/Commands/CommandObjectLog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ class CommandObjectLogDump : public CommandObjectParsed {
394394
(*file)->GetDescriptor(), /*shouldClose=*/true);
395395
} else {
396396
stream_up = std::make_unique<llvm::raw_fd_ostream>(
397-
GetDebugger().GetOutputFile().GetDescriptor(), /*shouldClose=*/false);
397+
GetDebugger().GetOutputFileSP()->GetDescriptor(),
398+
/*shouldClose=*/false);
398399
}
399400

400401
const std::string channel = std::string(args[0].ref());

lldb/source/Core/Debugger.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
947947
if (term && !strcmp(term, "dumb"))
948948
SetUseColor(false);
949949
// Turn off use-color if we don't write to a terminal with color support.
950-
if (!GetOutputFile().GetIsTerminalWithColors())
950+
if (!GetOutputFileSP()->GetIsTerminalWithColors())
951951
SetUseColor(false);
952952

953953
if (Diagnostics::Enabled()) {
@@ -1717,7 +1717,7 @@ bool Debugger::EnableLog(llvm::StringRef channel,
17171717
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
17181718
} else if (log_file.empty()) {
17191719
log_handler_sp =
1720-
CreateLogHandler(log_handler_kind, GetOutputFile().GetDescriptor(),
1720+
CreateLogHandler(log_handler_kind, GetOutputFileSP()->GetDescriptor(),
17211721
/*should_close=*/false, buffer_size);
17221722
} else {
17231723
auto pos = m_stream_handlers.find(log_file);
@@ -2163,8 +2163,8 @@ void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
21632163
// Determine whether the current output file is an interactive terminal with
21642164
// color support. We assume that if we support ANSI escape codes we support
21652165
// vt100 escape codes.
2166-
File &file = GetOutputFile();
2167-
if (!file.GetIsInteractive() || !file.GetIsTerminalWithColors())
2166+
FileSP file_sp = GetOutputFileSP();
2167+
if (!file_sp->GetIsInteractive() || !file_sp->GetIsTerminalWithColors())
21682168
return;
21692169

21702170
StreamSP output = GetAsyncOutputStream();

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,8 +2849,8 @@ void CommandInterpreter::HandleCommandsFromFile(
28492849
}
28502850

28512851
if (flags & eHandleCommandFlagPrintResult) {
2852-
debugger.GetOutputFile().Printf("Executing commands in '%s'.\n",
2853-
cmd_file_path.c_str());
2852+
debugger.GetOutputFileSP()->Printf("Executing commands in '%s'.\n",
2853+
cmd_file_path.c_str());
28542854
}
28552855

28562856
// Used for inheriting the right settings when "command source" might

lldb/source/Interpreter/ScriptInterpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(
245245
if (outfile_handle)
246246
::setbuf(outfile_handle, nullptr);
247247

248-
result->SetImmediateOutputFile(debugger.GetOutputStreamSP()->GetFileSP());
249-
result->SetImmediateErrorFile(debugger.GetErrorStreamSP()->GetFileSP());
248+
result->SetImmediateOutputFile(debugger.GetOutputFileSP());
249+
result->SetImmediateErrorFile(debugger.GetErrorFileSP());
250250
}
251251
}
252252

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader() {
11931193
m_kext_summary_header.version = data.GetU32(&offset);
11941194
if (m_kext_summary_header.version > 128) {
11951195
lldb::StreamSP s =
1196-
m_process->GetTarget().GetDebugger().GetOutputStreamSP();
1196+
m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
11971197
s->Printf("WARNING: Unable to read kext summary header, got "
11981198
"improbable version number %u\n",
11991199
m_kext_summary_header.version);
@@ -1208,7 +1208,7 @@ bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader() {
12081208
// If we get an improbably large entry_size, we're probably
12091209
// getting bad memory.
12101210
lldb::StreamSP s =
1211-
m_process->GetTarget().GetDebugger().GetOutputStreamSP();
1211+
m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
12121212
s->Printf("WARNING: Unable to read kext summary header, got "
12131213
"improbable entry_size %u\n",
12141214
m_kext_summary_header.entry_size);
@@ -1226,7 +1226,7 @@ bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader() {
12261226
// If we get an improbably large number of kexts, we're probably
12271227
// getting bad memory.
12281228
lldb::StreamSP s =
1229-
m_process->GetTarget().GetDebugger().GetOutputStreamSP();
1229+
m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
12301230
s->Printf("WARNING: Unable to read kext summary header, got "
12311231
"improbable number of kexts %u\n",
12321232
m_kext_summary_header.entry_count);
@@ -1330,7 +1330,8 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries(
13301330
number_of_old_kexts_being_removed == 0)
13311331
return true;
13321332

1333-
lldb::StreamSP s = m_process->GetTarget().GetDebugger().GetOutputStreamSP();
1333+
lldb::StreamSP s =
1334+
m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
13341335
if (load_kexts) {
13351336
if (number_of_new_kexts_being_added > 0 &&
13361337
number_of_old_kexts_being_removed > 0) {

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ StructuredData::ObjectSP InstrumentationRuntimeUBSan::RetrieveReportData(
116116
if (!frame_sp)
117117
return StructuredData::ObjectSP();
118118

119-
StreamFileSP Stream = target.GetDebugger().GetOutputStreamSP();
120-
121119
EvaluateExpressionOptions options;
122120
options.SetUnwindOnError(true);
123121
options.SetTryAllThreads(true);

0 commit comments

Comments
 (0)