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

Side by Side Diff: base/debug/stack_trace_posix.cc

Issue 11280010: Extract SIGPIPE ignoring code to a common place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ios Created 8 years, 1 month 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 | Annotate | Revision Log
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 "base/debug/stack_trace.h" 5 #include "base/debug/stack_trace.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <execinfo.h> 8 #include <execinfo.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 12 matching lines...) Expand all
23 23
24 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
25 #include <AvailabilityMacros.h> 25 #include <AvailabilityMacros.h>
26 #endif 26 #endif
27 27
28 #include "base/basictypes.h" 28 #include "base/basictypes.h"
29 #include "base/debug/debugger.h" 29 #include "base/debug/debugger.h"
30 #include "base/logging.h" 30 #include "base/logging.h"
31 #include "base/memory/scoped_ptr.h" 31 #include "base/memory/scoped_ptr.h"
32 #include "base/posix/eintr_wrapper.h" 32 #include "base/posix/eintr_wrapper.h"
33 #include "base/process_util.h"
33 #include "base/string_number_conversions.h" 34 #include "base/string_number_conversions.h"
34 35
35 #if defined(USE_SYMBOLIZE) 36 #if defined(USE_SYMBOLIZE)
36 #include "base/third_party/symbolize/symbolize.h" 37 #include "base/third_party/symbolize/symbolize.h"
37 #endif 38 #endif
38 39
39 namespace base { 40 namespace base {
40 namespace debug { 41 namespace debug {
41 42
42 namespace { 43 namespace {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 StackTrace stack_trace; 295 StackTrace stack_trace;
295 } 296 }
296 297
297 } // namespace 298 } // namespace
298 299
299 #if !defined(OS_IOS) 300 #if !defined(OS_IOS)
300 bool EnableInProcessStackDumping() { 301 bool EnableInProcessStackDumping() {
301 // When running in an application, our code typically expects SIGPIPE 302 // When running in an application, our code typically expects SIGPIPE
302 // to be ignored. Therefore, when testing that same code, it should run 303 // to be ignored. Therefore, when testing that same code, it should run
303 // with SIGPIPE ignored as well. 304 // with SIGPIPE ignored as well.
304 struct sigaction action; 305 bool success = base::IgnoreSigPipe();
305 memset(&action, 0, sizeof(action));
306 action.sa_handler = SIG_IGN;
307 sigemptyset(&action.sa_mask);
308 bool success = (sigaction(SIGPIPE, &action, NULL) == 0);
309 306
310 // Avoid hangs during backtrace initialization, see above. 307 // Avoid hangs during backtrace initialization, see above.
311 WarmUpBacktrace(); 308 WarmUpBacktrace();
312 309
313 sig_t handler = reinterpret_cast<sig_t>(&StackDumpSignalHandler); 310 sig_t handler = reinterpret_cast<sig_t>(&StackDumpSignalHandler);
314 success &= (signal(SIGILL, handler) != SIG_ERR); 311 success &= (signal(SIGILL, handler) != SIG_ERR);
315 success &= (signal(SIGABRT, handler) != SIG_ERR); 312 success &= (signal(SIGABRT, handler) != SIG_ERR);
316 success &= (signal(SIGFPE, handler) != SIG_ERR); 313 success &= (signal(SIGFPE, handler) != SIG_ERR);
317 success &= (signal(SIGBUS, handler) != SIG_ERR); 314 success &= (signal(SIGBUS, handler) != SIG_ERR);
318 success &= (signal(SIGSEGV, handler) != SIG_ERR); 315 success &= (signal(SIGSEGV, handler) != SIG_ERR);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 *ptr = *start; 398 *ptr = *start;
402 *start++ = ch; 399 *start++ = ch;
403 } 400 }
404 return buf; 401 return buf;
405 } 402 }
406 403
407 } // namespace internal 404 } // namespace internal
408 405
409 } // namespace debug 406 } // namespace debug
410 } // namespace base 407 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/stack_trace_android.cc ('k') | base/process_util.h » ('j') | base/process_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698