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/debug/alias.h" |
10 #include "base/metrics/histogram_flattener.h" | 10 #include "base/metrics/histogram_flattener.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // crashes with other events, such as plugins, or usage patterns, etc. | 46 // crashes with other events, such as plugins, or usage patterns, etc. |
47 uint32_t corruption = histogram->FindCorruption(*samples); | 47 uint32_t corruption = histogram->FindCorruption(*samples); |
48 if (HistogramBase::BUCKET_ORDER_ERROR & corruption) { | 48 if (HistogramBase::BUCKET_ORDER_ERROR & corruption) { |
49 // Extract fields useful during debug. | 49 // Extract fields useful during debug. |
50 const BucketRanges* ranges = | 50 const BucketRanges* ranges = |
51 static_cast<const Histogram*>(histogram)->bucket_ranges(); | 51 static_cast<const Histogram*>(histogram)->bucket_ranges(); |
52 std::vector<HistogramBase::Sample> ranges_copy; | 52 std::vector<HistogramBase::Sample> ranges_copy; |
53 for (size_t i = 0; i < ranges->size(); ++i) | 53 for (size_t i = 0; i < ranges->size(); ++i) |
54 ranges_copy.push_back(ranges->range(i)); | 54 ranges_copy.push_back(ranges->range(i)); |
55 HistogramBase::Sample* ranges_ptr = &ranges_copy[0]; | 55 HistogramBase::Sample* ranges_ptr = &ranges_copy[0]; |
| 56 uint32_t ranges_checksum = ranges->checksum(); |
| 57 uint32_t ranges_calc_checksum = ranges->CalculateChecksum(); |
56 const char* histogram_name = histogram->histogram_name().c_str(); | 58 const char* histogram_name = histogram->histogram_name().c_str(); |
57 int32_t flags = histogram->flags(); | 59 int32_t flags = histogram->flags(); |
58 // The checksum should have caught this, so crash separately if it didn't. | 60 // The checksum should have caught this, so crash separately if it didn't. |
59 CHECK_NE(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); | 61 CHECK_NE(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); |
60 CHECK(false); // Crash for the bucket order corruption. | 62 CHECK(false); // Crash for the bucket order corruption. |
61 // Ensure that compiler keeps around pointers to |histogram| and its | 63 // Ensure that compiler keeps around pointers to |histogram| and its |
62 // internal |bucket_ranges_| for any minidumps. | 64 // internal |bucket_ranges_| for any minidumps. |
63 base::debug::Alias(&ranges_ptr); | 65 base::debug::Alias(ranges_ptr); |
| 66 base::debug::Alias(&ranges_checksum); |
| 67 base::debug::Alias(&ranges_calc_checksum); |
64 base::debug::Alias(&histogram_name); | 68 base::debug::Alias(&histogram_name); |
65 base::debug::Alias(&flags); | 69 base::debug::Alias(&flags); |
66 } | 70 } |
67 // Checksum corruption might not have caused order corruption. | 71 // Checksum corruption might not have caused order corruption. |
68 CHECK_EQ(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); | 72 CHECK_EQ(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); |
69 | 73 |
70 // Note, at this point corruption can only be COUNT_HIGH_ERROR or | 74 // Note, at this point corruption can only be COUNT_HIGH_ERROR or |
71 // COUNT_LOW_ERROR and they never arise together, so we don't need to extract | 75 // COUNT_LOW_ERROR and they never arise together, so we don't need to extract |
72 // bits from corruption. | 76 // bits from corruption. |
73 if (corruption) { | 77 if (corruption) { |
(...skipping 25 matching lines...) Expand all Loading... |
99 | 103 |
100 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); | 104 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); |
101 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { | 105 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { |
102 // Fix logged_samples. | 106 // Fix logged_samples. |
103 logged_samples->Subtract(*logged_samples); | 107 logged_samples->Subtract(*logged_samples); |
104 logged_samples->Add(new_snapshot); | 108 logged_samples->Add(new_snapshot); |
105 } | 109 } |
106 } | 110 } |
107 | 111 |
108 } // namespace base | 112 } // namespace base |
OLD | NEW |