diff options
Diffstat (limited to 'lldb/source/API/SBDebugger.cpp')
-rw-r--r-- | lldb/source/API/SBDebugger.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 1da6ed26b24..82dc6048900 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -494,8 +494,7 @@ void SBDebugger::HandleCommand(const char *command) { while (lldb_listener_sp->GetEventForBroadcaster( process_sp.get(), event_sp, std::chrono::seconds(0))) { SBEvent event(event_sp); - HandleProcessEvent(process, event, GetOutputFileHandle(), - GetErrorFileHandle()); + HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile()); } } } @@ -513,6 +512,17 @@ SBListener SBDebugger::GetListener() { } void SBDebugger::HandleProcessEvent(const SBProcess &process, + const SBEvent &event, SBFile out, + SBFile err) { + LLDB_RECORD_METHOD( + void, SBDebugger, HandleProcessEvent, + (const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile), process, + event, out, err); + + return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp); +} + +void SBDebugger::HandleProcessEvent(const SBProcess &process, const SBEvent &event, FILE *out, FILE *err) { LLDB_RECORD_METHOD( @@ -520,6 +530,20 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process, (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process, event, out, err); + FileSP outfile = std::make_shared<NativeFile>(out, false); + FileSP errfile = std::make_shared<NativeFile>(err, false); + return HandleProcessEvent(process, event, outfile, errfile); +} + +void SBDebugger::HandleProcessEvent(const SBProcess &process, + const SBEvent &event, FileSP out_sp, + FileSP err_sp) { + + LLDB_RECORD_METHOD( + void, SBDebugger, HandleProcessEvent, + (const lldb::SBProcess &, const lldb::SBEvent &, FileSP, FileSP), process, + event, out_sp, err_sp); + if (!process.IsValid()) return; @@ -537,16 +561,16 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process, (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) { // Drain stdout when we stop just in case we have any bytes while ((len = process.GetSTDOUT(stdio_buffer, sizeof(stdio_buffer))) > 0) - if (out != nullptr) - ::fwrite(stdio_buffer, 1, len, out); + if (out_sp) + out_sp->Write(stdio_buffer, len); } if (event_type & (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged)) { // Drain stderr when we stop just in case we have any bytes while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0) - if (err != nullptr) - ::fwrite(stdio_buffer, 1, len, err); + if (err_sp) + err_sp->Write(stdio_buffer, len); } if (event_type & Process::eBroadcastBitStateChanged) { @@ -557,7 +581,7 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process, bool is_stopped = StateIsStoppedState(event_state); if (!is_stopped) - process.ReportEventState(event, out); + process.ReportEventState(event, out_sp); } } @@ -1669,6 +1693,12 @@ template <> void RegisterMethods<SBDebugger>(Registry &R) { LLDB_REGISTER_METHOD( void, SBDebugger, HandleProcessEvent, (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *)); + LLDB_REGISTER_METHOD( + void, SBDebugger, HandleProcessEvent, + (const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile)); + LLDB_REGISTER_METHOD( + void, SBDebugger, HandleProcessEvent, + (const lldb::SBProcess &, const lldb::SBEvent &, FileSP, FileSP)); LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager, ()); LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, (const char *)); |