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

Side by Side Diff: content/public/test/browser_test_base.cc

Issue 2250503002: Handle SIGSEGV in BrowserTestBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/test/browser_test_base.h" 5 #include "content/public/test/browser_test_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #if defined(OS_POSIX) 64 #if defined(OS_POSIX)
65 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make 65 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
66 // debugging easier) and also exit with a known error code (so that the test 66 // debugging easier) and also exit with a known error code (so that the test
67 // framework considers this a failure -- http://crbug.com/57578). 67 // framework considers this a failure -- http://crbug.com/57578).
68 // Note: We only want to do this in the browser process, and not forked 68 // Note: We only want to do this in the browser process, and not forked
69 // processes. That might lead to hangs because of locks inside tcmalloc or the 69 // processes. That might lead to hangs because of locks inside tcmalloc or the
70 // OS. See http://crbug.com/141302. 70 // OS. See http://crbug.com/141302.
71 static int g_browser_process_pid; 71 static int g_browser_process_pid;
72 static void DumpStackTraceSignalHandler(int signal) { 72 static void DumpStackTraceSignalHandler(int signal) {
73 if (g_browser_process_pid == base::GetCurrentProcId()) { 73 if (g_browser_process_pid == base::GetCurrentProcId()) {
74 logging::RawLog(logging::LOG_ERROR, 74 std::string message("BrowserTestBase received signal: ");
75 "BrowserTestBase signal handler received SIGTERM. " 75 message += strsignal(signal);
76 "Backtrace:\n"); 76 message += ". Backtrace:\n";
77 logging::RawLog(logging::LOG_ERROR, message.c_str());
77 base::debug::StackTrace().Print(); 78 base::debug::StackTrace().Print();
78 } 79 }
79 _exit(128 + signal); 80 _exit(128 + signal);
80 } 81 }
81 #endif // defined(OS_POSIX) 82 #endif // defined(OS_POSIX)
82 83
83 void RunTaskOnRendererThread(const base::Closure& task, 84 void RunTaskOnRendererThread(const base::Closure& task,
84 const base::Closure& quit_task) { 85 const base::Closure& quit_task) {
85 task.Run(); 86 task.Run();
86 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); 87 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 311 }
311 312
312 void BrowserTestBase::TearDown() { 313 void BrowserTestBase::TearDown() {
313 } 314 }
314 315
315 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { 316 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
316 #if defined(OS_POSIX) 317 #if defined(OS_POSIX)
317 if (handle_sigterm_) { 318 if (handle_sigterm_) {
318 g_browser_process_pid = base::GetCurrentProcId(); 319 g_browser_process_pid = base::GetCurrentProcId();
319 signal(SIGTERM, DumpStackTraceSignalHandler); 320 signal(SIGTERM, DumpStackTraceSignalHandler);
321 signal(SIGSEGV, DumpStackTraceSignalHandler);
Paweł Hajdan Jr. 2016/08/17 06:34:09 Could you just move this and g_browser_process_pid
michaelpg 2016/08/18 23:44:37 Done.
320 } 322 }
321 #endif // defined(OS_POSIX) 323 #endif // defined(OS_POSIX)
322 324
323 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 325 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
324 switches::kEnableTracing)) { 326 switches::kEnableTracing)) {
325 base::trace_event::TraceConfig trace_config( 327 base::trace_event::TraceConfig trace_config(
326 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 328 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
327 switches::kEnableTracing), 329 switches::kEnableTracing),
328 base::trace_event::RECORD_CONTINUOUSLY); 330 base::trace_event::RECORD_CONTINUOUSLY);
329 TracingController::GetInstance()->StartTracing( 331 TracingController::GetInstance()->StartTracing(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 use_software_compositing_ = true; 388 use_software_compositing_ = true;
387 } 389 }
388 390
389 bool BrowserTestBase::UsingOSMesa() const { 391 bool BrowserTestBase::UsingOSMesa() const {
390 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 392 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
391 return cmd->GetSwitchValueASCII(switches::kUseGL) == 393 return cmd->GetSwitchValueASCII(switches::kUseGL) ==
392 gl::kGLImplementationOSMesaName; 394 gl::kGLImplementationOSMesaName;
393 } 395 }
394 396
395 } // namespace content 397 } // 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