OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 #ifndef CRASH_CRASH_DUMPER_H_ | 5 #ifndef CRASH_CRASH_DUMPER_H_ |
6 #define CRASH_CRASH_DUMPER_H_ | 6 #define CRASH_CRASH_DUMPER_H_ |
7 | 7 |
8 #include <string> | |
9 | |
10 #include "base/scoped_ptr.h" | |
11 | |
12 namespace google_breakpad { | |
13 class ExceptionHandler; | |
14 } | |
15 | |
16 class FilePath; | |
17 | |
18 // Class to manage crash handling and dumping. When Enable is called, all | 8 // Class to manage crash handling and dumping. When Enable is called, all |
19 // crashes will be caught and stored to the appropriate crash directory. | 9 // crashes will be caught and stored to the appropriate crash directory. |
20 // The directory will be: | 10 // The directory will be: |
21 // /home/chronos/user/crash - for all processes running as chronos | 11 // /home/chronos/user/crash - for all processes running as chronos |
22 // /var/spool/crash - for all other processes | 12 // /var/spool/crash - for all other processes |
23 // The class takes care of creating the directories (even recreating them | 13 // The class takes care of creating the directories (even recreating them |
24 // at crash time in case the cryptohome mounting changes from Enable time. | 14 // at crash time in case the cryptohome mounting changes from Enable time. |
| 15 // |
| 16 // For most use cases, there is no need to include or call any functions |
| 17 // explicitly in this header file. Crash dumping is enabled just by linking |
| 18 // in libcrash_dumper. |
25 | 19 |
26 class CrashDumper { | 20 class CrashDumper { |
27 public: | 21 public: |
| 22 CrashDumper() { |
| 23 Enable(); |
| 24 } |
| 25 |
28 ~CrashDumper() { | 26 ~CrashDumper() { |
29 if (IsEnabled()) { | 27 if (IsEnabled()) { |
30 Disable(); | 28 Disable(); |
31 } | 29 } |
32 } | 30 } |
33 | 31 |
34 // Enable crash detection and dumping. Aborts if already enabled | 32 // Enable crash detection and dumping. Aborts if already enabled |
35 // or crash reporting cannot be enabled. If the cryptohome is mounted | 33 // or crash reporting cannot be enabled. If the cryptohome is mounted |
36 // while crash handling is enabled, later crashes may be lost. | 34 // while crash handling is enabled, later crashes may be lost. |
37 static void Enable(); | 35 static void Enable(); |
38 | 36 |
39 // Return if enabled. | 37 // Return if enabled. |
40 static bool IsEnabled(); | 38 static bool IsEnabled(); |
41 | 39 |
42 // Disable crash detection and dumping. Aborts if not enabled. | 40 // Disable crash detection and dumping. Aborts if not enabled. |
43 static void Disable(); | 41 static void Disable(); |
44 }; | 42 }; |
45 | 43 |
46 #endif // CRASH_CRASH_DUMPER_H_ | 44 #endif // CRASH_CRASH_DUMPER_H_ |
OLD | NEW |