| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 20 matching lines...) Expand all Loading... |
| 31 #include "breakpad/src/common/linux/memory.h" | 31 #include "breakpad/src/common/linux/memory.h" |
| 32 #include "chrome/common/chrome_descriptors.h" | 32 #include "chrome/common/chrome_descriptors.h" |
| 33 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 34 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 35 #include "chrome/installer/util/google_update_settings.h" | 35 #include "chrome/installer/util/google_update_settings.h" |
| 36 #include "webkit/glue/plugins/plugin_list.h" | 36 #include "webkit/glue/plugins/plugin_list.h" |
| 37 | 37 |
| 38 static const char kUploadURL[] = | 38 static const char kUploadURL[] = |
| 39 "https://clients2.google.com/cr/report"; | 39 "https://clients2.google.com/cr/report"; |
| 40 | 40 |
| 41 static bool is_crash_reporter_enabled = false; |
| 41 static uint64_t uptime = 0; | 42 static uint64_t uptime = 0; |
| 42 | 43 |
| 43 // Writes the value |v| as 16 hex characters to the memory pointed at by | 44 // Writes the value |v| as 16 hex characters to the memory pointed at by |
| 44 // |output|. | 45 // |output|. |
| 45 static void write_uint64_hex(char* output, uint64_t v) { | 46 static void write_uint64_hex(char* output, uint64_t v) { |
| 46 static const char hextable[] = "0123456789abcdef"; | 47 static const char hextable[] = "0123456789abcdef"; |
| 47 | 48 |
| 48 for (int i = 15; i >= 0; --i) { | 49 for (int i = 15; i >= 0; --i) { |
| 49 output[i] = hextable[v & 15]; | 50 output[i] = hextable[v & 15]; |
| 50 v >>= 4; | 51 v >>= 4; |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 676 |
| 676 // Wrapper script, do not add more code here. | 677 // Wrapper script, do not add more code here. |
| 677 static bool CrashDoneUpload(const char* dump_path, | 678 static bool CrashDoneUpload(const char* dump_path, |
| 678 const char* minidump_id, | 679 const char* minidump_id, |
| 679 void* context, | 680 void* context, |
| 680 bool succeeded) { | 681 bool succeeded) { |
| 681 return CrashDone(dump_path, minidump_id, true, succeeded); | 682 return CrashDone(dump_path, minidump_id, true, succeeded); |
| 682 } | 683 } |
| 683 | 684 |
| 684 void EnableCrashDumping(const bool unattended) { | 685 void EnableCrashDumping(const bool unattended) { |
| 686 is_crash_reporter_enabled = true; |
| 685 if (unattended) { | 687 if (unattended) { |
| 686 FilePath dumps_path("/tmp"); | 688 FilePath dumps_path("/tmp"); |
| 687 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); | 689 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); |
| 688 new google_breakpad::ExceptionHandler(dumps_path.value().c_str(), NULL, | 690 new google_breakpad::ExceptionHandler(dumps_path.value().c_str(), NULL, |
| 689 CrashDoneNoUpload, NULL, | 691 CrashDoneNoUpload, NULL, |
| 690 true /* install handlers */); | 692 true /* install handlers */); |
| 691 } else { | 693 } else { |
| 692 new google_breakpad::ExceptionHandler("/tmp", NULL, CrashDoneUpload, NULL, | 694 new google_breakpad::ExceptionHandler("/tmp", NULL, CrashDoneUpload, NULL, |
| 693 true /* install handlers */); | 695 true /* install handlers */); |
| 694 } | 696 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 sys_close(fds[1]); | 755 sys_close(fds[1]); |
| 754 | 756 |
| 755 char b; | 757 char b; |
| 756 HANDLE_EINTR(sys_read(fds[0], &b, 1)); | 758 HANDLE_EINTR(sys_read(fds[0], &b, 1)); |
| 757 | 759 |
| 758 return true; | 760 return true; |
| 759 } | 761 } |
| 760 | 762 |
| 761 void EnableNonBrowserCrashDumping() { | 763 void EnableNonBrowserCrashDumping() { |
| 762 const int fd = Singleton<base::GlobalDescriptors>()->Get(kCrashDumpSignal); | 764 const int fd = Singleton<base::GlobalDescriptors>()->Get(kCrashDumpSignal); |
| 765 is_crash_reporter_enabled = true; |
| 763 // We deliberately leak this object. | 766 // We deliberately leak this object. |
| 764 google_breakpad::ExceptionHandler* handler = | 767 google_breakpad::ExceptionHandler* handler = |
| 765 new google_breakpad::ExceptionHandler("" /* unused */, NULL, NULL, | 768 new google_breakpad::ExceptionHandler("" /* unused */, NULL, NULL, |
| 766 (void*) fd, true); | 769 (void*) fd, true); |
| 767 handler->set_crash_handler(NonBrowserCrashHandler); | 770 handler->set_crash_handler(NonBrowserCrashHandler); |
| 768 } | 771 } |
| 769 | 772 |
| 770 void InitCrashReporter() { | 773 void InitCrashReporter() { |
| 771 // Determine the process type and take appropriate action. | 774 // Determine the process type and take appropriate action. |
| 772 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 775 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 800 EnableNonBrowserCrashDumping(); | 803 EnableNonBrowserCrashDumping(); |
| 801 } | 804 } |
| 802 | 805 |
| 803 // Set the base process uptime value. | 806 // Set the base process uptime value. |
| 804 struct timeval tv; | 807 struct timeval tv; |
| 805 if (!gettimeofday(&tv, NULL)) | 808 if (!gettimeofday(&tv, NULL)) |
| 806 uptime = timeval_to_ms(&tv); | 809 uptime = timeval_to_ms(&tv); |
| 807 else | 810 else |
| 808 uptime = 0; | 811 uptime = 0; |
| 809 } | 812 } |
| 813 |
| 814 bool IsCrashReporterEnabled() { |
| 815 return is_crash_reporter_enabled; |
| 816 } |
| OLD | NEW |