OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006, Google Inc. | |
2 // All rights reserved. | |
3 // | |
4 // Redistribution and use in source and binary forms, with or without | |
5 // modification, are permitted provided that the following conditions are | |
6 // met: | |
7 // | |
8 // * Redistributions of source code must retain the above copyright | |
9 // notice, this list of conditions and the following disclaimer. | |
10 // * Redistributions in binary form must reproduce the above | |
11 // copyright notice, this list of conditions and the following disclaimer | |
12 // in the documentation and/or other materials provided with the | |
13 // distribution. | |
14 // * Neither the name of Google Inc. nor the names of its | |
15 // contributors may be used to endorse or promote products derived from | |
16 // this software without specific prior written permission. | |
17 // | |
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | |
30 #ifndef GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__ | |
31 #define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__ | |
32 | |
33 #include <cassert> | |
34 #include <string> | |
35 #include "google_breakpad/common/breakpad_types.h" | |
36 | |
37 namespace google_breakpad { | |
38 | |
39 using std::string; | |
40 | |
41 class Minidump; | |
42 class ProcessState; | |
43 class SourceLineResolverInterface; | |
44 class SymbolSupplier; | |
45 class SystemInfo; | |
46 // Return type for Process() | |
47 enum ProcessResult { | |
48 PROCESS_OK, // The minidump was | |
49 // processed | |
50 // successfully. | |
51 | |
52 PROCESS_ERROR_MINIDUMP_NOT_FOUND, // The minidump file | |
53 // was not found. | |
54 | |
55 PROCESS_ERROR_NO_MINIDUMP_HEADER, // The minidump file | |
56 // had no header | |
57 | |
58 PROCESS_ERROR_NO_THREAD_LIST, // The minidump file | |
59 // had no thread list. | |
60 | |
61 PROCESS_ERROR_GETTING_THREAD, // There was an error | |
62 // getting one | |
63 // thread's data from | |
64 // the minidump. | |
65 | |
66 PROCESS_ERROR_GETTING_THREAD_ID, // There was an error | |
67 // getting a thread id | |
68 // from the thread's | |
69 // data. | |
70 | |
71 PROCESS_ERROR_DUPLICATE_REQUESTING_THREADS, // There was more than | |
72 // one requesting | |
73 // thread. | |
74 | |
75 PROCESS_ERROR_NO_MEMORY_FOR_THREAD, // A thread had no | |
76 // memory region. | |
77 | |
78 PROCESS_ERROR_NO_STACKWALKER_FOR_THREAD, // We couldn't | |
79 // determine the | |
80 // StackWalker to walk | |
81 // the minidump's | |
82 // threads. | |
83 | |
84 PROCESS_SYMBOL_SUPPLIER_INTERRUPTED // The minidump | |
85 // processing was | |
86 // interrupted by the | |
87 // SymbolSupplier(not | |
88 // fatal) | |
89 }; | |
90 | |
91 class MinidumpProcessor { | |
92 public: | |
93 // Initializes this MinidumpProcessor. supplier should be an | |
94 // implementation of the SymbolSupplier abstract base class. | |
95 MinidumpProcessor(SymbolSupplier *supplier, | |
96 SourceLineResolverInterface *resolver); | |
97 ~MinidumpProcessor(); | |
98 | |
99 // Processes the minidump file and fills process_state with the result. | |
100 ProcessResult Process(const string &minidump_file, | |
101 ProcessState *process_state); | |
102 | |
103 // Processes the minidump structure and fills process_state with the | |
104 // result. | |
105 ProcessResult Process(Minidump *minidump, | |
106 ProcessState *process_state); | |
107 // Populates the cpu_* fields of the |info| parameter with textual | |
108 // representations of the CPU type that the minidump in |dump| was | |
109 // produced on. Returns false if this information is not available in | |
110 // the minidump. | |
111 static bool GetCPUInfo(Minidump *dump, SystemInfo *info); | |
112 | |
113 // Populates the os_* fields of the |info| parameter with textual | |
114 // representations of the operating system that the minidump in |dump| | |
115 // was produced on. Returns false if this information is not available in | |
116 // the minidump. | |
117 static bool GetOSInfo(Minidump *dump, SystemInfo *info); | |
118 | |
119 // Returns a textual representation of the reason that a crash occurred, | |
120 // if the minidump in dump was produced as a result of a crash. Returns | |
121 // an empty string if this information cannot be determined. If address | |
122 // is non-NULL, it will be set to contain the address that caused the | |
123 // exception, if this information is available. This will be a code | |
124 // address when the crash was caused by problems such as illegal | |
125 // instructions or divisions by zero, or a data address when the crash | |
126 // was caused by a memory access violation. | |
127 static string GetCrashReason(Minidump *dump, u_int64_t *address); | |
128 | |
129 // This function returns true if the passed-in error code is | |
130 // something unrecoverable(i.e. retry should not happen). For | |
131 // instance, if the minidump is corrupt, then it makes no sense to | |
132 // retry as we won't be able to glean additional information. | |
133 // However, as an example of the other case, the symbol supplier can | |
134 // return an error code indicating it was 'interrupted', which can | |
135 // happen of the symbols are fetched from a remote store, and a | |
136 // retry might be successful later on. | |
137 // You should not call this method with PROCESS_OK! Test for | |
138 // that separately before calling this. | |
139 static bool IsErrorUnrecoverable(ProcessResult p) { | |
140 assert(p != PROCESS_OK); | |
141 return (p != PROCESS_SYMBOL_SUPPLIER_INTERRUPTED); | |
142 } | |
143 | |
144 // Returns a textual representation of an assertion included | |
145 // in the minidump. Returns an empty string if this information | |
146 // does not exist or cannot be determined. | |
147 static string GetAssertion(Minidump *dump); | |
148 | |
149 private: | |
150 SymbolSupplier *supplier_; | |
151 SourceLineResolverInterface *resolver_; | |
152 }; | |
153 | |
154 } // namespace google_breakpad | |
155 | |
156 #endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__ | |
OLD | NEW |