diff options
author | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-23 01:17:16 +0000 |
---|---|---|
committer | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-23 01:17:16 +0000 |
commit | 147479d5e94f4c091b62c69a76bdfe6b6e15f39a (patch) | |
tree | 4896066faee6d6516c985c22dfb7f881e9d2edd4 /base/process_util.cc | |
parent | 8028073b0921bfac4b7987e9dcd677263973df05 (diff) | |
download | chromium_src-147479d5e94f4c091b62c69a76bdfe6b6e15f39a.zip chromium_src-147479d5e94f4c091b62c69a76bdfe6b6e15f39a.tar.gz chromium_src-147479d5e94f4c091b62c69a76bdfe6b6e15f39a.tar.bz2 |
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
Diffstat (limited to 'base/process_util.cc')
-rw-r--r-- | base/process_util.cc | 38 |
1 files changed, 34 insertions, 4 deletions
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 @@ bool DidProcessCrash(ProcessHandle handle) { } // 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 @@ void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) { 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 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) { 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; |