Chromium Code Reviews| Index: src/log.cc |
| diff --git a/src/log.cc b/src/log.cc |
| index 01ca6dd49b934ba6c010563b5da7541f56f26fb6..be76b96e1bdec0a1aadca616e9cadb7023923a7c 100644 |
| --- a/src/log.cc |
| +++ b/src/log.cc |
| @@ -349,6 +349,24 @@ void Logger::SharedLibraryEvent(const wchar_t* library_path, |
| #ifdef ENABLE_LOGGING_AND_PROFILING |
| +void Logger::LogString(Handle<String> str) { |
| + int len = str->length(); |
| + if (len > 256) |
| + len = 256; |
| + for (int i = 0; i < len; i++) { |
| + uc32 c = str->Get(i); |
| + if (c < 32 || (c > 126 && c <= 255)) { |
| + fprintf(logfile_, "\\x%02x", c); |
| + } else if (c > 255) { |
| + fprintf(logfile_, "\\u%04x", c); |
| + } else if (c == ',') { |
| + fprintf(logfile_, "\\,"); |
| + } else { |
| + fprintf(logfile_, "%lc", c); |
|
Erik Corry
2008/10/22 11:44:15
If you want to be able to reconstruct the original
Christian Plesner Hansen
2008/10/22 11:59:02
For now I'm not too worried about automatically re
|
| + } |
| + } |
| +} |
| + |
| void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { |
| // Prints "/" + re.source + "/" + |
| // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") |
| @@ -358,9 +376,7 @@ void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { |
| fprintf(logfile_, "no source"); |
| return; |
| } |
| - Handle<String> source_string = Handle<String>::cast(source); |
| - SmartPointer<uc16> cstring = source_string->ToWideCString(); |
| if (regexp->type()->IsSmi()) { |
| switch (regexp->type_tag()) { |
| case JSRegExp::ATOM: |
| @@ -371,16 +387,7 @@ void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { |
| } |
| } |
| fprintf(logfile_, "/"); |
| - for (int i = 0, n = source_string->length(); i < n; i++) { |
| - uc16 c = cstring[i]; |
| - if (c < 32 || (c > 126 && c <= 255)) { |
| - fprintf(logfile_, "\\x%02x", c); |
| - } else if (c > 255) { |
| - fprintf(logfile_, "\\u%04x", c); |
| - } else { |
| - fprintf(logfile_, "%lc", c); |
| - } |
| - } |
| + LogString(Handle<String>::cast(source)); |
| fprintf(logfile_, "/"); |
| // global flag |
| @@ -423,8 +430,9 @@ void Logger::RegExpExecEvent(Handle<JSRegExp> regexp, |
| fprintf(logfile_, "regexp-run,"); |
| LogRegExpSource(regexp); |
| - fprintf(logfile_, ",0x%08x,%d..%d\n", |
| - input_string->Hash(), start_index, input_string->length()); |
| + fprintf(logfile_, ","); |
| + LogString(input_string); |
| + fprintf(logfile_, ",%d..%d\n", start_index, input_string->length()); |
| #endif |
| } |