| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/crash/core/common/crash_keys.h" | 5 #include "components/crash/core/common/crash_keys.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 for (size_t i = 0; i < kSwitchesMaxCount; ++i) { | 127 for (size_t i = 0; i < kSwitchesMaxCount; ++i) { |
| 128 // Name the keys using 1-based indexing. | 128 // Name the keys using 1-based indexing. |
| 129 int n = base::snprintf(formatted_keys[i], formatted_key_len, kSwitchFormat, | 129 int n = base::snprintf(formatted_keys[i], formatted_key_len, kSwitchFormat, |
| 130 i + 1); | 130 i + 1); |
| 131 DCHECK_GT(n, 0); | 131 DCHECK_GT(n, 0); |
| 132 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; | 132 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; |
| 133 keys->push_back(crash_key); | 133 keys->push_back(crash_key); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 void AppendCrashCrashKeys(std::vector<base::debug::CrashKey>* keys) { |
| 138 DCHECK(keys); |
| 139 |
| 140 const std::vector<base::debug::CrashKey> crash_keys = { |
| 141 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 142 { kMetricsClientId, kSmallSize }, |
| 143 #else |
| 144 { kClientId, kSmallSize }, |
| 145 #endif |
| 146 { kChannel, kSmallSize }, |
| 147 { kNumVariations, kSmallSize }, |
| 148 { kVariations, kLargeSize }, |
| 149 #if defined(OS_MACOSX) |
| 150 { mac::kZombie, kMediumSize }, |
| 151 { mac::kZombieTrace, kMediumSize }, |
| 152 #endif |
| 153 { kBug464926CrashKey, kSmallSize }, |
| 154 }; |
| 155 |
| 156 keys->insert(keys->end(), crash_keys.begin(), crash_keys.end()); |
| 157 } |
| 158 |
| 137 void SetSwitchesFromCommandLine(const base::CommandLine& command_line, | 159 void SetSwitchesFromCommandLine(const base::CommandLine& command_line, |
| 138 SwitchFilterFunction skip_filter) { | 160 SwitchFilterFunction skip_filter) { |
| 139 const base::CommandLine::StringVector& argv = command_line.argv(); | 161 const base::CommandLine::StringVector& argv = command_line.argv(); |
| 140 | 162 |
| 141 // Set the number of switches in case size > kNumSwitches. | 163 // Set the number of switches in case size > kNumSwitches. |
| 142 base::debug::SetCrashKeyValue(kNumSwitches, | 164 base::debug::SetCrashKeyValue(kNumSwitches, |
| 143 base::StringPrintf("%" PRIuS, argv.size() - 1)); | 165 base::StringPrintf("%" PRIuS, argv.size() - 1)); |
| 144 | 166 |
| 145 size_t key_i = 1; // Key names are 1-indexed. | 167 size_t key_i = 1; // Key names are 1-indexed. |
| 146 | 168 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 161 std::string key = base::StringPrintf(kSwitchFormat, key_i++); | 183 std::string key = base::StringPrintf(kSwitchFormat, key_i++); |
| 162 base::debug::SetCrashKeyValue(key, switch_str); | 184 base::debug::SetCrashKeyValue(key, switch_str); |
| 163 } | 185 } |
| 164 | 186 |
| 165 // Clear any remaining switches. | 187 // Clear any remaining switches. |
| 166 for (; key_i <= kSwitchesMaxCount; ++key_i) | 188 for (; key_i <= kSwitchesMaxCount; ++key_i) |
| 167 base::debug::ClearCrashKey(base::StringPrintf(kSwitchFormat, key_i)); | 189 base::debug::ClearCrashKey(base::StringPrintf(kSwitchFormat, key_i)); |
| 168 } | 190 } |
| 169 | 191 |
| 170 } // namespace crash_keys | 192 } // namespace crash_keys |
| OLD | NEW |