[Lldb-commits] [lldb] r106682 - in /lldb/trunk: include/lldb/Core/Log.h source/Commands/CommandObjectLog.cpp source/Core/Log.cpp

Sean Callanan scallanan at apple.com
Wed Jun 23 14:28:25 PDT 2010


Author: spyffe
Date: Wed Jun 23 16:28:25 2010
New Revision: 106682

URL: http://llvm.org/viewvc/llvm-project?rev=106682&view=rev
Log:
Fixed the log streams for logs that output to
standard output, resolving a crasher.

Modified:
    lldb/trunk/include/lldb/Core/Log.h
    lldb/trunk/source/Commands/CommandObjectLog.cpp
    lldb/trunk/source/Core/Log.cpp

Modified: lldb/trunk/include/lldb/Core/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=106682&r1=106681&r2=106682&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Log.h (original)
+++ lldb/trunk/include/lldb/Core/Log.h Wed Jun 23 16:28:25 2010
@@ -101,30 +101,6 @@
     ListAllLogChannels (Stream *strm);
 
     //------------------------------------------------------------------
-    // Static accessors to STDOUT logging facilities.
-    //------------------------------------------------------------------
-    static void
-    STDOUT (const char *format, ...);
-
-    static lldb::StreamSP
-    GetStreamForSTDOUT ();
-
-    static void
-    SetStreamForSTDOUT (lldb::StreamSP &stream_sp);
-
-    //------------------------------------------------------------------
-    // Static accessors to STDERR logging facilities.
-    //------------------------------------------------------------------
-    static void
-    STDERR (const char *format, ...);
-
-    static lldb::StreamSP
-    GetStreamForSTDERR ();
-
-    static void
-    SetStreamForSTDERR (lldb::StreamSP &stream_sp);
-
-    //------------------------------------------------------------------
     // Member functions
     //------------------------------------------------------------------
     Log ();

Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=106682&r1=106681&r2=106682&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectLog.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectLog.cpp Wed Jun 23 16:28:25 2010
@@ -27,6 +27,7 @@
 #include "lldb/Core/Timer.h"
 
 #include "lldb/Core/Debugger.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 
 #include "lldb/Symbol/LineTable.h"
@@ -94,16 +95,7 @@
 
             if (m_options.log_file.empty())
             {
-                std::string log_file("<lldb.debugger>");
-                LogStreamMap::iterator pos = m_log_streams.find(log_file);
-                if (pos == m_log_streams.end())
-                {
-                    log_stream_sp = Log::GetStreamForSTDOUT ();
-                    if (log_stream_sp)
-                        m_log_streams[log_file] = log_stream_sp;
-                }
-                else
-                    log_stream_sp = pos->second;
+                log_stream_sp.reset(new StreamFile(interpreter.GetDebugger().GetOutputFileHandle()));
             }
             else
             {

Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=106682&r1=106681&r2=106682&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Wed Jun 23 16:28:25 2010
@@ -32,91 +32,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static Stream *
-StreamForSTDOUTAccess (bool set, StreamSP &stream_sp)
-{
-    // Since we are in a shared library and we can't have global
-    // constructors, we need to control access to this static variable
-    // through an accessor function to get and set the value.
-    static StreamSP g_stream_sp;
-
-    if (set)
-        g_stream_sp = stream_sp;
-    else
-        stream_sp = g_stream_sp;
-
-    return stream_sp.get();
-}
-
-StreamSP
-Log::GetStreamForSTDOUT ()
-{
-    StreamSP stream_sp;
-    StreamForSTDOUTAccess (false, stream_sp);
-    return stream_sp;
-}
-
-void
-Log::SetStreamForSTDOUT (StreamSP &stream_sp)
-{
-    StreamForSTDOUTAccess (true, stream_sp);
-}
-
-void
-Log::STDOUT (const char *format, ...)
-{
-    StreamSP stream_sp;
-    if (StreamForSTDOUTAccess(false, stream_sp))
-    {
-        va_list args;
-        va_start (args, format);
-        stream_sp->PrintfVarArg(format, args);
-        va_end (args);
-    }
-}
-
-static Stream *
-StreamForSTDERRAccess (bool set, StreamSP &stream_sp)
-{
-    // Since we are in a shared library and we can't have global
-    // constructors, we need to control access to this static variable
-    // through an accessor function to get and set the value.
-    static StreamSP g_stream_sp;
-
-    if (set)
-        g_stream_sp = stream_sp;
-    else
-        stream_sp = g_stream_sp;
-    return stream_sp.get();
-}
-
-StreamSP
-Log::GetStreamForSTDERR ()
-{
-    StreamSP stream_sp;
-    StreamForSTDERRAccess (false, stream_sp);
-    return stream_sp;
-}
-
-void
-Log::SetStreamForSTDERR (StreamSP &stream_sp)
-{
-    StreamForSTDERRAccess (true, stream_sp);
-}
-
-void
-Log::STDERR (const char *format, ...)
-{
-    StreamSP stream_sp;
-    if (StreamForSTDERRAccess(false, stream_sp))
-    {
-        va_list args;
-        va_start (args, format);
-        stream_sp->PrintfVarArg(format, args);
-        va_end (args);
-    }
-}
-
 Log::Log () :
     m_stream_sp(),
     m_options(0),





More information about the lldb-commits mailing list