diff options
Diffstat (limited to 'lldb/source/Plugins')
8 files changed, 76 insertions, 91 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 790e7866516..0c212735be7 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -773,12 +773,9 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( } if (IsKernel() && m_uuid.IsValid()) { - Stream *s = target.GetDebugger().GetOutputFile().get(); - if (s) { - s->Printf("Kernel UUID: %s\n", - m_uuid.GetAsString().c_str()); - s->Printf("Load Address: 0x%" PRIx64 "\n", m_load_address); - } + Stream &s = target.GetDebugger().GetOutputStream(); + s.Printf("Kernel UUID: %s\n", m_uuid.GetAsString().c_str()); + s.Printf("Load Address: 0x%" PRIx64 "\n", m_load_address); } if (!m_module_sp) { @@ -839,11 +836,9 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( } if (IsKernel() && !m_module_sp) { - Stream *s = target.GetDebugger().GetOutputFile().get(); - if (s) { - s->Printf("WARNING: Unable to locate kernel binary on the debugger " - "system.\n"); - } + Stream &s = target.GetDebugger().GetOutputStream(); + s.Printf("WARNING: Unable to locate kernel binary on the debugger " + "system.\n"); } } @@ -932,25 +927,24 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( bool is_loaded = IsLoaded(); if (is_loaded && m_module_sp && IsKernel()) { - Stream *s = target.GetDebugger().GetOutputFile().get(); - if (s) { - ObjectFile *kernel_object_file = m_module_sp->GetObjectFile(); - if (kernel_object_file) { - addr_t file_address = - kernel_object_file->GetBaseAddress().GetFileAddress(); - if (m_load_address != LLDB_INVALID_ADDRESS && - file_address != LLDB_INVALID_ADDRESS) { - s->Printf("Kernel slid 0x%" PRIx64 " in memory.\n", - m_load_address - file_address); - } + Stream &s = target.GetDebugger().GetOutputStream(); + ObjectFile *kernel_object_file = m_module_sp->GetObjectFile(); + if (kernel_object_file) { + addr_t file_address = + kernel_object_file->GetBaseAddress().GetFileAddress(); + if (m_load_address != LLDB_INVALID_ADDRESS && + file_address != LLDB_INVALID_ADDRESS) { + s.Printf("Kernel slid 0x%" PRIx64 " in memory.\n", + m_load_address - file_address); } - { - s->Printf("Loaded kernel file %s\n", - m_module_sp->GetFileSpec().GetPath().c_str()); - } - s->Flush(); } + { + s.Printf("Loaded kernel file %s\n", + m_module_sp->GetFileSpec().GetPath().c_str()); + } + s.Flush(); } + return is_loaded; } @@ -1109,11 +1103,10 @@ bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader() { lldb::offset_t offset = 0; m_kext_summary_header.version = data.GetU32(&offset); if (m_kext_summary_header.version > 128) { - Stream *s = - m_process->GetTarget().GetDebugger().GetOutputFile().get(); - s->Printf("WARNING: Unable to read kext summary header, got " - "improbable version number %u\n", - m_kext_summary_header.version); + Stream &s = m_process->GetTarget().GetDebugger().GetOutputStream(); + s.Printf("WARNING: Unable to read kext summary header, got " + "improbable version number %u\n", + m_kext_summary_header.version); // If we get an improbably large version number, we're probably // getting bad memory. m_kext_summary_header_addr.Clear(); @@ -1124,11 +1117,11 @@ bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader() { if (m_kext_summary_header.entry_size > 4096) { // If we get an improbably large entry_size, we're probably // getting bad memory. - Stream *s = - m_process->GetTarget().GetDebugger().GetOutputFile().get(); - s->Printf("WARNING: Unable to read kext summary header, got " - "improbable entry_size %u\n", - m_kext_summary_header.entry_size); + Stream &s = + m_process->GetTarget().GetDebugger().GetOutputStream(); + s.Printf("WARNING: Unable to read kext summary header, got " + "improbable entry_size %u\n", + m_kext_summary_header.entry_size); m_kext_summary_header_addr.Clear(); return false; } @@ -1142,11 +1135,10 @@ bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader() { if (m_kext_summary_header.entry_count > 10000) { // If we get an improbably large number of kexts, we're probably // getting bad memory. - Stream *s = - m_process->GetTarget().GetDebugger().GetOutputFile().get(); - s->Printf("WARNING: Unable to read kext summary header, got " - "improbable number of kexts %u\n", - m_kext_summary_header.entry_count); + Stream &s = m_process->GetTarget().GetDebugger().GetOutputStream(); + s.Printf("WARNING: Unable to read kext summary header, got " + "improbable number of kexts %u\n", + m_kext_summary_header.entry_count); m_kext_summary_header_addr.Clear(); return false; } @@ -1247,18 +1239,17 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries( number_of_old_kexts_being_removed == 0) return true; - Stream *s = m_process->GetTarget().GetDebugger().GetOutputFile().get(); - if (s && load_kexts) { + Stream &s = m_process->GetTarget().GetDebugger().GetOutputStream(); + if (load_kexts) { if (number_of_new_kexts_being_added > 0 && number_of_old_kexts_being_removed > 0) { - s->Printf("Loading %d kext modules and unloading %d kext modules ", - number_of_new_kexts_being_added, - number_of_old_kexts_being_removed); + s.Printf("Loading %d kext modules and unloading %d kext modules ", + number_of_new_kexts_being_added, + number_of_old_kexts_being_removed); } else if (number_of_new_kexts_being_added > 0) { - s->Printf("Loading %d kext modules ", number_of_new_kexts_being_added); + s.Printf("Loading %d kext modules ", number_of_new_kexts_being_added); } else if (number_of_old_kexts_being_removed > 0) { - s->Printf("Unloading %d kext modules ", - number_of_old_kexts_being_removed); + s.Printf("Unloading %d kext modules ", number_of_old_kexts_being_removed); } } @@ -1304,11 +1295,11 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries( m_process->GetStopID() == image_info.GetProcessStopId()) loaded_module_list.AppendIfNeeded(image_info.GetModule()); - if (s && load_kexts) { + if (load_kexts) { if (kext_successfully_added) - s->Printf("."); + s.Printf("."); else - s->Printf("-"); + s.Printf("-"); } if (log) @@ -1330,8 +1321,7 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries( if (image_info.GetModule()) { unloaded_module_list.AppendIfNeeded(image_info.GetModule()); } - if (s) - s->Printf("."); + s.Printf("."); image_info.Clear(); // should pull it out of the KextImageInfos vector but that would // mutate the list and invalidate the to_be_removed bool vector; @@ -1342,12 +1332,12 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries( } } - if (s && load_kexts) { - s->Printf(" done.\n"); + if (load_kexts) { + s.Printf(" done.\n"); if (kexts_failed_to_load.size() > 0 && number_of_new_kexts_being_added > 0) { - s->Printf("Failed to load %d of %d kexts:\n", - (int)kexts_failed_to_load.size(), - number_of_new_kexts_being_added); + s.Printf("Failed to load %d of %d kexts:\n", + (int)kexts_failed_to_load.size(), + number_of_new_kexts_being_added); // print a sorted list of <kext-name, uuid> kexts which failed to load unsigned longest_name = 0; std::sort(kexts_failed_to_load.begin(), kexts_failed_to_load.end()); @@ -1359,10 +1349,10 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries( std::string uuid; if (ku.second.IsValid()) uuid = ku.second.GetAsString(); - s->Printf (" %-*s %s\n", longest_name, ku.first.c_str(), uuid.c_str()); + s.Printf(" %-*s %s\n", longest_name, ku.first.c_str(), uuid.c_str()); } } - s->Flush(); + s.Flush(); } return true; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 593348fbeb0..d632805a96f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -1223,12 +1223,10 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution( type_system_helper->DeclMap(); // result can be NULL if (decl_map) { - Stream *error_stream = nullptr; Target *target = exe_ctx.GetTargetPtr(); - error_stream = target->GetDebugger().GetErrorFile().get(); - + auto &error_stream = target->GetDebugger().GetErrorStream(); IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(), - *execution_unit_sp, *error_stream, + *execution_unit_sp, error_stream, function_name.AsCString()); bool ir_can_run = diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp index c8ac04641e6..2e5dd5989e7 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp @@ -264,7 +264,7 @@ bool AddressSanitizerRuntime::NotifyBreakpointHit( *thread_sp, description, report)); StreamFileSP stream_sp( - process_sp->GetTarget().GetDebugger().GetOutputFile()); + process_sp->GetTarget().GetDebugger().GetOutputStreamSP()); if (stream_sp) { stream_sp->Printf("AddressSanitizer report breakpoint hit. Use 'thread " "info -s' to get extended information about the " diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp index 89f2139db71..45a3aeeb204 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp @@ -863,13 +863,11 @@ bool ThreadSanitizerRuntime::NotifyBreakpointHit( CreateStopReasonWithInstrumentationData( *thread_sp, stop_reason_description, report)); - StreamFileSP stream_sp( - process_sp->GetTarget().GetDebugger().GetOutputFile()); - if (stream_sp) { - stream_sp->Printf("ThreadSanitizer report breakpoint hit. Use 'thread " - "info -s' to get extended information about the " - "report.\n"); - } + StreamFile &s = process_sp->GetTarget().GetDebugger().GetOutputStream(); + s.Printf("ThreadSanitizer report breakpoint hit. Use 'thread " + "info -s' to get extended information about the " + "report.\n"); + return true; // Return true to stop the target } else return false; // Let target run diff --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp index 367098bb448..50f1d48d03e 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp @@ -124,7 +124,7 @@ StructuredData::ObjectSP UndefinedBehaviorSanitizerRuntime::RetrieveReportData( if (!frame_sp) return StructuredData::ObjectSP(); - StreamFileSP Stream(target.GetDebugger().GetOutputFile()); + StreamFileSP Stream = target.GetDebugger().GetOutputStreamSP(); EvaluateExpressionOptions options; options.SetUnwindOnError(true); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 3be07937eea..379ef3dca86 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -704,7 +704,7 @@ AppleObjCTrampolineHandler::AppleObjCTrampolineHandler( // step through any method dispatches. Warn to that effect and get out of // here. if (process_sp->CanJIT()) { - process_sp->GetTarget().GetDebugger().GetErrorFile()->Printf( + process_sp->GetTarget().GetDebugger().GetErrorStream().Printf( "Could not find implementation lookup function \"%s\"" " step in through ObjC method dispatch will not work.\n", get_impl_name.AsCString()); diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp index 7b959837955..3517f831970 100644 --- a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp @@ -28,13 +28,13 @@ ScriptInterpreterNone::~ScriptInterpreterNone() {} bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command, CommandReturnObject *, const ExecuteScriptOptions &) { - m_debugger.GetErrorFile()->PutCString( + m_debugger.GetErrorStream().PutCString( "error: there is no embedded script interpreter in this mode.\n"); return false; } void ScriptInterpreterNone::ExecuteInterpreterLoop() { - m_debugger.GetErrorFile()->PutCString( + m_debugger.GetErrorStream().PutCString( "error: there is no embedded script interpreter in this mode.\n"); } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 1d130672825..4019a572f22 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -536,7 +536,7 @@ def function (frame, bp_loc, internal_dict): } if (instructions) { - StreamFileSP output_sp(io_handler.GetOutputStreamFile()); + StreamFileSP output_sp(io_handler.GetOutputStreamFileSP()); if (output_sp && interactive) { output_sp->PutCString(instructions); output_sp->Flush(); @@ -572,7 +572,7 @@ void ScriptInterpreterPythonImpl::IOHandlerInputComplete(IOHandler &io_handler, bp_options->SetCallback( ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp); } else if (!batch_mode) { - StreamFileSP error_sp = io_handler.GetErrorStreamFile(); + StreamFileSP error_sp = io_handler.GetErrorStreamFileSP(); if (error_sp) { error_sp->Printf("Warning: No command attached to breakpoint.\n"); error_sp->Flush(); @@ -594,7 +594,7 @@ void ScriptInterpreterPythonImpl::IOHandlerInputComplete(IOHandler &io_handler, wp_options->SetCallback( ScriptInterpreterPythonImpl::WatchpointCallbackFunction, baton_sp); } else if (!batch_mode) { - StreamFileSP error_sp = io_handler.GetErrorStreamFile(); + StreamFileSP error_sp = io_handler.GetErrorStreamFileSP(); if (error_sp) { error_sp->Printf("Warning: No command attached to breakpoint.\n"); error_sp->Flush(); @@ -723,7 +723,7 @@ bool ScriptInterpreterPythonImpl::EnterSession(uint16_t on_entry_flags, File out_file(out, false); File err_file(err, false); - lldb::StreamFileSP in_sp; + lldb::FileSP in_sp; lldb::StreamFileSP out_sp; lldb::StreamFileSP err_sp; if (!in_file.IsValid() || !out_file.IsValid() || !err_file.IsValid()) @@ -734,7 +734,7 @@ bool ScriptInterpreterPythonImpl::EnterSession(uint16_t on_entry_flags, } else { if (!SetStdHandle(in_file, "stdin", m_saved_stdin, "r")) { if (in_sp) - SetStdHandle(in_sp->GetFile(), "stdin", m_saved_stdin, "r"); + SetStdHandle(*in_sp, "stdin", m_saved_stdin, "r"); } } @@ -853,7 +853,7 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine( // directly down to Python. Debugger &debugger = m_debugger; - StreamFileSP input_file_sp; + FileSP input_file_sp; StreamFileSP output_file_sp; StreamFileSP error_file_sp; Communication output_comm( @@ -861,7 +861,7 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine( bool join_read_thread = false; if (options.GetEnableIO()) { if (result) { - input_file_sp = debugger.GetInputFile(); + input_file_sp = debugger.GetInputFileSP(); // Set output to a temporary file so we can forward the results on to // the result object @@ -892,9 +892,8 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine( ::setbuf(outfile_handle, nullptr); result->SetImmediateOutputFile( - debugger.GetOutputFile()->GetFile().GetStream()); - result->SetImmediateErrorFile( - debugger.GetErrorFile()->GetFile().GetStream()); + debugger.GetOutputFile().GetStream()); + result->SetImmediateErrorFile(debugger.GetErrorFile().GetStream()); } } } @@ -918,11 +917,11 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine( llvm::fmt_consume(nullout.takeError())); return false; } - input_file_sp = std::make_shared<StreamFile>(std::move(nullin.get())); + input_file_sp = std::move(nullin.get()); error_file_sp = output_file_sp = std::make_shared<StreamFile>(std::move(nullout.get())); } - FILE *in_file = input_file_sp->GetFile().GetStream(); + FILE *in_file = input_file_sp->GetStream(); FILE *out_file = output_file_sp->GetFile().GetStream(); FILE *err_file = error_file_sp->GetFile().GetStream(); bool success = false; @@ -1013,7 +1012,7 @@ void ScriptInterpreterPythonImpl::ExecuteInterpreterLoop() { // a running interpreter loop inside the already running Python interpreter // loop, so we won't do it. - if (!debugger.GetInputFile()->GetFile().IsValid()) + if (!debugger.GetInputFile().IsValid()) return; IOHandlerSP io_handler_sp(new IOHandlerPythonInterpreter(debugger, this)); |