Commit 263a17a3 authored by kaiwang@chromium.org's avatar kaiwang@chromium.org

Add more code for debugging. We will revert this change when we find out the reason of corruption.

See previous change for debugging: http://codereview.chromium.org/10826293/

BUG=140688
TBR=jar
Review URL: https://chromiumcodereview.appspot.com/10857025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151837 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f33bb97
...@@ -103,7 +103,7 @@ BucketRanges::~BucketRanges() {} ...@@ -103,7 +103,7 @@ BucketRanges::~BucketRanges() {}
void BucketRanges::set_range(size_t i, HistogramBase::Sample value) { void BucketRanges::set_range(size_t i, HistogramBase::Sample value) {
DCHECK_LT(i, ranges_.size()); DCHECK_LT(i, ranges_.size());
DCHECK_GE(value, 0); CHECK_GE(value, 0);
ranges_[i] = value; ranges_[i] = value;
} }
......
...@@ -133,7 +133,7 @@ bool Histogram::SampleSet::Deserialize(PickleIterator* iter) { ...@@ -133,7 +133,7 @@ bool Histogram::SampleSet::Deserialize(PickleIterator* iter) {
} }
// TODO(rtenneti): delete this code after debugging. // TODO(rtenneti): delete this code after debugging.
void CheckCorruption(const Histogram& histogram) { void CheckCorruption(const Histogram& histogram, bool new_histogram) {
const std::string& histogram_name = histogram.histogram_name(); const std::string& histogram_name = histogram.histogram_name();
char histogram_name_buf[128]; char histogram_name_buf[128];
base::strlcpy(histogram_name_buf, base::strlcpy(histogram_name_buf,
...@@ -141,18 +141,18 @@ void CheckCorruption(const Histogram& histogram) { ...@@ -141,18 +141,18 @@ void CheckCorruption(const Histogram& histogram) {
arraysize(histogram_name_buf)); arraysize(histogram_name_buf));
base::debug::Alias(histogram_name_buf); base::debug::Alias(histogram_name_buf);
bool debug_new_histogram[1];
debug_new_histogram[0] = new_histogram;
base::debug::Alias(debug_new_histogram);
Sample previous_range = -1; // Bottom range is always 0. Sample previous_range = -1; // Bottom range is always 0.
for (size_t index = 0; index < histogram.bucket_count(); ++index) { for (size_t index = 0; index < histogram.bucket_count(); ++index) {
int new_range = histogram.ranges(index); int new_range = histogram.ranges(index);
if (previous_range >= new_range) { CHECK_LT(previous_range, new_range);
CHECK(false); // Crash for the bucket order corruption.
}
previous_range = new_range; previous_range = new_range;
} }
if (!histogram.bucket_ranges()->HasValidChecksum()) { CHECK(histogram.bucket_ranges()->HasValidChecksum());
CHECK(false); // Crash for the checksum corruption.
}
} }
Histogram* Histogram::FactoryGet(const string& name, Histogram* Histogram::FactoryGet(const string& name,
...@@ -174,12 +174,14 @@ Histogram* Histogram::FactoryGet(const string& name, ...@@ -174,12 +174,14 @@ Histogram* Histogram::FactoryGet(const string& name,
Histogram* tentative_histogram = Histogram* tentative_histogram =
new Histogram(name, minimum, maximum, bucket_count, registered_ranges); new Histogram(name, minimum, maximum, bucket_count, registered_ranges);
CheckCorruption(*tentative_histogram, true);
tentative_histogram->SetFlags(flags); tentative_histogram->SetFlags(flags);
histogram = histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
} }
// TODO(rtenneti): delete this code after debugging. // TODO(rtenneti): delete this code after debugging.
CheckCorruption(*histogram); CheckCorruption(*histogram, false);
CHECK_EQ(HISTOGRAM, histogram->histogram_type()); CHECK_EQ(HISTOGRAM, histogram->histogram_type());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
...@@ -728,12 +730,14 @@ Histogram* LinearHistogram::FactoryGet(const string& name, ...@@ -728,12 +730,14 @@ Histogram* LinearHistogram::FactoryGet(const string& name,
LinearHistogram* tentative_histogram = LinearHistogram* tentative_histogram =
new LinearHistogram(name, minimum, maximum, bucket_count, new LinearHistogram(name, minimum, maximum, bucket_count,
registered_ranges); registered_ranges);
CheckCorruption(*tentative_histogram, true);
tentative_histogram->SetFlags(flags); tentative_histogram->SetFlags(flags);
histogram = histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
} }
// TODO(rtenneti): delete this code after debugging. // TODO(rtenneti): delete this code after debugging.
CheckCorruption(*histogram); CheckCorruption(*histogram, false);
CHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type()); CHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
...@@ -821,12 +825,14 @@ Histogram* BooleanHistogram::FactoryGet(const string& name, int32 flags) { ...@@ -821,12 +825,14 @@ Histogram* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
BooleanHistogram* tentative_histogram = BooleanHistogram* tentative_histogram =
new BooleanHistogram(name, registered_ranges); new BooleanHistogram(name, registered_ranges);
CheckCorruption(*tentative_histogram, true);
tentative_histogram->SetFlags(flags); tentative_histogram->SetFlags(flags);
histogram = histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
} }
// TODO(rtenneti): delete this code after debugging. // TODO(rtenneti): delete this code after debugging.
CheckCorruption(*histogram); CheckCorruption(*histogram, false);
CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type()); CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type());
return histogram; return histogram;
...@@ -862,13 +868,15 @@ Histogram* CustomHistogram::FactoryGet(const string& name, ...@@ -862,13 +868,15 @@ Histogram* CustomHistogram::FactoryGet(const string& name,
// To avoid racy destruction at shutdown, the following will be leaked. // To avoid racy destruction at shutdown, the following will be leaked.
CustomHistogram* tentative_histogram = CustomHistogram* tentative_histogram =
new CustomHistogram(name, registered_ranges); new CustomHistogram(name, registered_ranges);
CheckCorruption(*tentative_histogram, true);
tentative_histogram->SetFlags(flags); tentative_histogram->SetFlags(flags);
histogram = histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
} }
// TODO(rtenneti): delete this code after debugging. // TODO(rtenneti): delete this code after debugging.
CheckCorruption(*histogram); CheckCorruption(*histogram, false);
CHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM); CHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM);
return histogram; return histogram;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment