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

Side by Side Diff: chrome/common/profiling.cc

Issue 9477002: Support the Syzygy instrumenting profiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move v8 deps exclusion above inclusion rule. Created 8 years, 9 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 | « chrome/browser/DEPS ('k') | chrome/renderer/DEPS » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/profiling.h" 5 #include "chrome/common/profiling.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/profiler.h" 10 #include "base/debug/profiler.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "v8/include/v8.h"
16 17
17 namespace { 18 namespace {
18 std::string GetProfileName() { 19 std::string GetProfileName() {
19 static const char kDefaultProfileName[] = "chrome-profile-{type}-{pid}"; 20 static const char kDefaultProfileName[] = "chrome-profile-{type}-{pid}";
20 CR_DEFINE_STATIC_LOCAL(std::string, profile_name, ()); 21 CR_DEFINE_STATIC_LOCAL(std::string, profile_name, ());
21 22
22 if (profile_name.empty()) { 23 if (profile_name.empty()) {
23 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 24 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
24 if (command_line.HasSwitch(switches::kProfilingFile)) 25 if (command_line.HasSwitch(switches::kProfilingFile))
25 profile_name = command_line.GetSwitchValueASCII(switches::kProfilingFile); 26 profile_name = command_line.GetSwitchValueASCII(switches::kProfilingFile);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 g_flush_thread_control = LAZY_INSTANCE_INITIALIZER; 96 g_flush_thread_control = LAZY_INSTANCE_INITIALIZER;
96 97
97 } // namespace 98 } // namespace
98 99
99 // static 100 // static
100 void Profiling::ProcessStarted() { 101 void Profiling::ProcessStarted() {
101 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 102 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
102 std::string process_type = 103 std::string process_type =
103 command_line.GetSwitchValueASCII(switches::kProcessType); 104 command_line.GetSwitchValueASCII(switches::kProcessType);
104 105
106 // Establish the V8 return address resolution hook if we're
107 // an instrumented binary.
108 if (base::debug::IsBinaryInstrumented()) {
109 base::debug::ReturnAddressLocationResolver resolve_func =
110 base::debug::GetProfilerReturnAddrResolutionFunc();
111
112 if (resolve_func != NULL) {
113 v8::V8::SetReturnAddressLocationResolver(resolve_func);
114 }
115 }
116
105 if (command_line.HasSwitch(switches::kProfilingAtStart)) { 117 if (command_line.HasSwitch(switches::kProfilingAtStart)) {
106 std::string process_type_to_start = 118 std::string process_type_to_start =
107 command_line.GetSwitchValueASCII(switches::kProfilingAtStart); 119 command_line.GetSwitchValueASCII(switches::kProfilingAtStart);
108 if (process_type == process_type_to_start) 120 if (process_type == process_type_to_start)
109 Start(); 121 Start();
110 } 122 }
111 } 123 }
112 124
113 // static 125 // static
114 void Profiling::Start() { 126 void Profiling::Start() {
(...skipping 18 matching lines...) Expand all
133 return base::debug::BeingProfiled(); 145 return base::debug::BeingProfiled();
134 } 146 }
135 147
136 // static 148 // static
137 void Profiling::Toggle() { 149 void Profiling::Toggle() {
138 if (BeingProfiled()) 150 if (BeingProfiled())
139 Stop(); 151 Stop();
140 else 152 else
141 Start(); 153 Start();
142 } 154 }
OLDNEW
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/renderer/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698