OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/metrics/histogram_snapshot_manager.h" | 5 #include "base/metrics/histogram_snapshot_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
| 9 #include "base/debug/alias.h" |
9 #include "base/metrics/histogram_flattener.h" | 10 #include "base/metrics/histogram_flattener.h" |
10 #include "base/metrics/histogram_samples.h" | 11 #include "base/metrics/histogram_samples.h" |
11 #include "base/metrics/statistics_recorder.h" | 12 #include "base/metrics/statistics_recorder.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 | 16 |
16 HistogramSnapshotManager::HistogramSnapshotManager( | 17 HistogramSnapshotManager::HistogramSnapshotManager( |
17 HistogramFlattener* histogram_flattener) | 18 HistogramFlattener* histogram_flattener) |
18 : preparing_deltas_(false), | 19 : preparing_deltas_(false), |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 112 } |
112 | 113 |
113 // Crash if we detect that our histograms have been overwritten. This may be | 114 // Crash if we detect that our histograms have been overwritten. This may be |
114 // a fair distance from the memory smasher, but we hope to correlate these | 115 // a fair distance from the memory smasher, but we hope to correlate these |
115 // crashes with other events, such as plugins, or usage patterns, etc. | 116 // crashes with other events, such as plugins, or usage patterns, etc. |
116 uint32_t corruption = histogram->FindCorruption(*samples); | 117 uint32_t corruption = histogram->FindCorruption(*samples); |
117 if (HistogramBase::BUCKET_ORDER_ERROR & corruption) { | 118 if (HistogramBase::BUCKET_ORDER_ERROR & corruption) { |
118 // The checksum should have caught this, so crash separately if it didn't. | 119 // The checksum should have caught this, so crash separately if it didn't. |
119 CHECK_NE(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); | 120 CHECK_NE(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); |
120 CHECK(false); // Crash for the bucket order corruption. | 121 CHECK(false); // Crash for the bucket order corruption. |
| 122 // Ensure that compiler keeps around pointers to |histogram| and its |
| 123 // internal |bucket_ranges_| for any minidumps. |
| 124 base::debug::Alias( |
| 125 static_cast<const Histogram*>(histogram)->bucket_ranges()); |
121 } | 126 } |
122 // Checksum corruption might not have caused order corruption. | 127 // Checksum corruption might not have caused order corruption. |
123 CHECK_EQ(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); | 128 CHECK_EQ(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); |
124 | 129 |
125 // Note, at this point corruption can only be COUNT_HIGH_ERROR or | 130 // Note, at this point corruption can only be COUNT_HIGH_ERROR or |
126 // COUNT_LOW_ERROR and they never arise together, so we don't need to extract | 131 // COUNT_LOW_ERROR and they never arise together, so we don't need to extract |
127 // bits from corruption. | 132 // bits from corruption. |
128 if (corruption) { | 133 if (corruption) { |
129 DLOG(ERROR) << "Histogram: \"" << histogram->histogram_name() | 134 DLOG(ERROR) << "Histogram: \"" << histogram->histogram_name() |
130 << "\" has data corruption: " << corruption; | 135 << "\" has data corruption: " << corruption; |
(...skipping 28 matching lines...) Expand all Loading... |
159 | 164 |
160 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); | 165 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); |
161 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { | 166 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { |
162 // Fix logged_samples. | 167 // Fix logged_samples. |
163 logged_samples->Subtract(*logged_samples); | 168 logged_samples->Subtract(*logged_samples); |
164 logged_samples->Add(new_snapshot); | 169 logged_samples->Add(new_snapshot); |
165 } | 170 } |
166 } | 171 } |
167 | 172 |
168 } // namespace base | 173 } // namespace base |
OLD | NEW |