summaryrefslogtreecommitdiffstats
path: root/chrome/app/chrome_main_delegate.cc
diff options
context:
space:
mode:
authorscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 20:01:37 +0000
committerscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 20:01:37 +0000
commit0a4cd3111631b21bdb07732ea037bbe40785590c (patch)
tree43403693f0e011f1d212ff56a5bf5be221f55b12 /chrome/app/chrome_main_delegate.cc
parent461749a8adf21103afe9807be1633ac950bce976 (diff)
downloadchromium_src-0a4cd3111631b21bdb07732ea037bbe40785590c.zip
chromium_src-0a4cd3111631b21bdb07732ea037bbe40785590c.tar.gz
chromium_src-0a4cd3111631b21bdb07732ea037bbe40785590c.tar.bz2
Profiling for the renderer process.
This lets you use --profiling-at-start=renderer and get profiler output for each renderer process started on Linux. The profiling classes are initialized at static initialization time, and the main thread is registered and the profile timer is started at that time. However, static initialization is done in the zygote, and the timer doesn't propagate across the fork, so trying to use the CPU profiler on the renderer never sampled. This patch re-registers the (new) main thread after the fork, which causes the profiler to check the state of the timer, and ends up re-starting it. A separate timer for flushing the profile and termination signal handler are added before the renderer process enters the sandbox in order to make sure the samples are written to disk. BUG=none TEST=Use it, get lovely traces, pperf away. Review URL: http://codereview.chromium.org/8083025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/chrome_main_delegate.cc')
-rw-r--r--chrome/app/chrome_main_delegate.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc
index 73e5331..52c0a93 100644
--- a/chrome/app/chrome_main_delegate.cc
+++ b/chrome/app/chrome_main_delegate.cc
@@ -351,6 +351,25 @@ void HandleHelpSwitches(const CommandLine& command_line) {
}
#endif
+#if !defined(OS_MACOSX)
+void SIGTERMProfilingShutdown(int signal) {
+ Profiling::Stop();
+ struct sigaction sigact;
+ memset(&sigact, 0, sizeof(sigact));
+ sigact.sa_handler = SIG_DFL;
+ CHECK(sigaction(SIGTERM, &sigact, NULL) == 0);
+ raise(signal);
+}
+
+void SetUpProfilingShutdownHandler() {
+ struct sigaction sigact;
+ sigact.sa_handler = SIGTERMProfilingShutdown;
+ sigact.sa_flags = SA_RESETHAND;
+ sigemptyset(&sigact.sa_mask);
+ CHECK(sigaction(SIGTERM, &sigact, NULL) == 0);
+}
+#endif
+
#endif // OS_POSIX
struct MainFunction {
@@ -704,6 +723,12 @@ void ChromeMainDelegate::ZygoteForked() {
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
+ Profiling::ProcessStarted();
+ if (Profiling::BeingProfiled()) {
+ base::debug::RestartProfilingAfterFork();
+ SetUpProfilingShutdownHandler();
+ }
+
#if defined(USE_LINUX_BREAKPAD)
// Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets
// this up for the browser process in a different manner.