diff --git a/hphp/runtime/base/variable_serializer.cpp b/hphp/runtime/base/variable_serializer.cpp index 186d1419c..c7de46cea 100644 --- a/hphp/runtime/base/variable_serializer.cpp +++ b/hphp/runtime/base/variable_serializer.cpp @@ -268,7 +268,6 @@ void VariableSerializer::write(const char *v, int len /* = -1 */, m_buf->append(v, len); break; } - case DebuggerDump: case VarExport: { m_buf->append('\''); const char *p = v; @@ -325,6 +324,7 @@ void VariableSerializer::write(const char *v, int len /* = -1 */, m_buf->appendJsonEscape(v, len, m_option); break; } + case DebuggerDump: case PHPOutput: { m_buf->append('"'); for (int i = 0; i < len; ++i) { @@ -519,6 +519,7 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) { info.indent_delta = 0; switch (m_type) { + case DebuggerDump: case PrintR: if (!m_rsrcName.empty()) { m_buf->append("Resource id #"); @@ -608,7 +609,6 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) { } break; case JSON: - case DebuggerDump: info.is_vector = (m_objClass.empty() || m_objCode == 'V' || m_objCode == 'K') && isVectorData; @@ -664,7 +664,7 @@ void VariableSerializer::writePropertyKey(CStrRef prop) { } } else { m_buf->append(prop); - if (m_type != PrintR) m_buf->append('"'); + if (m_type != PrintR && m_type != DebuggerDump) m_buf->append('"'); } } @@ -678,6 +678,7 @@ void VariableSerializer::writeArrayKey(Variant key) { } ArrayInfo &info = m_arrayInfos.back(); switch (m_type) { + case DebuggerDump: case PrintR: { indent(); m_buf->append('['); @@ -718,7 +719,6 @@ void VariableSerializer::writeArrayKey(Variant key) { write(key); break; case JSON: - case DebuggerDump: if (!info.first_element) { m_buf->append(','); } @@ -824,8 +824,10 @@ void VariableSerializer::writeArrayFooter() { m_indent -= info.indent_delta; switch (m_type) { + case DebuggerDump: case PrintR: if (m_rsrcName.empty()) { + if (m_type == DebuggerDump) m_buf->append("\n"); indent(); m_buf->append(")\n"); if (m_indent > 0) { @@ -860,7 +862,6 @@ void VariableSerializer::writeArrayFooter() { m_buf->append('}'); break; case JSON: - case DebuggerDump: if (m_type == JSON && m_option & k_JSON_PRETTY_PRINT) { m_buf->append("\n"); indent(); diff --git a/hphp/runtime/base/variable_serializer.h b/hphp/runtime/base/variable_serializer.h index b4533ea74..9946c4fb0 100644 --- a/hphp/runtime/base/variable_serializer.h +++ b/hphp/runtime/base/variable_serializer.h @@ -29,8 +29,7 @@ class ClassInfo; /** * Maintaining states during serialization of a variable. We use this single - * class to uniformly serialize variables according to different formats: - * print_r(), var_export(), var_dump(), debug_zval_dump() or serialize(). + * class to uniformly serialize variables according to different formats. */ class VariableSerializer { public: @@ -38,16 +37,16 @@ public: * Supported formats. */ enum Type { - PrintR, - VarExport, - VarDump, - DebugDump, - DebuggerDump, - Serialize, - JSON, - APCSerialize, - DebuggerSerialize, - PHPOutput, + PrintR, //print_r() + VarExport, //var_export() + VarDump, //var_dump() + DebugDump, //debug_zval_dump() + DebuggerDump, //used by hphp debugger to obtain user visible output + Serialize, // serialize() + JSON, //json_encode() + APCSerialize, //used in APC serialization (controlled by switch) + DebuggerSerialize, //used by hphp debugger for client<->proxy communication + PHPOutput, //used by compiler to output scalar values into byte code }; /** diff --git a/hphp/runtime/eval/debugger/debugger_client.cpp b/hphp/runtime/eval/debugger/debugger_client.cpp index 5abc68cfa..50e494969 100644 --- a/hphp/runtime/eval/debugger/debugger_client.cpp +++ b/hphp/runtime/eval/debugger/debugger_client.cpp @@ -332,7 +332,7 @@ String DebuggerClient::FormatVariable(CVarRef v, int maxlen /* = 80 */, try { VariableSerializer::Type t = vardump ? VariableSerializer::VarDump : - VariableSerializer::PrintR; + VariableSerializer::DebuggerDump; VariableSerializer vs(t, 0, 2); value = vs.serialize(v, true); } catch (StringBufferLimitException &e) { diff --git a/hphp/test/debugger_tests/printThis.expectf b/hphp/test/debugger_tests/printThis.expectf index 2575253d7..f7d72889b 100644 --- a/hphp/test/debugger_tests/printThis.expectf +++ b/hphp/test/debugger_tests/printThis.expectf @@ -13,8 +13,7 @@ hphpd> run hphpd> print $this Foo Object ( - [prop] => Hello - + [prop] => "Hello\n" )  hphpd> quit