| 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 "chrome/browser/crash_handler_host_linux.h" | 5 #include "components/breakpad/browser/crash_handler_host_linux.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/syscall.h> | 10 #include <sys/syscall.h> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
| 17 #include "base/linux_util.h" | 17 #include "base/linux_util.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
| 20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/posix/eintr_wrapper.h" | 22 #include "base/posix/eintr_wrapper.h" |
| 23 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 26 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
| 27 #include "breakpad/src/client/linux/handler/exception_handler.h" | 27 #include "breakpad/src/client/linux/handler/exception_handler.h" |
| 28 #include "breakpad/src/client/linux/minidump_writer/linux_dumper.h" | 28 #include "breakpad/src/client/linux/minidump_writer/linux_dumper.h" |
| 29 #include "breakpad/src/client/linux/minidump_writer/minidump_writer.h" | 29 #include "breakpad/src/client/linux/minidump_writer/minidump_writer.h" |
| 30 #include "chrome/app/breakpad_linux_impl.h" | 30 #include "components/breakpad/app/breakpad_linux_impl.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 | 32 |
| 33 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 34 #include <sys/linux-syscalls.h> | 34 #include <sys/linux-syscalls.h> |
| 35 | 35 |
| 36 #define SYS_read __NR_read | 36 #define SYS_read __NR_read |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 using content::BrowserThread; | 39 using content::BrowserThread; |
| 40 using google_breakpad::ExceptionHandler; | 40 using google_breakpad::ExceptionHandler; |
| 41 | 41 |
| 42 namespace breakpad { |
| 43 |
| 42 namespace { | 44 namespace { |
| 43 | 45 |
| 44 // The length of the control message: | 46 // The length of the control message: |
| 45 const unsigned kControlMsgSize = | 47 const unsigned kControlMsgSize = |
| 46 CMSG_SPACE(2*sizeof(int)) + CMSG_SPACE(sizeof(struct ucred)); | 48 CMSG_SPACE(2*sizeof(int)) + CMSG_SPACE(sizeof(struct ucred)); |
| 47 // The length of the regular payload: | 49 // The length of the regular payload: |
| 48 const unsigned kCrashContextSize = sizeof(ExceptionHandler::CrashContext); | 50 const unsigned kCrashContextSize = sizeof(ExceptionHandler::CrashContext); |
| 49 | 51 |
| 50 // Handles the crash dump and frees the allocated BreakpadInfo struct. | 52 // Handles the crash dump and frees the allocated BreakpadInfo struct. |
| 51 void CrashDumpTask(CrashHandlerHostLinux* handler, BreakpadInfo* info) { | 53 void CrashDumpTask(CrashHandlerHostLinux* handler, BreakpadInfo* info) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 123 } |
| 122 | 124 |
| 123 void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { | 125 void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { |
| 124 DCHECK_EQ(fd, browser_socket_); | 126 DCHECK_EQ(fd, browser_socket_); |
| 125 | 127 |
| 126 // A process has crashed and has signaled us by writing a datagram | 128 // A process has crashed and has signaled us by writing a datagram |
| 127 // to the death signal socket. The datagram contains the crash context needed | 129 // to the death signal socket. The datagram contains the crash context needed |
| 128 // for writing the minidump as well as a file descriptor and a credentials | 130 // for writing the minidump as well as a file descriptor and a credentials |
| 129 // block so that they can't lie about their pid. | 131 // block so that they can't lie about their pid. |
| 130 // | 132 // |
| 131 // The message sender is in chrome/app/breakpad_linux.cc. | 133 // The message sender is in components/breakpad/app/breakpad_linux.cc. |
| 132 | 134 |
| 133 struct msghdr msg = {0}; | 135 struct msghdr msg = {0}; |
| 134 struct iovec iov[kCrashIovSize]; | 136 struct iovec iov[kCrashIovSize]; |
| 135 | 137 |
| 136 // Freed in WriteDumpFile(); | 138 // Freed in WriteDumpFile(); |
| 137 char* crash_context = new char[kCrashContextSize]; | 139 char* crash_context = new char[kCrashContextSize]; |
| 138 // Freed in CrashDumpTask(); | 140 // Freed in CrashDumpTask(); |
| 139 char* distro = new char[kDistroSize + 1]; | 141 char* distro = new char[kDistroSize + 1]; |
| 140 #if defined(ADDRESS_SANITIZER) | 142 #if defined(ADDRESS_SANITIZER) |
| 141 asan_report_str_ = new char[kMaxAsanReportSize + 1]; | 143 asan_report_str_ = new char[kMaxAsanReportSize + 1]; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 445 |
| 444 // If we are quitting and there are crash dumps in the queue, turn them into | 446 // If we are quitting and there are crash dumps in the queue, turn them into |
| 445 // no-ops. | 447 // no-ops. |
| 446 shutting_down_ = true; | 448 shutting_down_ = true; |
| 447 uploader_thread_->Stop(); | 449 uploader_thread_->Stop(); |
| 448 } | 450 } |
| 449 | 451 |
| 450 bool CrashHandlerHostLinux::IsShuttingDown() const { | 452 bool CrashHandlerHostLinux::IsShuttingDown() const { |
| 451 return shutting_down_; | 453 return shutting_down_; |
| 452 } | 454 } |
| 455 |
| 456 } // namespace breakpad |
| OLD | NEW |