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_REPORTER_KERNEL_COLLECTOR_H_ | 5 #ifndef _CRASH_REPORTER_KERNEL_COLLECTOR_H_ |
6 #define _CRASH_REPORTER_KERNEL_COLLECTOR_H_ | 6 #define _CRASH_REPORTER_KERNEL_COLLECTOR_H_ |
7 | 7 |
8 #include <pcrecpp.h> | 8 #include <pcrecpp.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "crash-reporter/crash_collector.h" | 13 #include "crash-reporter/crash_collector.h" |
14 #include "gtest/gtest_prod.h" // for FRIEND_TEST | 14 #include "gtest/gtest_prod.h" // for FRIEND_TEST |
15 | 15 |
16 class FilePath; | 16 class FilePath; |
17 | 17 |
18 // Kernel crash collector. | 18 // Kernel crash collector. |
19 class KernelCollector : public CrashCollector { | 19 class KernelCollector : public CrashCollector { |
20 public: | 20 public: |
| 21 // Enumeration to specify architecture type. |
| 22 enum ArchKind { |
| 23 archUnknown, |
| 24 archArm, |
| 25 archX86, |
| 26 |
| 27 archCount // Number of architectures. |
| 28 }; |
| 29 |
21 KernelCollector(); | 30 KernelCollector(); |
22 | 31 |
23 virtual ~KernelCollector(); | 32 virtual ~KernelCollector(); |
24 | 33 |
25 void OverridePreservedDumpPath(const FilePath &file_path); | 34 void OverridePreservedDumpPath(const FilePath &file_path); |
26 | 35 |
27 // Enable collection. | 36 // Enable collection. |
28 bool Enable(); | 37 bool Enable(); |
29 | 38 |
30 // Returns true if the kernel collection currently enabled. | 39 // Returns true if the kernel collection currently enabled. |
31 bool IsEnabled() { | 40 bool IsEnabled() { |
32 return is_enabled_; | 41 return is_enabled_; |
33 } | 42 } |
34 | 43 |
35 // Collect any preserved kernel crash dump. Returns true if there was | 44 // Collect any preserved kernel crash dump. Returns true if there was |
36 // a dump (even if there were problems storing the dump), false otherwise. | 45 // a dump (even if there were problems storing the dump), false otherwise. |
37 bool Collect(); | 46 bool Collect(); |
38 | 47 |
39 // Compute a stack signature string from a kernel dump. | 48 // Compute a stack signature string from a kernel dump. |
40 bool ComputeKernelStackSignature(const std::string &kernel_dump, | 49 bool ComputeKernelStackSignature(const std::string &kernel_dump, |
41 std::string *kernel_signature, | 50 std::string *kernel_signature, |
42 bool print_diagnostics); | 51 bool print_diagnostics); |
43 | 52 |
| 53 // Set the architecture of the crash dumps we are looking at. |
| 54 void SetArch(enum ArchKind arch); |
| 55 enum ArchKind GetArch() { return arch_; } |
| 56 |
44 private: | 57 private: |
45 friend class KernelCollectorTest; | 58 friend class KernelCollectorTest; |
46 FRIEND_TEST(KernelCollectorTest, ClearPreservedDump); | 59 FRIEND_TEST(KernelCollectorTest, ClearPreservedDump); |
47 FRIEND_TEST(KernelCollectorTest, LoadPreservedDump); | 60 FRIEND_TEST(KernelCollectorTest, LoadPreservedDump); |
48 FRIEND_TEST(KernelCollectorTest, CollectOK); | 61 FRIEND_TEST(KernelCollectorTest, CollectOK); |
49 | 62 |
50 bool LoadPreservedDump(std::string *contents); | 63 bool LoadPreservedDump(std::string *contents); |
51 bool ClearPreservedDump(); | 64 bool ClearPreservedDump(); |
52 | 65 |
53 void ProcessStackTrace(pcrecpp::StringPiece kernel_dump, | 66 void ProcessStackTrace(pcrecpp::StringPiece kernel_dump, |
54 bool print_diagnostics, | 67 bool print_diagnostics, |
55 unsigned *hash, | 68 unsigned *hash, |
56 float *last_stack_timestamp); | 69 float *last_stack_timestamp); |
57 bool FindCrashingFunction(pcrecpp::StringPiece kernel_dump, | 70 bool FindCrashingFunction(pcrecpp::StringPiece kernel_dump, |
58 bool print_diagnostics, | 71 bool print_diagnostics, |
59 float stack_trace_timestamp, | 72 float stack_trace_timestamp, |
60 std::string *crashing_function); | 73 std::string *crashing_function); |
61 bool FindPanicMessage(pcrecpp::StringPiece kernel_dump, | 74 bool FindPanicMessage(pcrecpp::StringPiece kernel_dump, |
62 bool print_diagnostics, | 75 bool print_diagnostics, |
63 std::string *panic_message); | 76 std::string *panic_message); |
64 | 77 |
| 78 // Returns the architecture kind for which we are built - enum ArchKind. |
| 79 enum ArchKind GetCompilerArch(void); |
| 80 |
65 bool is_enabled_; | 81 bool is_enabled_; |
66 FilePath preserved_dump_path_; | 82 FilePath preserved_dump_path_; |
67 static const char kClearingSequence[]; | 83 static const char kClearingSequence[]; |
| 84 |
| 85 // The architecture of kernel dump strings we are working with. |
| 86 enum ArchKind arch_; |
68 }; | 87 }; |
69 | 88 |
70 #endif // _CRASH_REPORTER_KERNEL_COLLECTOR_H_ | 89 #endif // _CRASH_REPORTER_KERNEL_COLLECTOR_H_ |
OLD | NEW |