| 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 // Simple wrapper and basic configuration of Google breakpad. We try | 5 // Simple wrapper and basic configuration of Google breakpad. We try |
| 6 // to avoid using any unnecessary code (like libbase) to make it as | 6 // to avoid using any unnecessary code (like libbase) to make it as |
| 7 // non-intrusive as possible to link in this library. | 7 // non-intrusive as possible to link in this library. |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <pwd.h> | 10 #include <pwd.h> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 static const char *s_crash_path; | 31 static const char *s_crash_path; |
| 32 static const char *s_crash_parent_path; | 32 static const char *s_crash_parent_path; |
| 33 static mode_t s_dump_directory_mode; | 33 static mode_t s_dump_directory_mode; |
| 34 | 34 |
| 35 static bool s_any_crashes_occurred = false; | 35 static bool s_any_crashes_occurred = false; |
| 36 static google_breakpad::ExceptionHandler *s_breakpad_handler; | 36 static google_breakpad::ExceptionHandler *s_breakpad_handler; |
| 37 | 37 |
| 38 static bool s_enabled = false; | 38 static bool s_enabled = false; |
| 39 | 39 |
| 40 #define CHECK_CONDITION(_cond, _message) \ | 40 #define CHECK_CONDITION(_cond, _message) \ |
| 41 do { if (!(_cond)) { fputs(_message, stderr); abort(); } } while(false) | 41 do { if (!(_cond)) { fputs(_message"\n", stderr); abort(); } } while(false) |
| 42 | 42 |
| 43 // This static object will cause anything that links in this object to get | 43 // This static object will cause anything that links in this object to get |
| 44 // crash handling for the duration of this file's scope. | 44 // crash handling for the duration of this file's scope. |
| 45 static CrashDumper g_crash_dumper; | 45 static CrashDumper g_crash_dumper; |
| 46 | 46 |
| 47 | 47 |
| 48 // Prepare the crash path. Must avoid allocating memory. | 48 // Prepare the crash path. Must avoid allocating memory. |
| 49 static bool PrepareCrashPath() { | 49 static bool PrepareCrashPath() { |
| 50 struct kernel_stat buf; | 50 struct kernel_stat buf; |
| 51 if (sys_stat(s_crash_path, &buf) < 0) { | 51 if (sys_stat(s_crash_path, &buf) < 0) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 void CrashDumper::Disable() { | 129 void CrashDumper::Disable() { |
| 130 CHECK_CONDITION(s_enabled, "Crash handling was not enabled"); | 130 CHECK_CONDITION(s_enabled, "Crash handling was not enabled"); |
| 131 delete s_breakpad_handler; | 131 delete s_breakpad_handler; |
| 132 s_breakpad_handler = NULL; | 132 s_breakpad_handler = NULL; |
| 133 s_crash_path = NULL; | 133 s_crash_path = NULL; |
| 134 s_crash_parent_path = NULL; | 134 s_crash_parent_path = NULL; |
| 135 s_enabled = false; | 135 s_enabled = false; |
| 136 } | 136 } |
| OLD | NEW |