OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CRASH_CRASH_DUMPER_H_ | |
6 #define CRASH_CRASH_DUMPER_H_ | |
7 | |
8 // Class to manage crash handling and dumping. When Enable is called, all | |
9 // crashes will be caught and stored to the appropriate crash directory. | |
10 // The directory will be: | |
11 // /home/chronos/user/crash - for all processes running as chronos | |
12 // /var/spool/crash - for all other processes | |
13 // The class takes care of creating the directories (even recreating them | |
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. | |
19 | |
20 class CrashDumper { | |
21 public: | |
22 CrashDumper() { | |
23 Enable(); | |
24 } | |
25 | |
26 ~CrashDumper() { | |
27 if (IsEnabled()) { | |
28 Disable(); | |
29 } | |
30 } | |
31 | |
32 // Enable crash detection and dumping. Aborts if already enabled | |
33 // or crash reporting cannot be enabled. If the cryptohome is mounted | |
34 // while crash handling is enabled, later crashes may be lost. | |
35 static void Enable(); | |
36 | |
37 // Return if enabled. | |
38 static bool IsEnabled(); | |
39 | |
40 // Disable crash detection and dumping. Aborts if not enabled. | |
41 static void Disable(); | |
42 }; | |
43 | |
44 #endif // CRASH_CRASH_DUMPER_H_ | |
OLD | NEW |