| 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 <arpa/inet.h> | 7 #include <arpa/inet.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <netinet/in.h> | 9 #include <netinet/in.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| 11 #include <sys/sendfile.h> | 11 #include <sys/sendfile.h> |
| 12 #include <sys/socket.h> | 12 #include <sys/socket.h> |
| 13 #include <sys/uio.h> | 13 #include <sys/uio.h> |
| 14 #include <sys/wait.h> | 14 #include <sys/wait.h> |
| 15 #include <unistd.h> | 15 #include <unistd.h> |
| 16 | 16 |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 #include <string> | 18 #include <string> |
| 19 | 19 |
| 20 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| 21 #include "base/eintr_wrapper.h" | 21 #include "base/eintr_wrapper.h" |
| 22 #include "base/file_path.h" | 22 #include "base/file_path.h" |
| 23 #include "base/file_version_info_linux.h" | 23 #include "base/file_version_info_linux.h" |
| 24 #include "base/format_macros.h" | 24 #include "base/format_macros.h" |
| 25 #include "base/global_descriptors_posix.h" | 25 #include "base/global_descriptors_posix.h" |
| 26 #include "base/json_writer.h" | 26 #include "base/json_writer.h" |
| 27 #include "base/linux_util.h" | |
| 28 #include "base/path_service.h" | 27 #include "base/path_service.h" |
| 29 #include "base/rand_util.h" | 28 #include "base/rand_util.h" |
| 30 #include "base/scoped_fd.h" | 29 #include "base/scoped_fd.h" |
| 31 #include "base/string_util.h" | 30 #include "base/string_util.h" |
| 32 #include "base/values.h" | 31 #include "base/values.h" |
| 33 #include "breakpad/linux/directory_reader.h" | 32 #include "breakpad/linux/directory_reader.h" |
| 34 #include "breakpad/linux/exception_handler.h" | 33 #include "breakpad/linux/exception_handler.h" |
| 35 #include "breakpad/linux/linux_libc_support.h" | 34 #include "breakpad/linux/linux_libc_support.h" |
| 36 #include "breakpad/linux/linux_syscall_support.h" | 35 #include "breakpad/linux/linux_syscall_support.h" |
| 37 #include "breakpad/linux/memory.h" | 36 #include "breakpad/linux/memory.h" |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 636 |
| 638 void InitCrashReporter() { | 637 void InitCrashReporter() { |
| 639 // Determine the process type and take appropriate action. | 638 // Determine the process type and take appropriate action. |
| 640 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 639 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 641 const std::wstring process_type = | 640 const std::wstring process_type = |
| 642 parsed_command_line.GetSwitchValue(switches::kProcessType); | 641 parsed_command_line.GetSwitchValue(switches::kProcessType); |
| 643 const bool unattended = (getenv("CHROME_HEADLESS") != NULL); | 642 const bool unattended = (getenv("CHROME_HEADLESS") != NULL); |
| 644 if (process_type.empty()) { | 643 if (process_type.empty()) { |
| 645 if (!(unattended || GoogleUpdateSettings::GetCollectStatsConsent())) | 644 if (!(unattended || GoogleUpdateSettings::GetCollectStatsConsent())) |
| 646 return; | 645 return; |
| 647 base::GetLinuxDistro(); // Initialize base::linux_distro if needed. | |
| 648 EnableCrashDumping(unattended); | 646 EnableCrashDumping(unattended); |
| 649 } else if (process_type == switches::kRendererProcess || | 647 } else if (process_type == switches::kRendererProcess || |
| 650 process_type == switches::kZygoteProcess) { | 648 process_type == switches::kZygoteProcess) { |
| 651 // We might be chrooted in a zygote or renderer process so we cannot call | 649 // We might be chrooted in a zygote or renderer process so we cannot call |
| 652 // GetCollectStatsConsent because that needs access the the user's home | 650 // GetCollectStatsConsent because that needs access the the user's home |
| 653 // dir. Instead, we set a command line flag for these processes. | 651 // dir. Instead, we set a command line flag for these processes. |
| 654 if (!parsed_command_line.HasSwitch(switches::kEnableCrashReporter)) | 652 if (!parsed_command_line.HasSwitch(switches::kEnableCrashReporter)) |
| 655 return; | 653 return; |
| 656 // Get the guid and linux distro from the command line switch. | 654 // Get the guid and linux distro from the command line switch. |
| 657 std::string switch_value = WideToASCII( | 655 std::string switch_value = WideToASCII( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 818 |
| 821 if (WIFSIGNALED(status) && WCOREDUMP(status)) { | 819 if (WIFSIGNALED(status) && WCOREDUMP(status)) { |
| 822 std::string core_filename; | 820 std::string core_filename; |
| 823 UploadCoreFile(child, &core_filename); | 821 UploadCoreFile(child, &core_filename); |
| 824 unlink(core_filename.c_str()); | 822 unlink(core_filename.c_str()); |
| 825 } | 823 } |
| 826 | 824 |
| 827 rmdir(core_dump_directory.c_str()); | 825 rmdir(core_dump_directory.c_str()); |
| 828 } | 826 } |
| 829 #endif | 827 #endif |
| OLD | NEW |