diff --git a/hphp/runtime/base/runtime_option.cpp b/hphp/runtime/base/runtime_option.cpp index 9f2438681..aa3f83f3c 100644 --- a/hphp/runtime/base/runtime_option.cpp +++ b/hphp/runtime/base/runtime_option.cpp @@ -436,6 +436,7 @@ std::string RuntimeOption::SandboxDirectoriesRoot; std::string RuntimeOption::SandboxLogsRoot; bool RuntimeOption::EnableDebugger = false; +bool RuntimeOption::EnableDebuggerColor = true; bool RuntimeOption::EnableDebuggerServer = false; bool RuntimeOption::EnableDebuggerUsageLog = false; int RuntimeOption::DebuggerServerPort = 8089; @@ -1173,6 +1174,7 @@ void RuntimeOption::Load(Hdf &config, StringVec *overwrites /* = NULL */, { Hdf debugger = eval["Debugger"]; EnableDebugger = debugger["EnableDebugger"].getBool(); + EnableDebuggerColor = debugger["EnableDebuggerColor"].getBool(true); EnableDebuggerServer = debugger["EnableDebuggerServer"].getBool(); EnableDebuggerUsageLog = debugger["EnableDebuggerUsageLog"].getBool(); DebuggerServerPort = debugger["Port"].getUInt16(8089); diff --git a/hphp/runtime/base/runtime_option.h b/hphp/runtime/base/runtime_option.h index df4d1a7b9..1c29af94b 100644 --- a/hphp/runtime/base/runtime_option.h +++ b/hphp/runtime/base/runtime_option.h @@ -491,6 +491,7 @@ public: // Debugger options static bool EnableDebugger; + static bool EnableDebuggerColor; static bool EnableDebuggerServer; static bool EnableDebuggerUsageLog; static int DebuggerServerPort; diff --git a/hphp/runtime/eval/debugger/debugger_base.cpp b/hphp/runtime/eval/debugger/debugger_base.cpp index 63bf481fb..a6305ac5c 100644 --- a/hphp/runtime/eval/debugger/debugger_base.cpp +++ b/hphp/runtime/eval/debugger/debugger_base.cpp @@ -436,7 +436,7 @@ static void append_line_no(StringBuffer &sb, const char *text, if (*p == '\n') { ++line; sb.append(begin, p - begin); - sb.append(ANSI_COLOR_END); + if (color) sb.append(ANSI_COLOR_END); sb.append('\n'); if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1, colorLineNo); diff --git a/hphp/runtime/eval/debugger/debugger_client.cpp b/hphp/runtime/eval/debugger/debugger_client.cpp index b73a2b514..174807963 100644 --- a/hphp/runtime/eval/debugger/debugger_client.cpp +++ b/hphp/runtime/eval/debugger/debugger_client.cpp @@ -283,7 +283,6 @@ void DebuggerClient::LoadCodeColor(CodeColor index, Hdf hdf, SmartPtr DebuggerClient::Start(const DebuggerClientOptions &options) { TRACE(2, "DebuggerClient::Start\n"); - Debugger::SetTextColors(); SmartPtr ret = getStaticDebuggerClient().connectLocal(); getStaticDebuggerClient().start(options); return ret; @@ -633,6 +632,9 @@ void DebuggerClient::init(const DebuggerClientOptions &options) { m_outputBuf.clear(); } + UseColor &= RuntimeOption::EnableDebuggerColor; + if (UseColor) Debugger::SetTextColors(); + if (!NoPrompt) { info("Welcome to HipHop Debugger!"); info("Type \"help\" or \"?\" for a complete list of commands.\n"); @@ -1281,7 +1283,7 @@ bool DebuggerClient::code(CStrRef source, int line1 /*= 0*/, int line2 /*= 0*/, } } if (!sb.empty()) { - print("%s%s", sb.data(), isApiMode() ? "\0" : ANSI_COLOR_END); + print("%s%s", sb.data(), !UseColor ? "\0" : ANSI_COLOR_END); return true; } return false; @@ -2298,7 +2300,7 @@ void DebuggerClient::loadConfig() { m_config["UTF8"] = s_use_utf8; // for starter Hdf color = m_config["Color"]; - UseColor = color.getBool(true); + UseColor = color.getBool(true) && RuntimeOption::EnableDebuggerColor; color = UseColor; // for starter if (UseColor) { defineColors(); // (1) no one can overwrite, (2) for starter diff --git a/hphp/runtime/eval/debugger/debugger_server.cpp b/hphp/runtime/eval/debugger/debugger_server.cpp index 1873e4150..1e3ada3f4 100644 --- a/hphp/runtime/eval/debugger/debugger_server.cpp +++ b/hphp/runtime/eval/debugger/debugger_server.cpp @@ -32,12 +32,14 @@ DebuggerServer DebuggerServer::s_debugger_server; bool DebuggerServer::Start() { TRACE(2, "DebuggerServer::Start\n"); if (RuntimeOption::EnableDebuggerServer) { - Debugger::SetTextColors(); + if (RuntimeOption::EnableDebuggerColor) { + Debugger::SetTextColors(); - // Some server commands pre-formatted texts with color for clients. Loading - // a set of default colors for better display. - Hdf hdf; - DebuggerClient::LoadColors(hdf); + // Some server commands pre-formatted texts with color for clients. + // Loading a set of default colors for better display. + Hdf hdf; + DebuggerClient::LoadColors(hdf); + } return s_debugger_server.start(); } diff --git a/hphp/test/quick/debugger/config.hdf b/hphp/test/quick/debugger/config.hdf index 97062059f..bcdf7f575 100644 --- a/hphp/test/quick/debugger/config.hdf +++ b/hphp/test/quick/debugger/config.hdf @@ -5,6 +5,7 @@ Eval { EnableObjDestructCall = true Debugger { EnableDebugger = true + EnableDebuggerColor = false } } diff --git a/hphp/test/quick/debugger/printThis.php.expectf b/hphp/test/quick/debugger/printThis.php.expectf index f44efc39e..812fb398e 100644 --- a/hphp/test/quick/debugger/printThis.php.expectf +++ b/hphp/test/quick/debugger/printThis.php.expectf @@ -1,32 +1,32 @@ -Welcome to HipHop Debugger! -Type "help" or "?" for a complete list of commands. - -Program %sprintThis.php loaded. Type '[r]un' or '[c]ontinue' to go. +Welcome to HipHop Debugger! +Type "help" or "?" for a complete list of commands. + +Program %sprintThis.php loaded. Type '[r]un' or '[c]ontinue' to go. hphpd> break printThis.php:5 -Breakpoint 1 set on line 5 of printThis.php +Breakpoint 1 set on line 5 of printThis.php hphpd> run -Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php - 4  function method() { - 5  $other = $this; - 6  } - +Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php + 4 function method() { + 5 $other = $this; + 6 } + hphpd> print $this -Foo Object +Foo Object ( [prop] => "Hello\n" ) - + hphpd> continue -Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php - 4  function method() { - 5  $other = $this; - 6  } - +Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php + 4 function method() { + 5 $other = $this; + 6 } + hphpd> print $this -Foo Object +Foo Object ( [prop] => "Hello\n" [prop2] => "\tThere" ) - + hphpd> quit