1 //===-- StreamCallback.h -----------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_StreamCallback_h_ 11 #define liblldb_StreamCallback_h_ 12 13 #include <string> 14 15 #include "lldb/Core/Stream.h" 16 #include "lldb/Core/StreamString.h" 17 #include "lldb/Host/Mutex.h" 18 19 namespace lldb_private { 20 21 class StreamCallback : 22 public Stream 23 { 24 public: 25 StreamCallback (lldb::LogOutputCallback callback, void *baton); 26 27 virtual ~StreamCallback (); 28 29 virtual void 30 Flush (); 31 32 virtual size_t 33 Write (const void *src, size_t src_len); 34 35 36 private: 37 typedef std::map<lldb::tid_t, StreamString> collection; 38 lldb::LogOutputCallback m_callback; 39 void *m_baton; 40 collection m_accumulated_data; 41 Mutex m_collection_mutex; 42 43 StreamString &FindStreamForThread(lldb::tid_t cur_tid); 44 }; 45 46 } // namespace lldb_private 47 #endif // #ifndef liblldb_StreamCallback_h 48