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/SBProcess.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/SBProcess.cpp')
-rw-r--r-- | lldb/source/API/SBProcess.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 59e9608b76f..45aaa0bd2d8 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -29,11 +29,11 @@ #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" - #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" +#include "lldb/API/SBFile.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBMemoryRegionInfo.h" #include "lldb/API/SBMemoryRegionInfoList.h" @@ -331,23 +331,34 @@ lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options, return LLDB_RECORD_RESULT(trace_instance); } +void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const { + LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, + (const SBEvent &, SBFile), event, out); + + return ReportEventState(event, out.m_opaque_sp); +} + void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const { LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, (const lldb::SBEvent &, FILE *), event, out); + FileSP outfile = std::make_shared<NativeFile>(out, false); + return ReportEventState(event, outfile); +} + +void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const { - if (out == nullptr) + LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, + (const SBEvent &, FileSP), event, out); + + if (!out || !out->IsValid()) return; ProcessSP process_sp(GetSP()); if (process_sp) { + StreamFile stream(out); const StateType event_state = SBProcess::GetStateFromEvent(event); - char message[1024]; - int message_len = ::snprintf( - message, sizeof(message), "Process %" PRIu64 " %s\n", + stream.Printf("Process %" PRIu64 " %s\n", process_sp->GetID(), SBDebugger::StateAsCString(event_state)); - - if (message_len > 0) - ::fwrite(message, 1, message_len, out); } } @@ -1310,6 +1321,10 @@ void RegisterMethods<SBProcess>(Registry &R) { (lldb::SBTraceOptions &, lldb::SBError &)); LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, (const lldb::SBEvent &, FILE *)); + LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, + (const lldb::SBEvent &, FileSP)); + LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, + (const lldb::SBEvent &, SBFile)); LLDB_REGISTER_METHOD( void, SBProcess, AppendEventStateReport, (const lldb::SBEvent &, lldb::SBCommandReturnObject &)); |