| OLD | NEW |
| 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 <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 // at ../sysdeps/x86_64/../ia64/backtrace.c:104 | 437 // at ../sysdeps/x86_64/../ia64/backtrace.c:104 |
| 438 // #20 0x0000000000752a54 in base::debug::StackTrace::StackTrace | 438 // #20 0x0000000000752a54 in base::debug::StackTrace::StackTrace |
| 439 // at base/debug/stack_trace_posix.cc:175 | 439 // at base/debug/stack_trace_posix.cc:175 |
| 440 // #21 0x00000000007a4ae5 in | 440 // #21 0x00000000007a4ae5 in |
| 441 // base::(anonymous namespace)::StackDumpSignalHandler | 441 // base::(anonymous namespace)::StackDumpSignalHandler |
| 442 // at base/process_util_posix.cc:172 | 442 // at base/process_util_posix.cc:172 |
| 443 // #22 <signal handler called> | 443 // #22 <signal handler called> |
| 444 StackTrace stack_trace; | 444 StackTrace stack_trace; |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace | |
| 448 | |
| 449 #if defined(USE_SYMBOLIZE) | 447 #if defined(USE_SYMBOLIZE) |
| 450 | 448 |
| 451 // class SandboxSymbolizeHelper. | 449 // class SandboxSymbolizeHelper. |
| 452 // | 450 // |
| 453 // The purpose of this class is to prepare and install a "file open" callback | 451 // The purpose of this class is to prepare and install a "file open" callback |
| 454 // needed by the stack trace symbolization code | 452 // needed by the stack trace symbolization code |
| 455 // (base/third_party/symbolize/symbolize.h) so that it can function properly | 453 // (base/third_party/symbolize/symbolize.h) so that it can function properly |
| 456 // in a sandboxed process. The caveat is that this class must be instantiated | 454 // in a sandboxed process. The caveat is that this class must be instantiated |
| 457 // before the sandboxing is enabled so that it can get the chance to open all | 455 // before the sandboxing is enabled so that it can get the chance to open all |
| 458 // the object files that are loaded in the virtual address space of the current | 456 // the object files that are loaded in the virtual address space of the current |
| 459 // process. | 457 // process. |
| 460 class SandboxSymbolizeHelper { | 458 class SandboxSymbolizeHelper { |
| 461 public: | 459 public: |
| 462 // Returns the singleton instance. | 460 // Returns the singleton instance. |
| 463 static SandboxSymbolizeHelper* GetInstance() { | 461 static SandboxSymbolizeHelper* GetInstance() { |
| 464 return Singleton<SandboxSymbolizeHelper>::get(); | 462 return Singleton<SandboxSymbolizeHelper, |
| 463 LeakySingletonTraits<SandboxSymbolizeHelper>>::get(); |
| 465 } | 464 } |
| 466 | 465 |
| 467 private: | 466 private: |
| 468 friend struct DefaultSingletonTraits<SandboxSymbolizeHelper>; | 467 friend struct DefaultSingletonTraits<SandboxSymbolizeHelper>; |
| 469 | 468 |
| 470 SandboxSymbolizeHelper() | 469 SandboxSymbolizeHelper() |
| 471 : is_initialized_(false) { | 470 : is_initialized_(false) { |
| 472 Init(); | 471 Init(); |
| 473 } | 472 } |
| 474 | 473 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 #endif // !defined(OFFICIAL_BUILD) | 669 #endif // !defined(OFFICIAL_BUILD) |
| 671 | 670 |
| 672 // Cache for the process memory regions. Produced by parsing the contents | 671 // Cache for the process memory regions. Produced by parsing the contents |
| 673 // of /proc/self/maps cache. | 672 // of /proc/self/maps cache. |
| 674 std::vector<MappedMemoryRegion> regions_; | 673 std::vector<MappedMemoryRegion> regions_; |
| 675 | 674 |
| 676 DISALLOW_COPY_AND_ASSIGN(SandboxSymbolizeHelper); | 675 DISALLOW_COPY_AND_ASSIGN(SandboxSymbolizeHelper); |
| 677 }; | 676 }; |
| 678 #endif // USE_SYMBOLIZE | 677 #endif // USE_SYMBOLIZE |
| 679 | 678 |
| 679 } // namespace |
| 680 |
| 680 bool EnableInProcessStackDumping() { | 681 bool EnableInProcessStackDumping() { |
| 681 #if defined(USE_SYMBOLIZE) | 682 #if defined(USE_SYMBOLIZE) |
| 682 SandboxSymbolizeHelper::GetInstance(); | 683 SandboxSymbolizeHelper::GetInstance(); |
| 683 #endif // USE_SYMBOLIZE | 684 #endif // USE_SYMBOLIZE |
| 684 | 685 |
| 685 // When running in an application, our code typically expects SIGPIPE | 686 // When running in an application, our code typically expects SIGPIPE |
| 686 // to be ignored. Therefore, when testing that same code, it should run | 687 // to be ignored. Therefore, when testing that same code, it should run |
| 687 // with SIGPIPE ignored as well. | 688 // with SIGPIPE ignored as well. |
| 688 struct sigaction sigpipe_action; | 689 struct sigaction sigpipe_action; |
| 689 memset(&sigpipe_action, 0, sizeof(sigpipe_action)); | 690 memset(&sigpipe_action, 0, sizeof(sigpipe_action)); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 *ptr = *start; | 805 *ptr = *start; |
| 805 *start++ = ch; | 806 *start++ = ch; |
| 806 } | 807 } |
| 807 return buf; | 808 return buf; |
| 808 } | 809 } |
| 809 | 810 |
| 810 } // namespace internal | 811 } // namespace internal |
| 811 | 812 |
| 812 } // namespace debug | 813 } // namespace debug |
| 813 } // namespace base | 814 } // namespace base |
| OLD | NEW |