| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/common/crash_keys.h" | 5 #include "chrome/common/crash_keys.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "components/crash/core/common/crash_keys.h" |
| 17 #include "components/flags_ui/flags_ui_switches.h" | 18 #include "components/flags_ui/flags_ui_switches.h" |
| 18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/common/crash_keys.h" |
| 19 #include "ipc/ipc_switches.h" | 21 #include "ipc/ipc_switches.h" |
| 22 #include "media/base/crash_keys.h" |
| 20 | 23 |
| 21 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 22 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 23 #include "gpu/command_buffer/service/gpu_switches.h" | 26 #include "gpu/command_buffer/service/gpu_switches.h" |
| 24 #include "ui/gl/gl_switches.h" | 27 #include "ui/gl/gl_switches.h" |
| 25 #endif | 28 #endif |
| 26 | 29 |
| 27 namespace crash_keys { | 30 namespace crash_keys { |
| 28 | 31 |
| 29 const char kActiveURL[] = "url-chunk"; | 32 const char kActiveURL[] = "url-chunk"; |
| 30 | 33 |
| 31 const char kFontKeyName[] = "font_key_name"; | |
| 32 | |
| 33 const char kExtensionID[] = "extension-%" PRIuS; | 34 const char kExtensionID[] = "extension-%" PRIuS; |
| 34 const char kNumExtensionsCount[] = "num-extensions"; | 35 const char kNumExtensionsCount[] = "num-extensions"; |
| 35 | 36 |
| 36 const char kShutdownType[] = "shutdown-type"; | 37 const char kShutdownType[] = "shutdown-type"; |
| 37 | 38 |
| 38 #if !defined(OS_ANDROID) | 39 #if !defined(OS_ANDROID) |
| 39 const char kGPUVendorID[] = "gpu-venid"; | 40 const char kGPUVendorID[] = "gpu-venid"; |
| 40 const char kGPUDeviceID[] = "gpu-devid"; | 41 const char kGPUDeviceID[] = "gpu-devid"; |
| 41 #endif | 42 #endif |
| 42 const char kGPUDriverVersion[] = "gpu-driver"; | 43 const char kGPUDriverVersion[] = "gpu-driver"; |
| 43 const char kGPUPixelShaderVersion[] = "gpu-psver"; | 44 const char kGPUPixelShaderVersion[] = "gpu-psver"; |
| 44 const char kGPUVertexShaderVersion[] = "gpu-vsver"; | 45 const char kGPUVertexShaderVersion[] = "gpu-vsver"; |
| 45 #if defined(OS_MACOSX) | 46 #if defined(OS_MACOSX) |
| 46 const char kGPUGLVersion[] = "gpu-glver"; | 47 const char kGPUGLVersion[] = "gpu-glver"; |
| 47 #elif defined(OS_POSIX) | 48 #elif defined(OS_POSIX) |
| 48 const char kGPUVendor[] = "gpu-gl-vendor"; | 49 const char kGPUVendor[] = "gpu-gl-vendor"; |
| 49 const char kGPURenderer[] = "gpu-gl-renderer"; | 50 const char kGPURenderer[] = "gpu-gl-renderer"; |
| 50 #endif | 51 #endif |
| 51 | 52 |
| 52 #if defined(OS_WIN) | |
| 53 const char kHungAudioThreadDetails[] = "hung-audio-thread-details"; | |
| 54 #endif | |
| 55 | |
| 56 const char kPrinterInfo[] = "prn-info-%" PRIuS; | 53 const char kPrinterInfo[] = "prn-info-%" PRIuS; |
| 57 | 54 |
| 58 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 59 const char kNumberOfUsers[] = "num-users"; | 56 const char kNumberOfUsers[] = "num-users"; |
| 60 #endif | 57 #endif |
| 61 | 58 |
| 62 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
| 63 namespace mac { | 60 namespace mac { |
| 64 | 61 |
| 65 const char kFirstNSException[] = "firstexception"; | 62 const char kFirstNSException[] = "firstexception"; |
| 66 const char kFirstNSExceptionTrace[] = "firstexception_bt"; | 63 const char kFirstNSExceptionTrace[] = "firstexception_bt"; |
| 67 | 64 |
| 68 const char kLastNSException[] = "lastexception"; | 65 const char kLastNSException[] = "lastexception"; |
| 69 const char kLastNSExceptionTrace[] = "lastexception_bt"; | 66 const char kLastNSExceptionTrace[] = "lastexception_bt"; |
| 70 | 67 |
| 71 const char kNSException[] = "nsexception"; | 68 const char kNSException[] = "nsexception"; |
| 72 const char kNSExceptionTrace[] = "nsexception_bt"; | 69 const char kNSExceptionTrace[] = "nsexception_bt"; |
| 73 | 70 |
| 74 const char kSendAction[] = "sendaction"; | 71 const char kSendAction[] = "sendaction"; |
| 75 | 72 |
| 76 } // namespace mac | 73 } // namespace mac |
| 77 #endif | 74 #endif |
| 78 | 75 |
| 79 #if BUILDFLAG(ENABLE_KASKO) | |
| 80 const char kKaskoGuid[] = "kasko-guid"; | |
| 81 const char kKaskoEquivalentGuid[] = "kasko-equivalent-guid"; | |
| 82 #endif | |
| 83 | |
| 84 const char kViewCount[] = "view-count"; | 76 const char kViewCount[] = "view-count"; |
| 85 | 77 |
| 86 const char kZeroEncodeDetails[] = "zero-encode-details"; | 78 namespace { |
| 87 | 79 |
| 88 size_t RegisterChromeCrashKeys() { | 80 // Appends crash keys used under //chrome to |keys|. |
| 89 // The following keys may be chunked by the underlying crash logging system, | 81 void AppendChromeCrashKeys(std::vector<base::debug::CrashKey>* keys) { |
| 90 // but ultimately constitute a single key-value pair. | 82 DCHECK(keys); |
| 91 // | 83 |
| 92 // If you're adding keys here, please also add them to the list in | 84 const std::vector<base::debug::CrashKey> chrome_keys = { |
| 93 // //blimp/engine/app/blimp_engine_crash_keys.cc | 85 { kActiveURL, kSmallSize }, |
| 94 base::debug::CrashKey fixed_keys[] = { | |
| 95 #if defined(OS_MACOSX) || defined(OS_WIN) | |
| 96 { kMetricsClientId, kSmallSize }, | |
| 97 #else | |
| 98 { kClientId, kSmallSize }, | |
| 99 #endif | |
| 100 { kChannel, kSmallSize }, | |
| 101 { kActiveURL, kLargeSize }, | |
| 102 { kNumVariations, kSmallSize }, | |
| 103 { kVariations, kLargeSize }, | |
| 104 { kNumExtensionsCount, kSmallSize }, | 86 { kNumExtensionsCount, kSmallSize }, |
| 105 { kShutdownType, kSmallSize }, | 87 { kShutdownType, kSmallSize }, |
| 106 #if !defined(OS_ANDROID) | 88 #if !defined(OS_ANDROID) |
| 107 { kGPUVendorID, kSmallSize }, | 89 { kGPUVendorID, kSmallSize }, |
| 108 { kGPUDeviceID, kSmallSize }, | 90 { kGPUDeviceID, kSmallSize }, |
| 109 #endif | 91 #endif |
| 110 { kGPUDriverVersion, kSmallSize }, | 92 { kGPUDriverVersion, kSmallSize }, |
| 111 { kGPUPixelShaderVersion, kSmallSize }, | 93 { kGPUPixelShaderVersion, kSmallSize }, |
| 112 { kGPUVertexShaderVersion, kSmallSize }, | 94 { kGPUVertexShaderVersion, kSmallSize }, |
| 113 #if defined(OS_MACOSX) | 95 #if defined(OS_MACOSX) |
| 114 { kGPUGLVersion, kSmallSize }, | 96 { kGPUGLVersion, kSmallSize }, |
| 115 #elif defined(OS_POSIX) | 97 #elif defined(OS_POSIX) |
| 116 { kGPUVendor, kSmallSize }, | 98 { kGPUVendor, kSmallSize }, |
| 117 { kGPURenderer, kSmallSize }, | 99 { kGPURenderer, kSmallSize }, |
| 118 #endif | 100 #endif |
| 119 | |
| 120 // content/: | |
| 121 { "bad_message_reason", kSmallSize }, | |
| 122 { "discardable-memory-allocated", kSmallSize }, | |
| 123 { "discardable-memory-free", kSmallSize }, | |
| 124 { kFontKeyName, kSmallSize}, | |
| 125 { "ppapi_path", kMediumSize }, | |
| 126 { "subresource_url", kLargeSize }, | |
| 127 { "total-discardable-memory-allocated", kSmallSize }, | |
| 128 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) |
| 129 { kNumberOfUsers, kSmallSize }, | 102 { kNumberOfUsers, kSmallSize }, |
| 130 #endif | 103 #endif |
| 131 #if defined(OS_MACOSX) | 104 #if defined(OS_MACOSX) |
| 132 { mac::kFirstNSException, kMediumSize }, | 105 { mac::kFirstNSException, kMediumSize }, |
| 133 { mac::kFirstNSExceptionTrace, kMediumSize }, | 106 { mac::kFirstNSExceptionTrace, kMediumSize }, |
| 134 { mac::kLastNSException, kMediumSize }, | 107 { mac::kLastNSException, kMediumSize }, |
| 135 { mac::kLastNSExceptionTrace, kMediumSize }, | 108 { mac::kLastNSExceptionTrace, kMediumSize }, |
| 136 { mac::kNSException, kMediumSize }, | 109 { mac::kNSException, kMediumSize }, |
| 137 { mac::kNSExceptionTrace, kMediumSize }, | 110 { mac::kNSExceptionTrace, kMediumSize }, |
| 138 { mac::kSendAction, kMediumSize }, | 111 { mac::kSendAction, kMediumSize }, |
| 139 { mac::kZombie, kMediumSize }, | |
| 140 { mac::kZombieTrace, kMediumSize }, | |
| 141 // content/: | |
| 142 { "channel_error_bt", kMediumSize }, | |
| 143 { "remove_route_bt", kMediumSize }, | |
| 144 { "rwhvm_window", kMediumSize }, | |
| 145 // media/: | |
| 146 #endif | 112 #endif |
| 147 #if BUILDFLAG(ENABLE_KASKO) | |
| 148 { kKaskoGuid, kSmallSize }, | |
| 149 { kKaskoEquivalentGuid, kSmallSize }, | |
| 150 #endif | |
| 151 { kBug464926CrashKey, kSmallSize }, | |
| 152 { kViewCount, kSmallSize }, | 113 { kViewCount, kSmallSize }, |
| 153 | 114 |
| 154 // media/: | |
| 155 #if defined(OS_WIN) | |
| 156 { kHungAudioThreadDetails, kSmallSize }, | |
| 157 #endif | |
| 158 { kZeroEncodeDetails, kSmallSize }, | |
| 159 | |
| 160 // gin/: | 115 // gin/: |
| 116 // TODO(marcinjb): Figure out where this goes. |
| 161 { "v8-ignition", kSmallSize }, | 117 { "v8-ignition", kSmallSize }, |
| 162 | 118 |
| 163 // Temporary for http://crbug.com/575245. | |
| 164 { "swapout_frame_id", kSmallSize }, | |
| 165 { "swapout_proxy_id", kSmallSize }, | |
| 166 { "swapout_view_id", kSmallSize }, | |
| 167 { "commit_frame_id", kSmallSize }, | |
| 168 { "commit_proxy_id", kSmallSize }, | |
| 169 { "commit_view_id", kSmallSize }, | |
| 170 { "commit_main_render_frame_id", kSmallSize }, | |
| 171 { "newproxy_proxy_id", kSmallSize }, | |
| 172 { "newproxy_view_id", kSmallSize }, | |
| 173 { "newproxy_opener_id", kSmallSize }, | |
| 174 { "newproxy_parent_id", kSmallSize }, | |
| 175 { "rvinit_view_id", kSmallSize }, | |
| 176 { "rvinit_proxy_id", kSmallSize }, | |
| 177 { "rvinit_main_frame_id", kSmallSize }, | |
| 178 { "initrf_frame_id", kSmallSize }, | |
| 179 { "initrf_proxy_id", kSmallSize }, | |
| 180 { "initrf_view_id", kSmallSize }, | |
| 181 { "initrf_main_frame_id", kSmallSize }, | |
| 182 { "initrf_view_is_live", kSmallSize }, | |
| 183 | |
| 184 // Temporary for https://crbug.com/591478. | |
| 185 { "initrf_parent_proxy_exists", kSmallSize }, | |
| 186 { "initrf_render_view_is_live", kSmallSize }, | |
| 187 { "initrf_parent_is_in_same_site_instance", kSmallSize}, | |
| 188 { "initrf_parent_process_is_live", kSmallSize}, | |
| 189 { "initrf_root_is_in_same_site_instance", kSmallSize}, | |
| 190 { "initrf_root_is_in_same_site_instance_as_parent", kSmallSize}, | |
| 191 { "initrf_root_process_is_live", kSmallSize}, | |
| 192 { "initrf_root_proxy_is_live", kSmallSize}, | |
| 193 | |
| 194 // Temporary for https://crbug.com/612711. | 119 // Temporary for https://crbug.com/612711. |
| 195 { "aci_wrong_sp_extension_id", kSmallSize }, | 120 { "aci_wrong_sp_extension_id", kSmallSize }, |
| 196 | 121 |
| 197 // Temporary for http://crbug.com/621730 | 122 // Temporary for http://crbug.com/621730 |
| 198 { "postmessage_src_origin", kMediumSize }, | 123 { "postmessage_src_origin", kMediumSize }, |
| 199 { "postmessage_dst_origin", kMediumSize }, | 124 { "postmessage_dst_origin", kMediumSize }, |
| 200 { "postmessage_dst_url", kLargeSize }, | 125 { "postmessage_dst_url", kLargeSize }, |
| 201 { "postmessage_script_info", kLargeSize }, | 126 { "postmessage_script_info", kLargeSize }, |
| 202 | 127 |
| 203 // Temporary for https://crbug.com/616149. | 128 // Temporary for https://crbug.com/616149. |
| 204 { "existing_extension_pref_value_type", crash_keys::kSmallSize }, | 129 { "existing_extension_pref_value_type", crash_keys::kSmallSize }, |
| 205 | 130 |
| 206 // Temporary for https://crbug.com/625040 | 131 // Temporary for https://crbug.com/625040 |
| 207 { "swdh_not_handled_message_type", crash_keys::kMediumSize }, | 132 { "swdh_not_handled_message_type", crash_keys::kMediumSize }, |
| 208 { "swdh_not_handled_worker_status", crash_keys::kMediumSize }, | 133 { "swdh_not_handled_worker_status", crash_keys::kMediumSize }, |
| 209 }; | 134 }; |
| 210 | 135 |
| 211 // This dynamic set of keys is used for sets of key value pairs when gathering | 136 keys->insert(keys->end(), chrome_keys.begin(), chrome_keys.end()); |
| 212 // a collection of data, like command line switches or extension IDs. | 137 } |
| 213 std::vector<base::debug::CrashKey> keys( | |
| 214 fixed_keys, fixed_keys + arraysize(fixed_keys)); | |
| 215 | 138 |
| 139 } // namespace |
| 140 |
| 141 size_t RegisterChromeCrashKeys() { |
| 142 // Get the base set of crash keys used throughout the different components. |
| 143 // If you are adding a crash key, add it to the appropriate "Append" function |
| 144 // so that it is owned in the right directory hierarchy. |
| 145 std::vector<base::debug::CrashKey> keys; |
| 146 AppendChromeCrashKeys(&keys); // //chrome keys |
| 147 AppendCrashCrashKeys(&keys); // //components/crash keys |
| 148 AppendContentCrashKeys(&keys); // //content keys |
| 149 AppendMediaCrashKeys(&keys); // //media keys |
| 150 |
| 151 // Register command line switches. |
| 216 crash_keys::GetCrashKeysForCommandLineSwitches(&keys); | 152 crash_keys::GetCrashKeysForCommandLineSwitches(&keys); |
| 217 | 153 |
| 218 // Register the extension IDs. | 154 // Register the extension IDs. |
| 219 { | 155 { |
| 220 static char formatted_keys[kExtensionIDMaxCount][sizeof(kExtensionID) + 1] = | 156 static char formatted_keys[kExtensionIDMaxCount][sizeof(kExtensionID) + 1] = |
| 221 {{ 0 }}; | 157 {{ 0 }}; |
| 222 const size_t formatted_key_len = sizeof(formatted_keys[0]); | 158 const size_t formatted_key_len = sizeof(formatted_keys[0]); |
| 223 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { | 159 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
| 224 int n = base::snprintf( | 160 int n = base::snprintf( |
| 225 formatted_keys[i], formatted_key_len, kExtensionID, i + 1); | 161 formatted_keys[i], formatted_key_len, kExtensionID, i + 1); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 279 } |
| 344 | 280 |
| 345 ScopedPrinterInfo::~ScopedPrinterInfo() { | 281 ScopedPrinterInfo::~ScopedPrinterInfo() { |
| 346 for (size_t i = 0; i < kPrinterInfoCount; ++i) { | 282 for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
| 347 std::string key = base::StringPrintf(kPrinterInfo, i + 1); | 283 std::string key = base::StringPrintf(kPrinterInfo, i + 1); |
| 348 base::debug::ClearCrashKey(key); | 284 base::debug::ClearCrashKey(key); |
| 349 } | 285 } |
| 350 } | 286 } |
| 351 | 287 |
| 352 } // namespace crash_keys | 288 } // namespace crash_keys |
| OLD | NEW |