| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 #if defined(OS_ANDROID) | 103 #if defined(OS_ANDROID) |
| 104 char* g_process_type = nullptr; | 104 char* g_process_type = nullptr; |
| 105 ExceptionHandler* g_microdump = nullptr; | 105 ExceptionHandler* g_microdump = nullptr; |
| 106 int g_signal_code_pipe_fd = -1; | 106 int g_signal_code_pipe_fd = -1; |
| 107 | 107 |
| 108 class MicrodumpInfo { | 108 class MicrodumpInfo { |
| 109 public: | 109 public: |
| 110 MicrodumpInfo() | 110 MicrodumpInfo() |
| 111 : microdump_build_fingerprint_(nullptr), | 111 : microdump_build_fingerprint_(nullptr), |
| 112 microdump_product_info_(nullptr), | 112 microdump_product_info_(nullptr), |
| 113 microdump_gpu_fingerprint_(nullptr), | 113 microdump_gpu_fingerprint_(nullptr) {} |
| 114 microdump_process_type_(nullptr), | |
| 115 interest_range_start_(0ul), | |
| 116 interest_range_end_(0ul), | |
| 117 suppress_microdump_based_on_interest_range_(false) {} | |
| 118 | 114 |
| 119 // The order in which SetGpuFingerprint and Initialize are called | 115 // The order in which SetGpuFingerprint and Initialize are called |
| 120 // may be dependent on the timing of the availability of GPU | 116 // may be dependent on the timing of the availability of GPU |
| 121 // information. For this reason, they can be called in either order, | 117 // information. For this reason, they can be called in either order, |
| 122 // resulting in the same effect. | 118 // resulting in the same effect. |
| 123 // | 119 // |
| 124 // The following restrictions apply, however: | 120 // The following restrictions apply, however: |
| 125 // * Both methods must be called from the same thread. | 121 // * Both methods must be called from the same thread. |
| 126 // * Both methods must be called at most once. | 122 // * Both methods must be called at most once. |
| 127 // | 123 // |
| 128 // Microdumps will only be generated if Initialize is called. If | 124 // Microdumps will only be generated if Initialize is called. If |
| 129 // SetGpuFingerprint has not been called called at the point at | 125 // SetGpuFingerprint has not been called called at the point at |
| 130 // which a microdump is generated, then the GPU fingerprint will be | 126 // which a microdump is generated, then the GPU fingerprint will be |
| 131 // UNKNOWN. | 127 // UNKNOWN. |
| 132 void SetGpuFingerprint(const std::string& gpu_fingerprint); | 128 void SetGpuFingerprint(const std::string& gpu_fingerprint); |
| 133 void SetMicrodumpInterestRange(uintptr_t start, uintptr_t end); | |
| 134 void Initialize(const std::string& process_type, | 129 void Initialize(const std::string& process_type, |
| 135 const char* product_name, | 130 const char* product_name, |
| 136 const char* product_version, | 131 const char* product_version, |
| 137 const char* android_build_fp); | 132 const char* android_build_fp); |
| 138 | 133 |
| 139 private: | 134 private: |
| 140 base::ThreadChecker thread_checker_; | 135 base::ThreadChecker thread_checker_; |
| 141 const char* microdump_build_fingerprint_; | 136 const char* microdump_build_fingerprint_; |
| 142 const char* microdump_product_info_; | 137 const char* microdump_product_info_; |
| 143 const char* microdump_gpu_fingerprint_; | 138 const char* microdump_gpu_fingerprint_; |
| 144 const char* microdump_process_type_; | 139 const char* microdump_process_type_; |
| 145 uintptr_t interest_range_start_; | |
| 146 uintptr_t interest_range_end_; | |
| 147 bool suppress_microdump_based_on_interest_range_; | |
| 148 }; | 140 }; |
| 149 | 141 |
| 150 base::LazyInstance<MicrodumpInfo> g_microdump_info = | 142 base::LazyInstance<MicrodumpInfo> g_microdump_info = |
| 151 LAZY_INSTANCE_INITIALIZER; | 143 LAZY_INSTANCE_INITIALIZER; |
| 152 | 144 |
| 153 #endif | 145 #endif |
| 154 | 146 |
| 155 CrashKeyStorage* g_crash_keys = nullptr; | 147 CrashKeyStorage* g_crash_keys = nullptr; |
| 156 | 148 |
| 157 // Writes the value |v| as 16 hex characters to the memory pointed at by | 149 // Writes the value |v| as 16 hex characters to the memory pointed at by |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 ANNOTATE_LEAKING_OBJECT_PTR(microdump_gpu_fingerprint_); | 865 ANNOTATE_LEAKING_OBJECT_PTR(microdump_gpu_fingerprint_); |
| 874 | 866 |
| 875 if (g_microdump) { | 867 if (g_microdump) { |
| 876 MinidumpDescriptor minidump_descriptor(g_microdump->minidump_descriptor()); | 868 MinidumpDescriptor minidump_descriptor(g_microdump->minidump_descriptor()); |
| 877 minidump_descriptor.microdump_extra_info()->gpu_fingerprint = | 869 minidump_descriptor.microdump_extra_info()->gpu_fingerprint = |
| 878 microdump_gpu_fingerprint_; | 870 microdump_gpu_fingerprint_; |
| 879 g_microdump->set_minidump_descriptor(minidump_descriptor); | 871 g_microdump->set_minidump_descriptor(minidump_descriptor); |
| 880 } | 872 } |
| 881 } | 873 } |
| 882 | 874 |
| 883 void MicrodumpInfo::SetMicrodumpInterestRange(uintptr_t start, uintptr_t end) { | |
| 884 interest_range_start_ = start; | |
| 885 interest_range_end_ = end; | |
| 886 suppress_microdump_based_on_interest_range_ = true; | |
| 887 | |
| 888 if (g_microdump) { | |
| 889 MinidumpDescriptor descriptor(g_microdump->minidump_descriptor()); | |
| 890 google_breakpad::MicrodumpExtraInfo* microdump_extra_info = | |
| 891 descriptor.microdump_extra_info(); | |
| 892 microdump_extra_info->interest_range_start = interest_range_start_; | |
| 893 microdump_extra_info->interest_range_end = interest_range_end_; | |
| 894 microdump_extra_info->suppress_microdump_based_on_interest_range = true; | |
| 895 g_microdump->set_minidump_descriptor(descriptor); | |
| 896 } | |
| 897 } | |
| 898 | |
| 899 void MicrodumpInfo::Initialize(const std::string& process_type, | 875 void MicrodumpInfo::Initialize(const std::string& process_type, |
| 900 const char* product_name, | 876 const char* product_name, |
| 901 const char* product_version, | 877 const char* product_version, |
| 902 const char* android_build_fp) { | 878 const char* android_build_fp) { |
| 903 DCHECK(thread_checker_.CalledOnValidThread()); | 879 DCHECK(thread_checker_.CalledOnValidThread()); |
| 904 DCHECK(!g_microdump); | 880 DCHECK(!g_microdump); |
| 905 // |process_type| for webview's browser process is kBrowserProcessType or | 881 // |process_type| for webview's browser process is kBrowserProcessType or |
| 906 // kWebViewSingleProcessType. |process_type| for chrome's browser process is | 882 // kWebViewSingleProcessType. |process_type| for chrome's browser process is |
| 907 // an empty string. | 883 // an empty string. |
| 908 bool is_browser_process = process_type.empty() || | 884 bool is_browser_process = process_type.empty() || |
| 909 process_type == kWebViewSingleProcessType || | 885 process_type == kWebViewSingleProcessType || |
| 910 process_type == kBrowserProcessType; | 886 process_type == kBrowserProcessType; |
| 911 | 887 |
| 912 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole); | 888 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole); |
| 913 google_breakpad::MicrodumpExtraInfo* microdump_extra_info = | |
| 914 descriptor.microdump_extra_info(); | |
| 915 | 889 |
| 916 if (product_name && product_version) { | 890 if (product_name && product_version) { |
| 917 microdump_product_info_ = | 891 microdump_product_info_ = |
| 918 strdup((product_name + std::string(":") + product_version).c_str()); | 892 strdup((product_name + std::string(":") + product_version).c_str()); |
| 919 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_); | 893 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_); |
| 920 microdump_extra_info->product_info = microdump_product_info_; | 894 descriptor.microdump_extra_info()->product_info = microdump_product_info_; |
| 921 } | 895 } |
| 922 | 896 |
| 923 microdump_process_type_ = | 897 microdump_process_type_ = |
| 924 strdup(process_type.empty() ? kBrowserProcessType : process_type.c_str()); | 898 strdup(process_type.empty() ? kBrowserProcessType : process_type.c_str()); |
| 925 ANNOTATE_LEAKING_OBJECT_PTR(microdump_process_type_); | 899 ANNOTATE_LEAKING_OBJECT_PTR(microdump_process_type_); |
| 926 microdump_extra_info->process_type = microdump_process_type_; | 900 descriptor.microdump_extra_info()->process_type = microdump_process_type_; |
| 927 | 901 |
| 928 if (android_build_fp) { | 902 if (android_build_fp) { |
| 929 microdump_build_fingerprint_ = strdup(android_build_fp); | 903 microdump_build_fingerprint_ = strdup(android_build_fp); |
| 930 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_); | 904 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_); |
| 931 microdump_extra_info->build_fingerprint = microdump_build_fingerprint_; | 905 descriptor.microdump_extra_info()->build_fingerprint = |
| 906 microdump_build_fingerprint_; |
| 932 } | 907 } |
| 933 | 908 |
| 934 if (microdump_gpu_fingerprint_) { | 909 if (microdump_gpu_fingerprint_) { |
| 935 microdump_extra_info->gpu_fingerprint = microdump_gpu_fingerprint_; | 910 descriptor.microdump_extra_info()->gpu_fingerprint = |
| 911 microdump_gpu_fingerprint_; |
| 936 } | 912 } |
| 937 | 913 |
| 938 microdump_extra_info->interest_range_start = interest_range_start_; | |
| 939 microdump_extra_info->interest_range_end = interest_range_end_; | |
| 940 microdump_extra_info->suppress_microdump_based_on_interest_range = | |
| 941 suppress_microdump_based_on_interest_range_; | |
| 942 | |
| 943 g_microdump = | 914 g_microdump = |
| 944 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone, | 915 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone, |
| 945 reinterpret_cast<void*>(is_browser_process), | 916 reinterpret_cast<void*>(is_browser_process), |
| 946 true, // Install handlers. | 917 true, // Install handlers. |
| 947 -1); // Server file descriptor. -1 for in-process. | 918 -1); // Server file descriptor. -1 for in-process. |
| 948 | 919 |
| 949 if (process_type == kWebViewSingleProcessType || | 920 if (process_type == kWebViewSingleProcessType || |
| 950 process_type == kBrowserProcessType) { | 921 process_type == kBrowserProcessType) { |
| 951 // TODO(tobiasjs): figure out what to do with on demand minidump on the | 922 // TODO(tobiasjs): figure out what to do with on demand minidump on the |
| 952 // renderer process of webview. | 923 // renderer process of webview. |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 base::android::BuildInfo::GetInstance()->android_build_fp(); | 1927 base::android::BuildInfo::GetInstance()->android_build_fp(); |
| 1957 | 1928 |
| 1958 g_microdump_info.Get().Initialize(process_type, product_name, product_version, | 1929 g_microdump_info.Get().Initialize(process_type, product_name, product_version, |
| 1959 android_build_fp); | 1930 android_build_fp); |
| 1960 } | 1931 } |
| 1961 | 1932 |
| 1962 void AddGpuFingerprintToMicrodumpCrashHandler( | 1933 void AddGpuFingerprintToMicrodumpCrashHandler( |
| 1963 const std::string& gpu_fingerprint) { | 1934 const std::string& gpu_fingerprint) { |
| 1964 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); | 1935 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); |
| 1965 } | 1936 } |
| 1966 | |
| 1967 void SetNativeCodeTextAddrRange(uintptr_t start, uintptr_t end) { | |
| 1968 g_microdump_info.Get().SetMicrodumpInterestRange(start, end); | |
| 1969 } | |
| 1970 #endif // OS_ANDROID | 1937 #endif // OS_ANDROID |
| 1971 | 1938 |
| 1972 bool IsCrashReporterEnabled() { | 1939 bool IsCrashReporterEnabled() { |
| 1973 return g_is_crash_reporter_enabled; | 1940 return g_is_crash_reporter_enabled; |
| 1974 } | 1941 } |
| 1975 | 1942 |
| 1976 } // namespace breakpad | 1943 } // namespace breakpad |
| OLD | NEW |