Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 bool g_is_crash_reporter_enabled = false; | 94 bool g_is_crash_reporter_enabled = false; |
| 95 uint64_t g_process_start_time = 0; | 95 uint64_t g_process_start_time = 0; |
| 96 pid_t g_pid = 0; | 96 pid_t g_pid = 0; |
| 97 char* g_crash_log_path = nullptr; | 97 char* g_crash_log_path = nullptr; |
| 98 ExceptionHandler* g_breakpad = nullptr; | 98 ExceptionHandler* g_breakpad = nullptr; |
| 99 | 99 |
| 100 #if defined(ADDRESS_SANITIZER) | 100 #if defined(ADDRESS_SANITIZER) |
| 101 const char* g_asan_report_str = nullptr; | 101 const char* g_asan_report_str = nullptr; |
| 102 #endif | 102 #endif |
| 103 #if defined(OS_ANDROID) | 103 #if defined(OS_ANDROID) |
| 104 const char kWebViewProcessType[] = "webview"; | 104 // Keep these 3 string for webview in sync with the ones in aw_main_delegate.cc. |
|
sgurun-gerrit only
2016/06/24 23:57:57
please do not duplicate the consts, especially sin
hush (inactive)
2016/06/27 22:15:26
I put this section in the header file.
| |
| 105 const char kWebViewSingleProcessType[] = "webview-singleprocess"; | |
| 106 const char kWebViewBrowserProcessType[] = "webview-multiprocess-browser"; | |
| 107 const char kWebViewRendererProcessType[] = "webview-multiprocess-renderer"; | |
| 105 char* g_process_type = nullptr; | 108 char* g_process_type = nullptr; |
| 106 ExceptionHandler* g_microdump = nullptr; | 109 ExceptionHandler* g_microdump = nullptr; |
| 107 int g_signal_code_pipe_fd = -1; | 110 int g_signal_code_pipe_fd = -1; |
| 108 | 111 |
| 109 class MicrodumpInfo { | 112 class MicrodumpInfo { |
| 110 public: | 113 public: |
| 111 MicrodumpInfo() | 114 MicrodumpInfo() |
| 112 : microdump_build_fingerprint_(nullptr), | 115 : microdump_build_fingerprint_(nullptr), |
| 113 microdump_product_info_(nullptr), | 116 microdump_product_info_(nullptr), |
| 114 microdump_gpu_fingerprint_(nullptr) {} | 117 microdump_gpu_fingerprint_(nullptr) {} |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 130 void Initialize(const std::string& process_type, | 133 void Initialize(const std::string& process_type, |
| 131 const char* product_name, | 134 const char* product_name, |
| 132 const char* product_version, | 135 const char* product_version, |
| 133 const char* android_build_fp); | 136 const char* android_build_fp); |
| 134 | 137 |
| 135 private: | 138 private: |
| 136 base::ThreadChecker thread_checker_; | 139 base::ThreadChecker thread_checker_; |
| 137 const char* microdump_build_fingerprint_; | 140 const char* microdump_build_fingerprint_; |
| 138 const char* microdump_product_info_; | 141 const char* microdump_product_info_; |
| 139 const char* microdump_gpu_fingerprint_; | 142 const char* microdump_gpu_fingerprint_; |
| 143 const char* microdump_process_type_; | |
| 140 }; | 144 }; |
| 141 | 145 |
| 142 base::LazyInstance<MicrodumpInfo> g_microdump_info = | 146 base::LazyInstance<MicrodumpInfo> g_microdump_info = |
| 143 LAZY_INSTANCE_INITIALIZER; | 147 LAZY_INSTANCE_INITIALIZER; |
| 144 | 148 |
| 145 #endif | 149 #endif |
| 146 | 150 |
| 147 CrashKeyStorage* g_crash_keys = nullptr; | 151 CrashKeyStorage* g_crash_keys = nullptr; |
| 148 | 152 |
| 149 // Writes the value |v| as 16 hex characters to the memory pointed at by | 153 // Writes the value |v| as 16 hex characters to the memory pointed at by |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 g_microdump->set_minidump_descriptor(minidump_descriptor); | 875 g_microdump->set_minidump_descriptor(minidump_descriptor); |
| 872 } | 876 } |
| 873 } | 877 } |
| 874 | 878 |
| 875 void MicrodumpInfo::Initialize(const std::string& process_type, | 879 void MicrodumpInfo::Initialize(const std::string& process_type, |
| 876 const char* product_name, | 880 const char* product_name, |
| 877 const char* product_version, | 881 const char* product_version, |
| 878 const char* android_build_fp) { | 882 const char* android_build_fp) { |
| 879 DCHECK(thread_checker_.CalledOnValidThread()); | 883 DCHECK(thread_checker_.CalledOnValidThread()); |
| 880 DCHECK(!g_microdump); | 884 DCHECK(!g_microdump); |
| 881 bool is_browser_process = | 885 bool is_browser_process = process_type.empty() || |
| 882 process_type.empty() || process_type == kWebViewProcessType; | 886 process_type == kWebViewSingleProcessType || |
| 887 process_type == kWebViewBrowserProcessType; | |
| 883 | 888 |
| 884 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole); | 889 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole); |
| 885 | 890 |
| 886 if (product_name && product_version) { | 891 if (product_name && product_version) { |
| 887 microdump_product_info_ = | 892 microdump_product_info_ = |
| 888 strdup((product_name + std::string(":") + product_version).c_str()); | 893 strdup((product_name + std::string(":") + product_version).c_str()); |
| 889 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_); | 894 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_); |
| 890 descriptor.microdump_extra_info()->product_info = microdump_product_info_; | 895 descriptor.microdump_extra_info()->product_info = microdump_product_info_; |
| 891 } | 896 } |
| 892 | 897 |
| 898 microdump_process_type_ = | |
| 899 strdup(process_type.empty() ? "browser" : process_type.c_str()); | |
| 900 ANNOTATE_LEAKING_OBJECT_PTR(microdump_process_type_); | |
| 901 descriptor.microdump_extra_info()->process_type = microdump_process_type_; | |
| 902 | |
| 893 if (android_build_fp) { | 903 if (android_build_fp) { |
| 894 microdump_build_fingerprint_ = strdup(android_build_fp); | 904 microdump_build_fingerprint_ = strdup(android_build_fp); |
| 895 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_); | 905 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_); |
| 896 descriptor.microdump_extra_info()->build_fingerprint = | 906 descriptor.microdump_extra_info()->build_fingerprint = |
| 897 microdump_build_fingerprint_; | 907 microdump_build_fingerprint_; |
| 898 } | 908 } |
| 899 | 909 |
| 900 if (microdump_gpu_fingerprint_) { | 910 if (microdump_gpu_fingerprint_) { |
| 901 descriptor.microdump_extra_info()->gpu_fingerprint = | 911 descriptor.microdump_extra_info()->gpu_fingerprint = |
| 902 microdump_gpu_fingerprint_; | 912 microdump_gpu_fingerprint_; |
| 903 } | 913 } |
| 904 | 914 |
| 905 g_microdump = | 915 g_microdump = |
| 906 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone, | 916 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone, |
| 907 reinterpret_cast<void*>(is_browser_process), | 917 reinterpret_cast<void*>(is_browser_process), |
| 908 true, // Install handlers. | 918 true, // Install handlers. |
| 909 -1); // Server file descriptor. -1 for in-process. | 919 -1); // Server file descriptor. -1 for in-process. |
| 910 | 920 |
| 911 if (process_type == kWebViewProcessType) { | 921 if (process_type == kWebViewSingleProcessType || |
| 922 process_type == kWebViewBrowserProcessType) { | |
| 923 // TODO(tobiasjs): figure out what to do with on demand minidump on the | |
| 924 // renderer process of webview. | |
| 912 // We do not use |DumpProcess()| for handling programatically | 925 // We do not use |DumpProcess()| for handling programatically |
| 913 // generated dumps for WebView because we only know the file | 926 // generated dumps for WebView because we only know the file |
| 914 // descriptor to which we are dumping at the time of the call to | 927 // descriptor to which we are dumping at the time of the call to |
| 915 // |DumpWithoutCrashing()|. Therefore we need to construct the | 928 // |DumpWithoutCrashing()|. Therefore we need to construct the |
| 916 // |MinidumpDescriptor| and |ExceptionHandler| instances as | 929 // |MinidumpDescriptor| and |ExceptionHandler| instances as |
| 917 // needed, instead of setting up |g_breakpad| at initialization | 930 // needed, instead of setting up |g_breakpad| at initialization |
| 918 // time. | 931 // time. |
| 919 base::debug::SetDumpWithoutCrashingFunction( | 932 base::debug::SetDumpWithoutCrashingFunction( |
| 920 &GenerateMinidumpOnDemandForAndroid); | 933 &GenerateMinidumpOnDemandForAndroid); |
| 921 } else if (!process_type.empty()) { | 934 } else if (!process_type.empty()) { |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1922 const std::string& gpu_fingerprint) { | 1935 const std::string& gpu_fingerprint) { |
| 1923 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); | 1936 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); |
| 1924 } | 1937 } |
| 1925 #endif // OS_ANDROID | 1938 #endif // OS_ANDROID |
| 1926 | 1939 |
| 1927 bool IsCrashReporterEnabled() { | 1940 bool IsCrashReporterEnabled() { |
| 1928 return g_is_crash_reporter_enabled; | 1941 return g_is_crash_reporter_enabled; |
| 1929 } | 1942 } |
| 1930 | 1943 |
| 1931 } // namespace breakpad | 1944 } // namespace breakpad |
| OLD | NEW |