diff --git a/src/objects-printer.cc b/src/objects-printer.cc index fe41fdf034..7cb96aae55 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -380,7 +380,6 @@ void JSObject::PrintElements(std::ostream& os) { // NOLINT case DICTIONARY_ELEMENTS: case SLOW_STRING_WRAPPER_ELEMENTS: - os << "\n - elements: "; elements()->Print(os); break; case FAST_SLOPPY_ARGUMENTS_ELEMENTS: @@ -424,10 +423,14 @@ static void JSObjectPrintHeader(std::ostream& os, JSObject* obj, static void JSObjectPrintBody(std::ostream& os, JSObject* obj, // NOLINT bool print_elements = true) { - os << "\n {"; + os << "\n - properties = {"; obj->PrintProperties(os); - if (print_elements) obj->PrintElements(os); os << "\n }\n"; + if (print_elements && obj->elements()->length() > 0) { + os << " - elements = {"; + obj->PrintElements(os); + os << "\n }\n"; + } } @@ -716,8 +719,6 @@ void String::StringPrint(std::ostream& os) { // NOLINT void Name::NamePrint(std::ostream& os) { // NOLINT if (IsString()) { String::cast(this)->StringPrint(os); - } else if (IsSymbol()) { - Symbol::cast(this)->name()->Print(os); } else { os << Brief(this); } diff --git a/src/objects.cc b/src/objects.cc index a47a45dcb4..a2438d351e 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -1913,8 +1913,7 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { return true; } - -void String::StringShortPrint(StringStream* accumulator) { +void String::StringShortPrint(StringStream* accumulator, bool show_details) { int len = length(); if (len > kMaxShortPrintLength) { accumulator->Add("", len); @@ -1943,15 +1942,15 @@ void String::StringShortPrint(StringStream* accumulator) { } stream.Reset(this); if (one_byte) { - accumulator->Add("Add("Put(static_cast(stream.GetNext())); } - accumulator->Put('>'); + if (show_details) accumulator->Put('>'); } else { // Backslash indicates that the string contains control // characters and that backslashes are therefore escaped. - accumulator->Add("Add("Put('.'); accumulator->Put('.'); } - accumulator->Put('>'); + if (show_details) accumulator->Put('>'); } return; } @@ -15396,12 +15395,12 @@ const char* Symbol::PrivateSymbolToName() const { void Symbol::SymbolShortPrint(std::ostream& os) { - os << "IsUndefined()) { os << " "; HeapStringAllocator allocator; StringStream accumulator(&allocator); - String::cast(name())->StringShortPrint(&accumulator); + String::cast(name())->StringShortPrint(&accumulator, false); os << accumulator.ToCString().get(); } else { os << " (" << PrivateSymbolToName() << ")"; diff --git a/src/objects.h b/src/objects.h index 21551dcee9..6ada398026 100644 --- a/src/objects.h +++ b/src/objects.h @@ -8869,7 +8869,7 @@ class String: public Name { bool LooksValid(); // Dispatched behavior. - void StringShortPrint(StringStream* accumulator); + void StringShortPrint(StringStream* accumulator, bool show_details = true); void PrintUC16(std::ostream& os, int start = 0, int end = -1); // NOLINT #if defined(DEBUG) || defined(OBJECT_PRINT) char* ToAsciiArray();