Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/objects-printer.cc

Issue 7523052: String to ascii char array converter for debug mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added comment to clarify the purpose of this method. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 PrintF(out, "%c", Get(i)); 553 PrintF(out, "%c", Get(i));
554 } 554 }
555 if (len != length()) { 555 if (len != length()) {
556 PrintF(out, "%s", truncated_epilogue); 556 PrintF(out, "%s", truncated_epilogue);
557 } 557 }
558 558
559 if (!StringShape(this).IsSymbol()) PrintF(out, "\""); 559 if (!StringShape(this).IsSymbol()) PrintF(out, "\"");
560 } 560 }
561 561
562 562
563 // This method is only meant to be called from gdb for debugging purposes.
564 // Since the string can also be in two-byte encoding, non-ascii characters
565 // will be ignored in the output.
566 char* String::ToAsciiArray() {
567 // Static so that subsequent calls frees previously allocated space.
568 // This also means that previous results will be overwritten.
569 static char* buffer = NULL;
570 if (buffer != NULL) free(buffer);
571 buffer = new char[length()+1];
572 WriteToFlat(this, buffer, 0, length());
573 buffer[length()] = 0;
574 return buffer;
575 }
576
577
563 void JSProxy::JSProxyPrint(FILE* out) { 578 void JSProxy::JSProxyPrint(FILE* out) {
564 HeapObject::PrintHeader(out, "JSProxy"); 579 HeapObject::PrintHeader(out, "JSProxy");
565 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); 580 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map()));
566 PrintF(out, " - handler = "); 581 PrintF(out, " - handler = ");
567 handler()->Print(out); 582 handler()->Print(out);
568 PrintF(out, "\n"); 583 PrintF(out, "\n");
569 } 584 }
570 585
571 586
572 void JSFunction::JSFunctionPrint(FILE* out) { 587 void JSFunction::JSFunctionPrint(FILE* out) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 desc.Print(out); 861 desc.Print(out);
847 } 862 }
848 PrintF(out, "\n"); 863 PrintF(out, "\n");
849 } 864 }
850 865
851 866
852 #endif // OBJECT_PRINT 867 #endif // OBJECT_PRINT
853 868
854 869
855 } } // namespace v8::internal 870 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698