@@ -257,7 +257,7 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
257257 std::list<Status> errors;
258258 StreamString feedback_stream;
259259 if (!target_sp->LoadScriptingResources (errors, feedback_stream)) {
260- lldb::StreamSP s = GetAsyncErrorStream ();
260+ lldb::StreamUP s = GetAsyncErrorStream ();
261261 for (auto &error : errors)
262262 s->Printf (" %s\n " , error.AsCString ());
263263 if (feedback_stream.GetSize ())
@@ -1328,13 +1328,13 @@ bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) {
13281328 return true ;
13291329}
13301330
1331- StreamSP Debugger::GetAsyncOutputStream () {
1332- return std::make_shared <StreamAsynchronousIO>(*this ,
1331+ StreamUP Debugger::GetAsyncOutputStream () {
1332+ return std::make_unique <StreamAsynchronousIO>(*this ,
13331333 StreamAsynchronousIO::STDOUT);
13341334}
13351335
1336- StreamSP Debugger::GetAsyncErrorStream () {
1337- return std::make_shared <StreamAsynchronousIO>(*this ,
1336+ StreamUP Debugger::GetAsyncErrorStream () {
1337+ return std::make_unique <StreamAsynchronousIO>(*this ,
13381338 StreamAsynchronousIO::STDERR);
13391339}
13401340
@@ -1577,8 +1577,7 @@ static void PrivateReportDiagnostic(Debugger &debugger, Severity severity,
15771577 // diagnostic directly to the debugger's error stream.
15781578 DiagnosticEventData event_data (severity, std::move (message),
15791579 debugger_specific);
1580- StreamSP stream = debugger.GetAsyncErrorStream ();
1581- event_data.Dump (stream.get ());
1580+ event_data.Dump (debugger.GetAsyncErrorStream ().get ());
15821581 return ;
15831582 }
15841583 EventSP event_sp = std::make_shared<Event>(
@@ -1774,12 +1773,11 @@ void Debugger::HandleBreakpointEvent(const EventSP &event_sp) {
17741773 if (num_new_locations > 0 ) {
17751774 BreakpointSP breakpoint =
17761775 Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event_sp);
1777- StreamSP output_sp (GetAsyncOutputStream ());
1778- if (output_sp) {
1779- output_sp->Printf (" %d location%s added to breakpoint %d\n " ,
1776+ if (StreamUP output_up = GetAsyncOutputStream ()) {
1777+ output_up->Printf (" %d location%s added to breakpoint %d\n " ,
17801778 num_new_locations, num_new_locations == 1 ? " " : " s" ,
17811779 breakpoint->GetID ());
1782- output_sp ->Flush ();
1780+ output_up ->Flush ();
17831781 }
17841782 }
17851783 }
@@ -1823,8 +1821,8 @@ void Debugger::HandleProcessEvent(const EventSP &event_sp) {
18231821 ? EventDataStructuredData::GetProcessFromEvent (event_sp.get ())
18241822 : Process::ProcessEventData::GetProcessFromEvent (event_sp.get ());
18251823
1826- StreamSP output_stream_sp = GetAsyncOutputStream ();
1827- StreamSP error_stream_sp = GetAsyncErrorStream ();
1824+ StreamUP output_stream_up = GetAsyncOutputStream ();
1825+ StreamUP error_stream_up = GetAsyncErrorStream ();
18281826 const bool gui_enabled = IsForwardingEvents ();
18291827
18301828 if (!gui_enabled) {
@@ -1849,7 +1847,7 @@ void Debugger::HandleProcessEvent(const EventSP &event_sp) {
18491847 if (got_state_changed && !state_is_stopped) {
18501848 // This is a public stop which we are going to announce to the user, so
18511849 // we should force the most relevant frame selection here.
1852- Process::HandleProcessStateChangedEvent (event_sp, output_stream_sp .get (),
1850+ Process::HandleProcessStateChangedEvent (event_sp, output_stream_up .get (),
18531851 SelectMostRelevantFrame,
18541852 pop_process_io_handler);
18551853 }
@@ -1865,37 +1863,35 @@ void Debugger::HandleProcessEvent(const EventSP &event_sp) {
18651863 if (plugin_sp) {
18661864 auto structured_data_sp =
18671865 EventDataStructuredData::GetObjectFromEvent (event_sp.get ());
1868- if (output_stream_sp) {
1869- StreamString content_stream;
1870- Status error =
1871- plugin_sp->GetDescription (structured_data_sp, content_stream);
1872- if (error.Success ()) {
1873- if (!content_stream.GetString ().empty ()) {
1874- // Add newline.
1875- content_stream.PutChar (' \n ' );
1876- content_stream.Flush ();
1877-
1878- // Print it.
1879- output_stream_sp->PutCString (content_stream.GetString ());
1880- }
1881- } else {
1882- error_stream_sp->Format (" Failed to print structured "
1883- " data with plugin {0}: {1}" ,
1884- plugin_sp->GetPluginName (), error);
1866+ StreamString content_stream;
1867+ Status error =
1868+ plugin_sp->GetDescription (structured_data_sp, content_stream);
1869+ if (error.Success ()) {
1870+ if (!content_stream.GetString ().empty ()) {
1871+ // Add newline.
1872+ content_stream.PutChar (' \n ' );
1873+ content_stream.Flush ();
1874+
1875+ // Print it.
1876+ output_stream_up->PutCString (content_stream.GetString ());
18851877 }
1878+ } else {
1879+ error_stream_up->Format (" Failed to print structured "
1880+ " data with plugin {0}: {1}" ,
1881+ plugin_sp->GetPluginName (), error);
18861882 }
18871883 }
18881884 }
18891885
18901886 // Now display any stopped state changes after any STDIO
18911887 if (got_state_changed && state_is_stopped) {
1892- Process::HandleProcessStateChangedEvent (event_sp, output_stream_sp .get (),
1888+ Process::HandleProcessStateChangedEvent (event_sp, output_stream_up .get (),
18931889 SelectMostRelevantFrame,
18941890 pop_process_io_handler);
18951891 }
18961892
1897- output_stream_sp ->Flush ();
1898- error_stream_sp ->Flush ();
1893+ output_stream_up ->Flush ();
1894+ error_stream_up ->Flush ();
18991895
19001896 if (pop_process_io_handler)
19011897 process_sp->PopProcessIOHandler ();
@@ -1995,22 +1991,18 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
19951991 const char *data = static_cast <const char *>(
19961992 EventDataBytes::GetBytesFromEvent (event_sp.get ()));
19971993 if (data && data[0 ]) {
1998- StreamSP error_sp (GetAsyncErrorStream ());
1999- if (error_sp) {
2000- error_sp->PutCString (data);
2001- error_sp->Flush ();
2002- }
1994+ StreamUP error_up = GetAsyncErrorStream ();
1995+ error_up->PutCString (data);
1996+ error_up->Flush ();
20031997 }
20041998 } else if (event_type & CommandInterpreter::
20051999 eBroadcastBitAsynchronousOutputData) {
20062000 const char *data = static_cast <const char *>(
20072001 EventDataBytes::GetBytesFromEvent (event_sp.get ()));
20082002 if (data && data[0 ]) {
2009- StreamSP output_sp (GetAsyncOutputStream ());
2010- if (output_sp) {
2011- output_sp->PutCString (data);
2012- output_sp->Flush ();
2013- }
2003+ StreamUP output_up = GetAsyncOutputStream ();
2004+ output_up->PutCString (data);
2005+ output_up->Flush ();
20142006 }
20152007 }
20162008 } else if (broadcaster == &m_broadcaster) {
@@ -2125,7 +2117,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
21252117 if (!file_sp->GetIsInteractive () || !file_sp->GetIsTerminalWithColors ())
21262118 return ;
21272119
2128- StreamSP output = GetAsyncOutputStream ();
2120+ StreamUP output = GetAsyncOutputStream ();
21292121
21302122 // Print over previous line, if any.
21312123 output->Printf (" \r " );
@@ -2175,8 +2167,7 @@ void Debugger::HandleDiagnosticEvent(const lldb::EventSP &event_sp) {
21752167 if (!data)
21762168 return ;
21772169
2178- StreamSP stream = GetAsyncErrorStream ();
2179- data->Dump (stream.get ());
2170+ data->Dump (GetAsyncErrorStream ().get ());
21802171}
21812172
21822173bool Debugger::HasIOHandlerThread () const {
0 commit comments