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

Side by Side Diff: src/cpu-profiler.cc

Issue 3108004: Fix CPU profiler crash in start / stop sequence when non-existent name is passed (Closed)
Patch Set: Created 10 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
« no previous file with comments | « src/cpu-profiler.h ('k') | src/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 Logger::LogAccessorCallbacks(); 469 Logger::LogAccessorCallbacks();
470 } 470 }
471 // Enable stack sampling. 471 // Enable stack sampling.
472 reinterpret_cast<Sampler*>(Logger::ticker_)->Start(); 472 reinterpret_cast<Sampler*>(Logger::ticker_)->Start();
473 } 473 }
474 } 474 }
475 475
476 476
477 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) { 477 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
478 const double actual_sampling_rate = generator_->actual_sampling_rate(); 478 const double actual_sampling_rate = generator_->actual_sampling_rate();
479 StopProcessorIfLastProfile(); 479 StopProcessorIfLastProfile(title);
480 CpuProfile* result = 480 CpuProfile* result =
481 profiles_->StopProfiling(TokenEnumerator::kNoSecurityToken, 481 profiles_->StopProfiling(TokenEnumerator::kNoSecurityToken,
482 title, 482 title,
483 actual_sampling_rate); 483 actual_sampling_rate);
484 if (result != NULL) { 484 if (result != NULL) {
485 result->Print(); 485 result->Print();
486 } 486 }
487 return result; 487 return result;
488 } 488 }
489 489
490 490
491 CpuProfile* CpuProfiler::StopCollectingProfile(Object* security_token, 491 CpuProfile* CpuProfiler::StopCollectingProfile(Object* security_token,
492 String* title) { 492 String* title) {
493 const double actual_sampling_rate = generator_->actual_sampling_rate(); 493 const double actual_sampling_rate = generator_->actual_sampling_rate();
494 StopProcessorIfLastProfile(); 494 const char* profile_title = profiles_->GetName(title);
495 StopProcessorIfLastProfile(profile_title);
495 int token = token_enumerator_->GetTokenId(security_token); 496 int token = token_enumerator_->GetTokenId(security_token);
496 return profiles_->StopProfiling(token, title, actual_sampling_rate); 497 return profiles_->StopProfiling(token, profile_title, actual_sampling_rate);
497 } 498 }
498 499
499 500
500 void CpuProfiler::StopProcessorIfLastProfile() { 501 void CpuProfiler::StopProcessorIfLastProfile(const char* title) {
501 if (profiles_->is_last_profile()) { 502 if (profiles_->IsLastProfile(title)) {
502 reinterpret_cast<Sampler*>(Logger::ticker_)->Stop(); 503 reinterpret_cast<Sampler*>(Logger::ticker_)->Stop();
503 processor_->Stop(); 504 processor_->Stop();
504 processor_->Join(); 505 processor_->Join();
505 delete processor_; 506 delete processor_;
506 delete generator_; 507 delete generator_;
507 processor_ = NULL; 508 processor_ = NULL;
508 generator_ = NULL; 509 generator_ = NULL;
509 Logger::logging_nesting_ = saved_logging_nesting_; 510 Logger::logging_nesting_ = saved_logging_nesting_;
510 } 511 }
511 } 512 }
(...skipping 17 matching lines...) Expand all
529 void CpuProfiler::TearDown() { 530 void CpuProfiler::TearDown() {
530 #ifdef ENABLE_LOGGING_AND_PROFILING 531 #ifdef ENABLE_LOGGING_AND_PROFILING
531 if (singleton_ != NULL) { 532 if (singleton_ != NULL) {
532 delete singleton_; 533 delete singleton_;
533 } 534 }
534 singleton_ = NULL; 535 singleton_ = NULL;
535 #endif 536 #endif
536 } 537 }
537 538
538 } } // namespace v8::internal 539 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/cpu-profiler.h ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698