summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/StreamCallback.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-02-10 11:49:21 +0000
committerPavel Labath <labath@google.com>2017-02-10 11:49:21 +0000
commit5fae71c51cc8c3d51e86cd597ce91a254e9175f4 (patch)
tree07566b6e6ea25ad4cd1fe0138e69b3b15650d072 /lldb/source/Core/StreamCallback.cpp
parent30a02088c0dcf07dcb38bc9fd2f8221154cff449 (diff)
downloadbcm5719-llvm-5fae71c51cc8c3d51e86cd597ce91a254e9175f4.tar.gz
bcm5719-llvm-5fae71c51cc8c3d51e86cd597ce91a254e9175f4.zip
Convert Log class to llvm streams
Summary: This converts LLDB's logging to use llvm streams instead of lldb_private::Stream and friends. The changes are mostly straight-forward and amount to s/lldb_private::Stream/llvm::raw_ostream. The part worth calling out is the rewrite of the StreamCallback class. Previously this class contained a per-thread buffer of data written. I assume this had something to do with it trying to make sure each log line is delivered as a single event, instead of multiple (possibly interleaved) events. However, this is no longer relevant as the Log class already writes things to a temporary buffer and then delivers the message as a single "write", so I have just removed the code in question. Reviewers: zturner, clayborg Subscribers: emaste, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D29615 llvm-svn: 294736
Diffstat (limited to 'lldb/source/Core/StreamCallback.cpp')
-rw-r--r--lldb/source/Core/StreamCallback.cpp37
1 files changed, 4 insertions, 33 deletions
diff --git a/lldb/source/Core/StreamCallback.cpp b/lldb/source/Core/StreamCallback.cpp
index de784101e96..95f4293891a 100644
--- a/lldb/source/Core/StreamCallback.cpp
+++ b/lldb/source/Core/StreamCallback.cpp
@@ -7,44 +7,15 @@
//
//===----------------------------------------------------------------------===//
-#include <stdio.h>
-
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Event.h"
#include "lldb/Core/StreamCallback.h"
-#include "lldb/Host/Host.h"
-#include "lldb/lldb-private.h"
-using namespace lldb;
using namespace lldb_private;
StreamCallback::StreamCallback(lldb::LogOutputCallback callback, void *baton)
- : Stream(0, 4, eByteOrderBig), m_callback(callback), m_baton(baton),
- m_accumulated_data(), m_collection_mutex() {}
-
-StreamCallback::~StreamCallback() {}
+ : llvm::raw_ostream(true), m_callback(callback), m_baton(baton) {}
-StreamString &StreamCallback::FindStreamForThread(lldb::tid_t cur_tid) {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::iterator iter = m_accumulated_data.find(cur_tid);
- if (iter == m_accumulated_data.end()) {
- std::pair<collection::iterator, bool> ret;
- ret = m_accumulated_data.insert(
- std::pair<lldb::tid_t, StreamString>(cur_tid, StreamString()));
- iter = ret.first;
- }
- return (*iter).second;
+void StreamCallback::write_impl(const char *Ptr, size_t Size) {
+ m_callback(std::string(Ptr, Size).c_str(), m_baton);
}
-void StreamCallback::Flush() {
- lldb::tid_t cur_tid = Host::GetCurrentThreadID();
- StreamString &out_stream = FindStreamForThread(cur_tid);
- m_callback(out_stream.GetData(), m_baton);
- out_stream.Clear();
-}
-
-size_t StreamCallback::Write(const void *s, size_t length) {
- lldb::tid_t cur_tid = Host::GetCurrentThreadID();
- FindStreamForThread(cur_tid).Write(s, length);
- return length;
-}
+uint64_t StreamCallback::current_pos() const { return 0; }
OpenPOWER on IntegriCloud