diff options
author | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-14 20:15:28 +0000 |
---|---|---|
committer | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-14 20:15:28 +0000 |
commit | 322f12afc3673fc868899857b069ce59084dba05 (patch) | |
tree | 306f102542cd3987d31eb51d27c965dae489182b /lldb/source/API/SBDebugger.cpp | |
parent | c5d14b5c6fa9e003ef2037dcd3601c8339b1e42f (diff) | |
download | bcm5719-llvm-322f12afc3673fc868899857b069ce59084dba05.tar.gz bcm5719-llvm-322f12afc3673fc868899857b069ce59084dba05.zip |
remove FILE* usage from ReportEventState() and HandleProcessEvent()
Summary:
This patch adds FileSP and SBFile versions of the API methods
ReportEventState and HandleProcessEvent. It points the SWIG
wrappers at these instead of the ones that use FILE* streams.
Reviewers: JDevlieghere, jasonmolenda, labath, jingham
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68546
llvm-svn: 374816
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 *)); |