We're hoping to find exit codes that are incorrectly counted
as "crashes" but are "not really." Toward that end, we want
a "complete" list of exit codes, which categorigized as
"crashes."
Note we don't record stats when we "recognize" the exit
code.
r=evanm,nsylvain
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1269 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 147479d5e94f4c091b62c69a76bdfe6b6e15f39a
diff --git a/base/process_util.cc b/base/process_util.cc
index 09631ac..ca33f45 100644
--- a/base/process_util.cc
+++ b/base/process_util.cc
@@ -33,6 +33,7 @@
#include <winternl.h>
#include <psapi.h>
+#include "base/histogram.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
@@ -201,6 +202,34 @@
}
// All other exit codes indicate crashes.
+
+ // TODO(jar): Remove histogramming code when UMA stats are consistent with
+ // other crash metrics.
+ // Histogram the low order 3 nibbles for UMA
+ const int kLeastValue = 0;
+ const int kMaxValue = 0xFFF;
+ const int kBucketCount = kMaxValue - kLeastValue + 1;
+ static LinearHistogram least_significant_histogram(L"ExitCodes.LSNibbles",
+ kLeastValue + 1, kMaxValue, kBucketCount);
+ least_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
+ LinearHistogram::kHexRangePrintingFlag);
+ least_significant_histogram.Add(exitcode & 0xFFF);
+
+ // Histogram the high order 3 nibbles
+ static LinearHistogram most_significant_histogram(L"ExitCodes.MSNibbles",
+ kLeastValue + 1, kMaxValue, kBucketCount);
+ most_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
+ LinearHistogram::kHexRangePrintingFlag);
+ // Avoid passing in negative numbers by shifting data into low end of dword.
+ most_significant_histogram.Add((exitcode >> 20) & 0xFFF);
+
+ // Histogram the middle order 2 nibbles
+ static LinearHistogram mid_significant_histogram(L"ExitCodes.MidNibbles",
+ 1, 0xFF, 0x100);
+ mid_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
+ LinearHistogram::kHexRangePrintingFlag);
+ mid_significant_histogram.Add((exitcode >> 12) & 0xFF);
+
return true;
}
@@ -377,7 +406,7 @@
while (VirtualQueryEx(process_, base_address, &mbi,
sizeof(MEMORY_BASIC_INFORMATION)) ==
sizeof(MEMORY_BASIC_INFORMATION)) {
- if(mbi.State == MEM_COMMIT) {
+ if (mbi.State == MEM_COMMIT) {
if (mbi.Type == MEM_PRIVATE) {
committed_private += mbi.RegionSize;
} else if (mbi.Type == MEM_MAPPED) {
@@ -406,14 +435,15 @@
DWORD number_of_entries = 4096; // Just a guess.
PSAPI_WORKING_SET_INFORMATION* buffer = NULL;
int retries = 5;
- for(;;) {
+ for (;;) {
DWORD buffer_size = sizeof(PSAPI_WORKING_SET_INFORMATION) +
(number_of_entries * sizeof(PSAPI_WORKING_SET_BLOCK));
// if we can't expand the buffer, don't leak the previous
// contents or pass a NULL pointer to QueryWorkingSet
- PSAPI_WORKING_SET_INFORMATION* new_buffer = reinterpret_cast<PSAPI_WORKING_SET_INFORMATION*>(
- realloc(buffer, buffer_size));
+ PSAPI_WORKING_SET_INFORMATION* new_buffer =
+ reinterpret_cast<PSAPI_WORKING_SET_INFORMATION*>(
+ realloc(buffer, buffer_size));
if (!new_buffer) {
free(buffer);
return false;