Fixed the log streams for logs that output to

standard output, resolving a crasher.

llvm-svn: 106682
This commit is contained in:
Sean Callanan
2010-06-23 21:28:25 +00:00
parent 3183dd5692
commit 4be3990f3b
3 changed files with 2 additions and 119 deletions

View File

@@ -100,30 +100,6 @@ public:
static void
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
//------------------------------------------------------------------

View File

@@ -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 @@ public:
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
{

View File

@@ -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),