diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 | 
| commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
| tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /lldb/source/API/SBStream.cpp | |
| parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) | |
Notes
Diffstat (limited to 'lldb/source/API/SBStream.cpp')
| -rw-r--r-- | lldb/source/API/SBStream.cpp | 22 | 
1 files changed, 16 insertions, 6 deletions
| diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp index d57634d2947cd..eb81153084e8c 100644 --- a/lldb/source/API/SBStream.cpp +++ b/lldb/source/API/SBStream.cpp @@ -1,4 +1,4 @@ -//===-- SBStream.cpp ----------------------------------------*- C++ -*-===// +//===-- SBStream.cpp ------------------------------------------------------===//  //  // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.  // See https://llvm.org/LICENSE.txt for license information. @@ -26,7 +26,7 @@ SBStream::SBStream() : m_opaque_up(new StreamString()), m_is_file(false) {  SBStream::SBStream(SBStream &&rhs)      : m_opaque_up(std::move(rhs.m_opaque_up)), m_is_file(rhs.m_is_file) {} -SBStream::~SBStream() {} +SBStream::~SBStream() = default;  bool SBStream::IsValid() const {    LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, IsValid); @@ -60,6 +60,12 @@ size_t SBStream::GetSize() {    return static_cast<StreamString *>(m_opaque_up.get())->GetSize();  } +void SBStream::Print(const char *str) { +  LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str); + +  Printf("%s", str); +} +  void SBStream::Printf(const char *format, ...) {    if (!format)      return; @@ -81,7 +87,8 @@ void SBStream::RedirectToFile(const char *path, bool append) {      // See if we have any locally backed data. If so, copy it so we can then      // redirect it to the file so we don't lose the data      if (!m_is_file) -      local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); +      local_data = std::string( +          static_cast<StreamString *>(m_opaque_up.get())->GetString());    }    auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;    if (append) @@ -129,7 +136,8 @@ void SBStream::RedirectToFile(FileSP file_sp) {      // See if we have any locally backed data. If so, copy it so we can then      // redirect it to the file so we don't lose the data      if (!m_is_file) -      local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); +      local_data = std::string( +          static_cast<StreamString *>(m_opaque_up.get())->GetString());    }    m_opaque_up = std::make_unique<StreamFile>(file_sp); @@ -150,7 +158,8 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) {      // See if we have any locally backed data. If so, copy it so we can then      // redirect it to the file so we don't lose the data      if (!m_is_file) -      local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); +      local_data = std::string( +          static_cast<StreamString *>(m_opaque_up.get())->GetString());    }    m_opaque_up = std::make_unique<StreamFile>(fd, transfer_fh_ownership); @@ -168,7 +177,7 @@ lldb_private::Stream *SBStream::get() { return m_opaque_up.get(); }  lldb_private::Stream &SBStream::ref() {    if (m_opaque_up == nullptr) -    m_opaque_up.reset(new StreamString()); +    m_opaque_up = std::make_unique<StreamString>();    return *m_opaque_up;  } @@ -201,6 +210,7 @@ void RegisterMethods<SBStream>(Registry &R) {    LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));    LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));    LLDB_REGISTER_METHOD(void, SBStream, Clear, ()); +  LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));  }  } | 
