OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/process_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <io.h> | 8 #include <io.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <winternl.h> | 10 #include <winternl.h> |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if (exitcode == PROCESS_END_NORMAL_TERMINATON || | 356 if (exitcode == PROCESS_END_NORMAL_TERMINATON || |
357 exitcode == PROCESS_END_KILLED_BY_USER || | 357 exitcode == PROCESS_END_KILLED_BY_USER || |
358 exitcode == PROCESS_END_PROCESS_WAS_HUNG || | 358 exitcode == PROCESS_END_PROCESS_WAS_HUNG || |
359 exitcode == 0xC0000354 || // STATUS_DEBUGGER_INACTIVE. | 359 exitcode == 0xC0000354 || // STATUS_DEBUGGER_INACTIVE. |
360 exitcode == 0xC000013A || // Control-C/end session. | 360 exitcode == 0xC000013A || // Control-C/end session. |
361 exitcode == 0x40010004) { // Debugger terminated process/end session. | 361 exitcode == 0x40010004) { // Debugger terminated process/end session. |
362 return false; | 362 return false; |
363 } | 363 } |
364 | 364 |
365 // All other exit codes indicate crashes. | 365 // All other exit codes indicate crashes. |
366 | |
367 // TODO(jar): Remove histogramming code when UMA stats are consistent with | |
368 // other crash metrics. | |
369 // Histogram the low order 3 nibbles for UMA | |
370 const int kLeastValue = 0; | |
371 const int kMaxValue = 0xFFF; | |
372 const int kBucketCount = kMaxValue - kLeastValue + 1; | |
373 static LinearHistogram least_significant_histogram("ExitCodes.LSNibbles", | |
374 kLeastValue + 1, kMaxValue, kBucketCount); | |
375 least_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | | |
376 LinearHistogram::kHexRangePrintingFlag); | |
377 least_significant_histogram.Add(exitcode & 0xFFF); | |
378 | |
379 // Histogram the high order 3 nibbles | |
380 static LinearHistogram most_significant_histogram("ExitCodes.MSNibbles", | |
381 kLeastValue + 1, kMaxValue, kBucketCount); | |
382 most_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | | |
383 LinearHistogram::kHexRangePrintingFlag); | |
384 // Avoid passing in negative numbers by shifting data into low end of dword. | |
385 most_significant_histogram.Add((exitcode >> 20) & 0xFFF); | |
386 | |
387 // Histogram the middle order 2 nibbles | |
388 static LinearHistogram mid_significant_histogram("ExitCodes.MidNibbles", | |
389 1, 0xFF, 0x100); | |
390 mid_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | | |
391 LinearHistogram::kHexRangePrintingFlag); | |
392 mid_significant_histogram.Add((exitcode >> 12) & 0xFF); | |
393 | |
394 return true; | 366 return true; |
395 } | 367 } |
396 | 368 |
397 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { | 369 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { |
398 ScopedHandle closer(handle); // Ensure that we always close the handle. | 370 ScopedHandle closer(handle); // Ensure that we always close the handle. |
399 if (::WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0) { | 371 if (::WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0) { |
400 NOTREACHED(); | 372 NOTREACHED(); |
401 return false; | 373 return false; |
402 } | 374 } |
403 DWORD temp_code; // Don't clobber out-parameters in case of failure. | 375 DWORD temp_code; // Don't clobber out-parameters in case of failure. |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 g_previous_filter = SetUnhandledExceptionFilter(&StackDumpExceptionFilter); | 793 g_previous_filter = SetUnhandledExceptionFilter(&StackDumpExceptionFilter); |
822 AttachToConsole(); | 794 AttachToConsole(); |
823 return true; | 795 return true; |
824 } | 796 } |
825 | 797 |
826 void RaiseProcessToHighPriority() { | 798 void RaiseProcessToHighPriority() { |
827 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); | 799 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
828 } | 800 } |
829 | 801 |
830 } // namespace base | 802 } // namespace base |
OLD | NEW |