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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1091 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. | 1091 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. |
1092 nullptr, | 1092 nullptr, |
1093 nullptr, | 1093 nullptr, |
1094 nullptr, | 1094 nullptr, |
1095 true, | 1095 true, |
1096 -1); | 1096 -1); |
1097 g_breakpad->set_crash_generation_client(new NonBrowserCrashHandler()); | 1097 g_breakpad->set_crash_generation_client(new NonBrowserCrashHandler()); |
1098 } | 1098 } |
1099 #endif // defined(OS_ANDROID) | 1099 #endif // defined(OS_ANDROID) |
1100 | 1100 |
1101 bool g_use_crash_keys_whitelist; | |
Tobias Sargeant
2017/03/02 16:36:48
initialize these, and move them to the top of the
gsennton
2017/03/02 17:35:37
Done.
| |
1102 const char** g_crash_keys_whitelist; | |
1103 | |
1104 bool IsInWhiteList(const base::StringPiece& key) { | |
1105 DCHECK(g_crash_keys_whitelist); | |
1106 for (size_t i = 0; g_crash_keys_whitelist[i] != NULL; ++i) { | |
1107 if (0 == my_strcmp(g_crash_keys_whitelist[i], key.data())) { | |
1108 return true; | |
1109 } | |
1110 } | |
1111 return false; | |
1112 } | |
1113 | |
1101 void SetCrashKeyValue(const base::StringPiece& key, | 1114 void SetCrashKeyValue(const base::StringPiece& key, |
1102 const base::StringPiece& value) { | 1115 const base::StringPiece& value) { |
1103 g_crash_keys->SetKeyValue(key.data(), value.data()); | 1116 if (!g_use_crash_keys_whitelist || IsInWhiteList(key)) { |
1117 g_crash_keys->SetKeyValue(key.data(), value.data()); | |
1118 } | |
1104 } | 1119 } |
1105 | 1120 |
1106 void ClearCrashKey(const base::StringPiece& key) { | 1121 void ClearCrashKey(const base::StringPiece& key) { |
1107 g_crash_keys->RemoveKey(key.data()); | 1122 g_crash_keys->RemoveKey(key.data()); |
1108 } | 1123 } |
1109 | 1124 |
1110 // GetCrashReporterClient() cannot call any Set methods until after | 1125 // GetCrashReporterClient() cannot call any Set methods until after |
1111 // InitCrashKeys(). | 1126 // InitCrashKeys(). |
1112 void InitCrashKeys() { | 1127 void InitCrashKeys() { |
1113 g_crash_keys = new CrashKeyStorage; | 1128 g_crash_keys = new CrashKeyStorage; |
1114 GetCrashReporterClient()->RegisterCrashKeys(); | 1129 GetCrashReporterClient()->RegisterCrashKeys(); |
1130 g_use_crash_keys_whitelist = | |
1131 GetCrashReporterClient()->UseCrashKeysWhiteList(); | |
1132 g_crash_keys_whitelist = GetCrashReporterClient()->GetWhiteListedCrashKeys(); | |
1115 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey); | 1133 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey); |
1116 } | 1134 } |
1117 | 1135 |
1118 // Miscellaneous initialization functions to call after Breakpad has been | 1136 // Miscellaneous initialization functions to call after Breakpad has been |
1119 // enabled. | 1137 // enabled. |
1120 void PostEnableBreakpadInitialization() { | 1138 void PostEnableBreakpadInitialization() { |
1121 SetProcessStartTime(); | 1139 SetProcessStartTime(); |
1122 g_pid = getpid(); | 1140 g_pid = getpid(); |
1123 | 1141 |
1124 base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); | 1142 base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1898 | 1916 |
1899 #if defined(OS_ANDROID) | 1917 #if defined(OS_ANDROID) |
1900 // In Android WebView, microdumps are generated conditionally (depending on the | 1918 // In Android WebView, microdumps are generated conditionally (depending on the |
1901 // cause of the crash) and can be sanitized to prevent exposing unnecessary data | 1919 // cause of the crash) and can be sanitized to prevent exposing unnecessary data |
1902 // from the embedding application. | 1920 // from the embedding application. |
1903 void InitCrashReporter(const std::string& process_type) { | 1921 void InitCrashReporter(const std::string& process_type) { |
1904 SanitizationInfo sanitization_info; | 1922 SanitizationInfo sanitization_info; |
1905 InitCrashReporter(process_type, sanitization_info); | 1923 InitCrashReporter(process_type, sanitization_info); |
1906 } | 1924 } |
1907 | 1925 |
1926 void InitCrashKeysForTesting() { | |
1927 InitCrashKeys(); | |
1928 } | |
1929 | |
1908 void InitCrashReporter(const std::string& process_type, | 1930 void InitCrashReporter(const std::string& process_type, |
1909 const SanitizationInfo& sanitization_info) { | 1931 const SanitizationInfo& sanitization_info) { |
1910 #else | 1932 #else |
1911 void InitCrashReporter(const std::string& process_type) { | 1933 void InitCrashReporter(const std::string& process_type) { |
1912 #endif // defined(OS_ANDROID) | 1934 #endif // defined(OS_ANDROID) |
1913 // The maximum lengths specified by breakpad include the trailing NULL, so the | 1935 // The maximum lengths specified by breakpad include the trailing NULL, so the |
1914 // actual length of the chunk is one less. | 1936 // actual length of the chunk is one less. |
1915 static_assert(crash_keys::kChunkMaxLength == 63, "kChunkMaxLength mismatch"); | 1937 static_assert(crash_keys::kChunkMaxLength == 63, "kChunkMaxLength mismatch"); |
1916 static_assert(crash_keys::kSmallSize <= crash_keys::kChunkMaxLength, | 1938 static_assert(crash_keys::kSmallSize <= crash_keys::kChunkMaxLength, |
1917 "crash key chunk size too small"); | 1939 "crash key chunk size too small"); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2059 void SuppressDumpGeneration() { | 2081 void SuppressDumpGeneration() { |
2060 g_dumps_suppressed = G_DUMPS_SUPPRESSED_MAGIC; | 2082 g_dumps_suppressed = G_DUMPS_SUPPRESSED_MAGIC; |
2061 } | 2083 } |
2062 #endif // OS_ANDROID | 2084 #endif // OS_ANDROID |
2063 | 2085 |
2064 bool IsCrashReporterEnabled() { | 2086 bool IsCrashReporterEnabled() { |
2065 return g_is_crash_reporter_enabled; | 2087 return g_is_crash_reporter_enabled; |
2066 } | 2088 } |
2067 | 2089 |
2068 } // namespace breakpad | 2090 } // namespace breakpad |
OLD | NEW |