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

Side by Side Diff: content/app/content_main_runner.cc

Issue 2674373003: content: Allow printing stack-trace when browser process crashes. (Closed)
Patch Set: . Created 3 years, 10 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 | « no previous file | no next file » | 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 "content/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 for (unsigned i = 0; i < arraysize(signals_to_reset); i++) { 213 for (unsigned i = 0; i < arraysize(signals_to_reset); i++) {
214 CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL)); 214 CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL));
215 } 215 }
216 216
217 // Always ignore SIGPIPE. We check the return value of write(). 217 // Always ignore SIGPIPE. We check the return value of write().
218 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); 218 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN));
219 } 219 }
220 220
221 #endif // OS_POSIX 221 #endif // OS_POSIX
222 222
223 void CommonSubprocessInit(const std::string& process_type) { 223 void CommonSubprocessInit() {
224 #if defined(OS_WIN) 224 #if defined(OS_WIN)
225 // HACK: Let Windows know that we have started. This is needed to suppress 225 // HACK: Let Windows know that we have started. This is needed to suppress
226 // the IDC_APPSTARTING cursor from being displayed for a prolonged period 226 // the IDC_APPSTARTING cursor from being displayed for a prolonged period
227 // while a subprocess is starting. 227 // while a subprocess is starting.
228 PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0); 228 PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0);
229 MSG msg; 229 MSG msg;
230 PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); 230 PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
231 #endif 231 #endif
232 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 232 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
233 // Various things break when you're using a locale where the decimal 233 // Various things break when you're using a locale where the decimal
234 // separator isn't a period. See e.g. bugs 22782 and 39964. For 234 // separator isn't a period. See e.g. bugs 22782 and 39964. For
235 // all processes except the browser process (where we call system 235 // all processes except the browser process (where we call system
236 // APIs that may rely on the correct locale for formatting numbers 236 // APIs that may rely on the correct locale for formatting numbers
237 // when presenting them to the user), reset the locale for numeric 237 // when presenting them to the user), reset the locale for numeric
238 // formatting. 238 // formatting.
239 // Note that this is not correct for plugin processes -- they can 239 // Note that this is not correct for plugin processes -- they can
240 // surface UI -- but it's likely they get this wrong too so why not. 240 // surface UI -- but it's likely they get this wrong too so why not.
241 setlocale(LC_NUMERIC, "C"); 241 setlocale(LC_NUMERIC, "C");
242 #endif 242 #endif
243 243
244 #if !defined(OFFICIAL_BUILD) 244 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN)
245 // Print stack traces to stderr when crashes occur. This opens up security
246 // holes so it should never be enabled for official builds.
247 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
248 switches::kDisableInProcessStackTraces)) {
249 base::debug::EnableInProcessStackDumping();
250 }
251 #if defined(OS_WIN)
252 base::RouteStdioToConsole(false); 245 base::RouteStdioToConsole(false);
253 LoadLibraryA("dbghelp.dll"); 246 LoadLibraryA("dbghelp.dll");
254 #endif 247 #endif
255 #endif
256 } 248 }
257 249
258 class ContentClientInitializer { 250 class ContentClientInitializer {
259 public: 251 public:
260 static void Set(const std::string& process_type, 252 static void Set(const std::string& process_type,
261 ContentMainDelegate* delegate) { 253 ContentMainDelegate* delegate) {
262 ContentClient* content_client = GetContentClient(); 254 ContentClient* content_client = GetContentClient();
263 #if !defined(CHROME_MULTIPLE_DLL_CHILD) 255 #if !defined(CHROME_MULTIPLE_DLL_CHILD)
264 if (process_type.empty()) { 256 if (process_type.empty()) {
265 if (delegate) 257 if (delegate)
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 gin::V8Initializer::LoadV8Natives(); 742 gin::V8Initializer::LoadV8Natives();
751 } 743 }
752 #else 744 #else
753 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 745 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
754 gin::V8Initializer::LoadV8Snapshot(); 746 gin::V8Initializer::LoadV8Snapshot();
755 gin::V8Initializer::LoadV8Natives(); 747 gin::V8Initializer::LoadV8Natives();
756 #endif // !CHROME_MULTIPLE_DLL_BROWSER 748 #endif // !CHROME_MULTIPLE_DLL_BROWSER
757 #endif // OS_POSIX && !OS_MACOSX 749 #endif // OS_POSIX && !OS_MACOSX
758 #endif // V8_USE_EXTERNAL_STARTUP_DATA 750 #endif // V8_USE_EXTERNAL_STARTUP_DATA
759 751
752 #if !defined(OFFICIAL_BUILD)
753 #if defined(OS_WIN)
754 bool should_enable_stack_dump = !process_type.empty();
755 #else
756 bool should_enable_stack_dump = true;
757 #endif
758 // Print stack traces to stderr when crashes occur. This opens up security
759 // holes so it should never be enabled for official builds. This needs to
760 // happen before crash reporting is initialized (which for chrome happens in
761 // the call to PreSandboxStartup() on the delegate below), because otherwise
762 // this would interfere with signal handlers used by crash reporting.
763 if (should_enable_stack_dump && !command_line.HasSwitch(
764 switches::kDisableInProcessStackTraces)) {
765 base::debug::EnableInProcessStackDumping();
766 }
767 #endif // !defined(OFFICIAL_BUILD)
768
760 if (delegate_) 769 if (delegate_)
761 delegate_->PreSandboxStartup(); 770 delegate_->PreSandboxStartup();
762 771
763 if (!process_type.empty()) 772 if (!process_type.empty())
764 CommonSubprocessInit(process_type); 773 CommonSubprocessInit();
765 774
766 #if defined(OS_WIN) 775 #if defined(OS_WIN)
767 CHECK(InitializeSandbox(params.sandbox_info)); 776 CHECK(InitializeSandbox(params.sandbox_info));
768 #elif defined(OS_MACOSX) 777 #elif defined(OS_MACOSX)
769 if (process_type == switches::kRendererProcess || 778 if (process_type == switches::kRendererProcess ||
770 process_type == switches::kPpapiPluginProcess || 779 process_type == switches::kPpapiPluginProcess ||
771 (delegate_ && delegate_->DelaySandboxInitialization(process_type))) { 780 (delegate_ && delegate_->DelaySandboxInitialization(process_type))) {
772 // On OS X the renderer sandbox needs to be initialized later in the 781 // On OS X the renderer sandbox needs to be initialized later in the
773 // startup sequence in RendererMainPlatformDelegate::EnableSandbox(). 782 // startup sequence in RendererMainPlatformDelegate::EnableSandbox().
774 } else { 783 } else {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 882
874 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 883 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
875 }; 884 };
876 885
877 // static 886 // static
878 ContentMainRunner* ContentMainRunner::Create() { 887 ContentMainRunner* ContentMainRunner::Create() {
879 return new ContentMainRunnerImpl(); 888 return new ContentMainRunnerImpl();
880 } 889 }
881 890
882 } // namespace content 891 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698