Index: lldb/trunk/include/lldb/Host/File.h =================================================================== --- lldb/trunk/include/lldb/Host/File.h +++ lldb/trunk/include/lldb/Host/File.h @@ -54,13 +54,15 @@ : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), m_stream(kInvalidStream), m_options(0), m_own_stream(false), m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate) {} + m_is_real_terminal(eLazyBoolCalculate), + m_supports_colors(eLazyBoolCalculate) {} File(FILE *fh, bool transfer_ownership) : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), m_stream(fh), m_options(0), m_own_stream(transfer_ownership), m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate) {} + m_is_real_terminal(eLazyBoolCalculate), + m_supports_colors(eLazyBoolCalculate) {} //------------------------------------------------------------------ /// Constructor with path. Index: lldb/trunk/lit/Settings/TestDisableColor.test =================================================================== --- lldb/trunk/lit/Settings/TestDisableColor.test +++ lldb/trunk/lit/Settings/TestDisableColor.test @@ -0,0 +1,7 @@ +# RUN: %lldb -x -b -s %s | FileCheck %s +settings show use-color +q +# This tests that LLDB turns off use-color if the output file is not an +# interactive terminal. In this example, use-color should be off because LLDB +# is run just by the non-interactive lit test runner. +# CHECK: use-color (boolean) = false Index: lldb/trunk/lit/Settings/lit.local.cfg =================================================================== --- lldb/trunk/lit/Settings/lit.local.cfg +++ lldb/trunk/lit/Settings/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] Index: lldb/trunk/source/Core/Debugger.cpp =================================================================== --- lldb/trunk/source/Core/Debugger.cpp +++ lldb/trunk/source/Core/Debugger.cpp @@ -804,6 +804,9 @@ const char *term = getenv("TERM"); if (term && !strcmp(term, "dumb")) SetUseColor(false); + // Turn off use-color if we don't write to a terminal with color support. + if (!m_output_file_sp->GetFile().GetIsTerminalWithColors()) + SetUseColor(false); } Debugger::~Debugger() { Clear(); }