Commit 15b13fac authored by yangguo@chromium.org's avatar yangguo@chromium.org

String to ascii char array converter for debug mode.

Review URL: http://codereview.chromium.org/7523052

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8763 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6637fa28
......@@ -560,6 +560,21 @@ void String::StringPrint(FILE* out) {
}
// This method is only meant to be called from gdb for debugging purposes.
// Since the string can also be in two-byte encoding, non-ascii characters
// will be ignored in the output.
char* String::ToAsciiArray() {
// Static so that subsequent calls frees previously allocated space.
// This also means that previous results will be overwritten.
static char* buffer = NULL;
if (buffer != NULL) free(buffer);
buffer = new char[length()+1];
WriteToFlat(this, buffer, 0, length());
buffer[length()] = 0;
return buffer;
}
void JSProxy::JSProxyPrint(FILE* out) {
HeapObject::PrintHeader(out, "JSProxy");
PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map()));
......
......@@ -5927,6 +5927,8 @@ class String: public HeapObject {
StringPrint(stdout);
}
void StringPrint(FILE* out);
char* ToAsciiArray();
#endif
#ifdef DEBUG
void StringVerify();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment