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

Side by Side Diff: src/log.cc

Issue 7866: Misc (Closed)
Patch Set: Created 12 years, 2 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 #ifdef ENABLE_LOGGING_AND_PROFILING 342 #ifdef ENABLE_LOGGING_AND_PROFILING
343 if (logfile_ == NULL || !FLAG_prof) return; 343 if (logfile_ == NULL || !FLAG_prof) return;
344 ScopedLock sl(mutex_); 344 ScopedLock sl(mutex_);
345 fprintf(logfile_, "shared-library,\"%ls\",0x%08x,0x%08x\n", library_path, 345 fprintf(logfile_, "shared-library,\"%ls\",0x%08x,0x%08x\n", library_path,
346 start, end); 346 start, end);
347 #endif 347 #endif
348 } 348 }
349 349
350 350
351 #ifdef ENABLE_LOGGING_AND_PROFILING 351 #ifdef ENABLE_LOGGING_AND_PROFILING
352 void Logger::LogString(Handle<String> str) {
353 int len = str->length();
354 if (len > 256)
355 len = 256;
356 for (int i = 0; i < len; i++) {
357 uc32 c = str->Get(i);
358 if (c < 32 || (c > 126 && c <= 255)) {
359 fprintf(logfile_, "\\x%02x", c);
360 } else if (c > 255) {
361 fprintf(logfile_, "\\u%04x", c);
362 } else if (c == ',') {
363 fprintf(logfile_, "\\,");
364 } else {
365 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
366 }
367 }
368 }
369
352 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { 370 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) {
353 // Prints "/" + re.source + "/" + 371 // Prints "/" + re.source + "/" +
354 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") 372 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"")
355 373
356 Handle<Object> source = GetProperty(regexp, "source"); 374 Handle<Object> source = GetProperty(regexp, "source");
357 if (!source->IsString()) { 375 if (!source->IsString()) {
358 fprintf(logfile_, "no source"); 376 fprintf(logfile_, "no source");
359 return; 377 return;
360 } 378 }
361 Handle<String> source_string = Handle<String>::cast(source);
362 379
363 SmartPointer<uc16> cstring = source_string->ToWideCString();
364 if (regexp->type()->IsSmi()) { 380 if (regexp->type()->IsSmi()) {
365 switch (regexp->type_tag()) { 381 switch (regexp->type_tag()) {
366 case JSRegExp::ATOM: 382 case JSRegExp::ATOM:
367 fprintf(logfile_, "a"); 383 fprintf(logfile_, "a");
368 break; 384 break;
369 default: 385 default:
370 break; 386 break;
371 } 387 }
372 } 388 }
373 fprintf(logfile_, "/"); 389 fprintf(logfile_, "/");
374 for (int i = 0, n = source_string->length(); i < n; i++) { 390 LogString(Handle<String>::cast(source));
375 uc16 c = cstring[i];
376 if (c < 32 || (c > 126 && c <= 255)) {
377 fprintf(logfile_, "\\x%02x", c);
378 } else if (c > 255) {
379 fprintf(logfile_, "\\u%04x", c);
380 } else {
381 fprintf(logfile_, "%lc", c);
382 }
383 }
384 fprintf(logfile_, "/"); 391 fprintf(logfile_, "/");
385 392
386 // global flag 393 // global flag
387 Handle<Object> global = GetProperty(regexp, "global"); 394 Handle<Object> global = GetProperty(regexp, "global");
388 if (global->IsTrue()) { 395 if (global->IsTrue()) {
389 fprintf(logfile_, "g"); 396 fprintf(logfile_, "g");
390 } 397 }
391 // ignorecase flag 398 // ignorecase flag
392 Handle<Object> ignorecase = GetProperty(regexp, "ignoreCase"); 399 Handle<Object> ignorecase = GetProperty(regexp, "ignoreCase");
393 if (ignorecase->IsTrue()) { 400 if (ignorecase->IsTrue()) {
(...skipping 22 matching lines...) Expand all
416 423
417 void Logger::RegExpExecEvent(Handle<JSRegExp> regexp, 424 void Logger::RegExpExecEvent(Handle<JSRegExp> regexp,
418 int start_index, 425 int start_index,
419 Handle<String> input_string) { 426 Handle<String> input_string) {
420 #ifdef ENABLE_LOGGING_AND_PROFILING 427 #ifdef ENABLE_LOGGING_AND_PROFILING
421 if (logfile_ == NULL || !FLAG_log_regexp) return; 428 if (logfile_ == NULL || !FLAG_log_regexp) return;
422 ScopedLock sl(mutex_); 429 ScopedLock sl(mutex_);
423 430
424 fprintf(logfile_, "regexp-run,"); 431 fprintf(logfile_, "regexp-run,");
425 LogRegExpSource(regexp); 432 LogRegExpSource(regexp);
426 fprintf(logfile_, ",0x%08x,%d..%d\n", 433 fprintf(logfile_, ",");
427 input_string->Hash(), start_index, input_string->length()); 434 LogString(input_string);
435 fprintf(logfile_, ",%d..%d\n", start_index, input_string->length());
428 #endif 436 #endif
429 } 437 }
430 438
431 439
432 void Logger::ApiIndexedSecurityCheck(uint32_t index) { 440 void Logger::ApiIndexedSecurityCheck(uint32_t index) {
433 #ifdef ENABLE_LOGGING_AND_PROFILING 441 #ifdef ENABLE_LOGGING_AND_PROFILING
434 if (logfile_ == NULL || !FLAG_log_api) return; 442 if (logfile_ == NULL || !FLAG_log_api) return;
435 ApiEvent("api,check-security,%u\n", index); 443 ApiEvent("api,check-security,%u\n", index);
436 #endif 444 #endif
437 } 445 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 if (FLAG_log_state_changes) { 842 if (FLAG_log_state_changes) {
835 LOG(StringEvent("Leaving", StateToString(state_))); 843 LOG(StringEvent("Leaving", StateToString(state_)));
836 if (previous_) { 844 if (previous_) {
837 LOG(StringEvent("To", StateToString(previous_->state_))); 845 LOG(StringEvent("To", StateToString(previous_->state_)));
838 } 846 }
839 } 847 }
840 } 848 }
841 #endif 849 #endif
842 850
843 } } // namespace v8::internal 851 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698