OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/app/breakpad_linux.h" | 5 #include "chrome/app/breakpad_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
10 #include <sys/time.h> | 10 #include <sys/time.h> |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 const size_t guid_len = std::min(google_update::posix_guid.size(), | 672 const size_t guid_len = std::min(google_update::posix_guid.size(), |
673 kGuidSize); | 673 kGuidSize); |
674 const size_t crash_url_len = | 674 const size_t crash_url_len = |
675 std::min(child_process_logging::active_url.size(), kMaxActiveURLSize); | 675 std::min(child_process_logging::active_url.size(), kMaxActiveURLSize); |
676 const size_t distro_len = | 676 const size_t distro_len = |
677 std::min(base::linux_distro.size(), kDistroSize); | 677 std::min(base::linux_distro.size(), kDistroSize); |
678 memcpy(guid, google_update::posix_guid.data(), guid_len); | 678 memcpy(guid, google_update::posix_guid.data(), guid_len); |
679 memcpy(crash_url, child_process_logging::active_url.data(), crash_url_len); | 679 memcpy(crash_url, child_process_logging::active_url.data(), crash_url_len); |
680 memcpy(distro, base::linux_distro.data(), distro_len); | 680 memcpy(distro, base::linux_distro.data(), distro_len); |
681 | 681 |
| 682 char b; // Dummy variable for sys_read below. |
| 683 const char* b_addr = &b; // Get the address of |b| so we can create the |
| 684 // expected /proc/[pid]/syscall content in the |
| 685 // browser to convert namespace tids. |
| 686 |
682 // The length of the control message: | 687 // The length of the control message: |
683 static const unsigned kControlMsgSize = CMSG_SPACE(sizeof(int)); | 688 static const unsigned kControlMsgSize = CMSG_SPACE(sizeof(int)); |
684 | 689 |
685 struct kernel_msghdr msg; | 690 struct kernel_msghdr msg; |
686 my_memset(&msg, 0, sizeof(struct kernel_msghdr)); | 691 my_memset(&msg, 0, sizeof(struct kernel_msghdr)); |
687 struct kernel_iovec iov[4]; | 692 struct kernel_iovec iov[6]; |
688 iov[0].iov_base = const_cast<void*>(crash_context); | 693 iov[0].iov_base = const_cast<void*>(crash_context); |
689 iov[0].iov_len = crash_context_size; | 694 iov[0].iov_len = crash_context_size; |
690 iov[1].iov_base = guid; | 695 iov[1].iov_base = guid; |
691 iov[1].iov_len = kGuidSize + 1; | 696 iov[1].iov_len = kGuidSize + 1; |
692 iov[2].iov_base = crash_url; | 697 iov[2].iov_base = crash_url; |
693 iov[2].iov_len = kMaxActiveURLSize + 1; | 698 iov[2].iov_len = kMaxActiveURLSize + 1; |
694 iov[3].iov_base = distro; | 699 iov[3].iov_base = distro; |
695 iov[3].iov_len = kDistroSize + 1; | 700 iov[3].iov_len = kDistroSize + 1; |
| 701 iov[4].iov_base = &b_addr; |
| 702 iov[4].iov_len = sizeof(b_addr); |
| 703 iov[5].iov_base = &fds[0]; |
| 704 iov[5].iov_len = sizeof(fds[0]); |
696 | 705 |
697 msg.msg_iov = iov; | 706 msg.msg_iov = iov; |
698 msg.msg_iovlen = 4; | 707 msg.msg_iovlen = 6; |
699 char cmsg[kControlMsgSize]; | 708 char cmsg[kControlMsgSize]; |
700 my_memset(cmsg, 0, kControlMsgSize); | 709 my_memset(cmsg, 0, kControlMsgSize); |
701 msg.msg_control = cmsg; | 710 msg.msg_control = cmsg; |
702 msg.msg_controllen = sizeof(cmsg); | 711 msg.msg_controllen = sizeof(cmsg); |
703 | 712 |
704 struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); | 713 struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); |
705 hdr->cmsg_level = SOL_SOCKET; | 714 hdr->cmsg_level = SOL_SOCKET; |
706 hdr->cmsg_type = SCM_RIGHTS; | 715 hdr->cmsg_type = SCM_RIGHTS; |
707 hdr->cmsg_len = CMSG_LEN(sizeof(int)); | 716 hdr->cmsg_len = CMSG_LEN(sizeof(int)); |
708 *((int*) CMSG_DATA(hdr)) = fds[1]; | 717 *((int*) CMSG_DATA(hdr)) = fds[1]; |
709 | 718 |
710 HANDLE_EINTR(sys_sendmsg(fd, &msg, 0)); | 719 HANDLE_EINTR(sys_sendmsg(fd, &msg, 0)); |
711 sys_close(fds[1]); | 720 sys_close(fds[1]); |
712 | 721 |
713 char b; | |
714 HANDLE_EINTR(sys_read(fds[0], &b, 1)); | 722 HANDLE_EINTR(sys_read(fds[0], &b, 1)); |
715 | 723 |
716 return true; | 724 return true; |
717 } | 725 } |
718 | 726 |
719 void EnableNonBrowserCrashDumping() { | 727 void EnableNonBrowserCrashDumping() { |
720 const int fd = Singleton<base::GlobalDescriptors>()->Get(kCrashDumpSignal); | 728 const int fd = Singleton<base::GlobalDescriptors>()->Get(kCrashDumpSignal); |
721 is_crash_reporter_enabled = true; | 729 is_crash_reporter_enabled = true; |
722 // We deliberately leak this object. | 730 // We deliberately leak this object. |
723 google_breakpad::ExceptionHandler* handler = | 731 google_breakpad::ExceptionHandler* handler = |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 struct timeval tv; | 771 struct timeval tv; |
764 if (!gettimeofday(&tv, NULL)) | 772 if (!gettimeofday(&tv, NULL)) |
765 uptime = timeval_to_ms(&tv); | 773 uptime = timeval_to_ms(&tv); |
766 else | 774 else |
767 uptime = 0; | 775 uptime = 0; |
768 } | 776 } |
769 | 777 |
770 bool IsCrashReporterEnabled() { | 778 bool IsCrashReporterEnabled() { |
771 return is_crash_reporter_enabled; | 779 return is_crash_reporter_enabled; |
772 } | 780 } |
OLD | NEW |