| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // For linux_syscall_support.h. This makes it safe to call embedded system | 5 // For linux_syscall_support.h. This makes it safe to call embedded system |
| 6 // calls when in seccomp mode. | 6 // calls when in seccomp mode. |
| 7 | 7 |
| 8 #include "components/crash/content/app/breakpad_linux.h" | 8 #include "components/crash/content/app/breakpad_linux.h" |
| 9 | 9 |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "base/debug/crash_logging.h" | 30 #include "base/debug/crash_logging.h" |
| 31 #include "base/debug/dump_without_crashing.h" | 31 #include "base/debug/dump_without_crashing.h" |
| 32 #include "base/files/file_path.h" | 32 #include "base/files/file_path.h" |
| 33 #include "base/lazy_instance.h" | 33 #include "base/lazy_instance.h" |
| 34 #include "base/linux_util.h" | 34 #include "base/linux_util.h" |
| 35 #include "base/macros.h" | 35 #include "base/macros.h" |
| 36 #include "base/path_service.h" | 36 #include "base/path_service.h" |
| 37 #include "base/posix/eintr_wrapper.h" | 37 #include "base/posix/eintr_wrapper.h" |
| 38 #include "base/posix/global_descriptors.h" | 38 #include "base/posix/global_descriptors.h" |
| 39 #include "base/process/memory.h" | 39 #include "base/process/memory.h" |
| 40 #include "base/strings/string_split.h" |
| 40 #include "base/strings/string_util.h" | 41 #include "base/strings/string_util.h" |
| 41 #include "base/threading/thread_checker.h" | 42 #include "base/threading/thread_checker.h" |
| 42 #include "breakpad/src/client/linux/crash_generation/crash_generation_client.h" | 43 #include "breakpad/src/client/linux/crash_generation/crash_generation_client.h" |
| 43 #include "breakpad/src/client/linux/handler/exception_handler.h" | 44 #include "breakpad/src/client/linux/handler/exception_handler.h" |
| 44 #include "breakpad/src/client/linux/minidump_writer/directory_reader.h" | 45 #include "breakpad/src/client/linux/minidump_writer/directory_reader.h" |
| 45 #include "breakpad/src/common/linux/linux_libc_support.h" | 46 #include "breakpad/src/common/linux/linux_libc_support.h" |
| 46 #include "breakpad/src/common/memory.h" | 47 #include "breakpad/src/common/memory.h" |
| 47 #include "build/build_config.h" | 48 #include "build/build_config.h" |
| 48 #include "components/crash/content/app/breakpad_linux_impl.h" | 49 #include "components/crash/content/app/breakpad_linux_impl.h" |
| 49 #include "components/crash/content/app/crash_reporter_client.h" | 50 #include "components/crash/content/app/crash_reporter_client.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 217 } |
| 217 #endif | 218 #endif |
| 218 | 219 |
| 219 size_t LengthWithoutTrailingSpaces(const char* str, size_t len) { | 220 size_t LengthWithoutTrailingSpaces(const char* str, size_t len) { |
| 220 while (len > 0 && str[len - 1] == ' ') { | 221 while (len > 0 && str[len - 1] == ' ') { |
| 221 len--; | 222 len--; |
| 222 } | 223 } |
| 223 return len; | 224 return len; |
| 224 } | 225 } |
| 225 | 226 |
| 226 void SetClientIdFromCommandLine(const base::CommandLine& command_line) { | 227 bool GetEnableCrashReporterSwitchParts(const base::CommandLine& command_line, |
| 227 // Get the guid from the command line switch. | 228 std::vector<std::string>* switch_parts) { |
| 228 std::string switch_value = | 229 std::string switch_value = |
| 229 command_line.GetSwitchValueASCII(switches::kEnableCrashReporter); | 230 command_line.GetSwitchValueASCII(switches::kEnableCrashReporter); |
| 230 GetCrashReporterClient()->SetCrashReporterClientIdFromGUID(switch_value); | 231 std::vector<std::string> parts = base::SplitString(switch_value, |
| 232 ",", |
| 233 base::KEEP_WHITESPACE, |
| 234 base::SPLIT_WANT_ALL); |
| 235 if (parts.size() != 2) |
| 236 return false; |
| 237 |
| 238 *switch_parts = parts; |
| 239 return true; |
| 240 } |
| 241 |
| 242 #if !defined(OS_ANDROID) |
| 243 void SetChannelFromCommandLine(const base::CommandLine& command_line) { |
| 244 std::vector<std::string> switch_parts; |
| 245 if (!GetEnableCrashReporterSwitchParts(command_line, &switch_parts)) |
| 246 return; |
| 247 |
| 248 base::debug::SetCrashKeyValue(crash_keys::kChannel, switch_parts[1]); |
| 249 } |
| 250 #endif |
| 251 |
| 252 void SetClientIdFromCommandLine(const base::CommandLine& command_line) { |
| 253 std::vector<std::string> switch_parts; |
| 254 if (!GetEnableCrashReporterSwitchParts(command_line, &switch_parts)) |
| 255 return; |
| 256 |
| 257 GetCrashReporterClient()->SetCrashReporterClientIdFromGUID(switch_parts[0]); |
| 231 } | 258 } |
| 232 | 259 |
| 233 // MIME substrings. | 260 // MIME substrings. |
| 234 #if defined(OS_CHROMEOS) | 261 #if defined(OS_CHROMEOS) |
| 235 const char g_sep[] = ":"; | 262 const char g_sep[] = ":"; |
| 236 #endif | 263 #endif |
| 237 const char g_rn[] = "\r\n"; | 264 const char g_rn[] = "\r\n"; |
| 238 const char g_form_data_msg[] = "Content-Disposition: form-data; name=\""; | 265 const char g_form_data_msg[] = "Content-Disposition: form-data; name=\""; |
| 239 const char g_quote_msg[] = "\""; | 266 const char g_quote_msg[] = "\""; |
| 240 const char g_dashdash_msg[] = "--"; | 267 const char g_dashdash_msg[] = "--"; |
| (...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 "InitNonBrowserCrashReporter in " << process_type << " process."; | 1847 "InitNonBrowserCrashReporter in " << process_type << " process."; |
| 1821 return; | 1848 return; |
| 1822 #else | 1849 #else |
| 1823 // We might be chrooted in a zygote or renderer process so we cannot call | 1850 // We might be chrooted in a zygote or renderer process so we cannot call |
| 1824 // GetCollectStatsConsent because that needs access the the user's home | 1851 // GetCollectStatsConsent because that needs access the the user's home |
| 1825 // dir. Instead, we set a command line flag for these processes. | 1852 // dir. Instead, we set a command line flag for these processes. |
| 1826 // Even though plugins are not chrooted, we share the same code path for | 1853 // Even though plugins are not chrooted, we share the same code path for |
| 1827 // simplicity. | 1854 // simplicity. |
| 1828 if (!parsed_command_line.HasSwitch(switches::kEnableCrashReporter)) | 1855 if (!parsed_command_line.HasSwitch(switches::kEnableCrashReporter)) |
| 1829 return; | 1856 return; |
| 1857 |
| 1830 InitCrashKeys(); | 1858 InitCrashKeys(); |
| 1859 SetChannelFromCommandLine(parsed_command_line); |
| 1831 SetClientIdFromCommandLine(parsed_command_line); | 1860 SetClientIdFromCommandLine(parsed_command_line); |
| 1832 EnableNonBrowserCrashDumping(); | 1861 EnableNonBrowserCrashDumping(); |
| 1833 VLOG(1) << "Non Browser crash dumping enabled for: " << process_type; | 1862 VLOG(1) << "Non Browser crash dumping enabled for: " << process_type; |
| 1834 #endif // #if defined(OS_ANDROID) | 1863 #endif // #if defined(OS_ANDROID) |
| 1835 } | 1864 } |
| 1836 | 1865 |
| 1837 PostEnableBreakpadInitialization(); | 1866 PostEnableBreakpadInitialization(); |
| 1838 } | 1867 } |
| 1839 | 1868 |
| 1840 #if defined(OS_ANDROID) | 1869 #if defined(OS_ANDROID) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 const std::string& gpu_fingerprint) { | 1920 const std::string& gpu_fingerprint) { |
| 1892 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); | 1921 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); |
| 1893 } | 1922 } |
| 1894 #endif // OS_ANDROID | 1923 #endif // OS_ANDROID |
| 1895 | 1924 |
| 1896 bool IsCrashReporterEnabled() { | 1925 bool IsCrashReporterEnabled() { |
| 1897 return g_is_crash_reporter_enabled; | 1926 return g_is_crash_reporter_enabled; |
| 1898 } | 1927 } |
| 1899 | 1928 |
| 1900 } // namespace breakpad | 1929 } // namespace breakpad |
| OLD | NEW |