[printing] show symbols when using %DebugPrint
This CL makes sure that Symbols-keys are printed the same way for fast and slow properties. Additionally the elements and properties are marked clearer in the output. BUG= Review-Url: https://codereview.chromium.org/2008893002 Cr-Commit-Position: refs/heads/master@{#36550}
This commit is contained in:
parent
e2172e1f0a
commit
bcf520ef6e
@ -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);
|
||||
}
|
||||
|
@ -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("<Very long string[%u]>", len);
|
||||
@ -1943,15 +1942,15 @@ void String::StringShortPrint(StringStream* accumulator) {
|
||||
}
|
||||
stream.Reset(this);
|
||||
if (one_byte) {
|
||||
accumulator->Add("<String[%u]: ", length());
|
||||
if (show_details) accumulator->Add("<String[%u]: ", length());
|
||||
for (int i = 0; i < len; i++) {
|
||||
accumulator->Put(static_cast<char>(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("<String[%u]\\: ", length());
|
||||
if (show_details) accumulator->Add("<String[%u]\\: ", length());
|
||||
for (int i = 0; i < len; i++) {
|
||||
uint16_t c = stream.GetNext();
|
||||
if (c == '\n') {
|
||||
@ -1971,7 +1970,7 @@ void String::StringShortPrint(StringStream* accumulator) {
|
||||
accumulator->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 << "<Symbol: " << Hash();
|
||||
os << "<Symbol:";
|
||||
if (!name()->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() << ")";
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user