Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1783)

Unified Diff: base/metrics/histogram_snapshot_manager.cc

Issue 2148503002: Fix capture of debug information when corruption is detected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix signed/unsigned comparison Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_snapshot_manager.cc
diff --git a/base/metrics/histogram_snapshot_manager.cc b/base/metrics/histogram_snapshot_manager.cc
index dc6cb8a86ed62c97cce03ecb5cc88676ba1b4282..1eb2d5a59b2009e793877bae5f32f610270c3159 100644
--- a/base/metrics/histogram_snapshot_manager.cc
+++ b/base/metrics/histogram_snapshot_manager.cc
@@ -123,13 +123,23 @@ void HistogramSnapshotManager::PrepareSamples(
// crashes with other events, such as plugins, or usage patterns, etc.
uint32_t corruption = histogram->FindCorruption(*samples);
if (HistogramBase::BUCKET_ORDER_ERROR & corruption) {
+ // Extract fields useful during debug.
+ const BucketRanges* ranges =
+ static_cast<const Histogram*>(histogram)->bucket_ranges();
+ std::vector<HistogramBase::Sample> ranges_copy;
+ for (size_t i = 0; i < ranges->size(); ++i)
+ ranges_copy.push_back(ranges->range(i));
+ HistogramBase::Sample* ranges_ptr = &ranges_copy[0];
+ const char* histogram_name = histogram->histogram_name().c_str();
+ int32_t flags = histogram->flags();
// The checksum should have caught this, so crash separately if it didn't.
CHECK_NE(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
CHECK(false); // Crash for the bucket order corruption.
// Ensure that compiler keeps around pointers to |histogram| and its
// internal |bucket_ranges_| for any minidumps.
- base::debug::Alias(
- static_cast<const Histogram*>(histogram)->bucket_ranges());
+ base::debug::Alias(&ranges_ptr);
+ base::debug::Alias(&histogram_name);
+ base::debug::Alias(&flags);
}
// Checksum corruption might not have caused order corruption.
CHECK_EQ(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698