1 // Copyright (c) 2006, Google Inc.
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
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
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.
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.
30 #ifndef GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
31 #define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
36 #include "common/using_std_string.h"
37 #include "google_breakpad/common/breakpad_types.h"
39 namespace google_breakpad {
43 class StackFrameSymbolizer;
44 class SourceLineResolverInterface;
47 // Return type for Process()
49 PROCESS_OK, // The minidump was
53 PROCESS_ERROR_MINIDUMP_NOT_FOUND, // The minidump file
56 PROCESS_ERROR_NO_MINIDUMP_HEADER, // The minidump file
59 PROCESS_ERROR_NO_THREAD_LIST, // The minidump file
60 // had no thread list.
62 PROCESS_ERROR_GETTING_THREAD, // There was an error
67 PROCESS_ERROR_GETTING_THREAD_ID, // There was an error
68 // getting a thread id
72 PROCESS_ERROR_DUPLICATE_REQUESTING_THREADS, // There was more than
76 PROCESS_SYMBOL_SUPPLIER_INTERRUPTED // The minidump
83 class MinidumpProcessor {
85 // Initializes this MinidumpProcessor. supplier should be an
86 // implementation of the SymbolSupplier abstract base class.
87 MinidumpProcessor(SymbolSupplier* supplier,
88 SourceLineResolverInterface* resolver);
90 // Initializes the MinidumpProcessor with the option of
91 // enabling the exploitability framework to analyze dumps
92 // for probable security relevance.
93 MinidumpProcessor(SymbolSupplier* supplier,
94 SourceLineResolverInterface* resolver,
95 bool enable_exploitability);
97 // Initializes the MinidumpProcessor with source line resolver helper, and
98 // the option of enabling the exploitability framework to analyze dumps
99 // for probable security relevance.
100 // Does not take ownership of resolver_helper, which must NOT be NULL.
101 MinidumpProcessor(StackFrameSymbolizer* stack_frame_symbolizer,
102 bool enable_exploitability);
104 ~MinidumpProcessor();
106 // Processes the minidump file and fills process_state with the result.
107 ProcessResult Process(const string &minidump_file,
108 ProcessState* process_state);
110 // Processes the minidump structure and fills process_state with the
112 ProcessResult Process(Minidump* minidump,
113 ProcessState* process_state);
114 // Populates the cpu_* fields of the |info| parameter with textual
115 // representations of the CPU type that the minidump in |dump| was
116 // produced on. Returns false if this information is not available in
118 static bool GetCPUInfo(Minidump* dump, SystemInfo* info);
120 // Populates the os_* fields of the |info| parameter with textual
121 // representations of the operating system that the minidump in |dump|
122 // was produced on. Returns false if this information is not available in
124 static bool GetOSInfo(Minidump* dump, SystemInfo* info);
126 // Returns a textual representation of the reason that a crash occurred,
127 // if the minidump in dump was produced as a result of a crash. Returns
128 // an empty string if this information cannot be determined. If address
129 // is non-NULL, it will be set to contain the address that caused the
130 // exception, if this information is available. This will be a code
131 // address when the crash was caused by problems such as illegal
132 // instructions or divisions by zero, or a data address when the crash
133 // was caused by a memory access violation.
134 static string GetCrashReason(Minidump* dump, uint64_t* address);
136 // This function returns true if the passed-in error code is
137 // something unrecoverable(i.e. retry should not happen). For
138 // instance, if the minidump is corrupt, then it makes no sense to
139 // retry as we won't be able to glean additional information.
140 // However, as an example of the other case, the symbol supplier can
141 // return an error code indicating it was 'interrupted', which can
142 // happen of the symbols are fetched from a remote store, and a
143 // retry might be successful later on.
144 // You should not call this method with PROCESS_OK! Test for
145 // that separately before calling this.
146 static bool IsErrorUnrecoverable(ProcessResult p) {
147 assert(p != PROCESS_OK);
148 return (p != PROCESS_SYMBOL_SUPPLIER_INTERRUPTED);
151 // Returns a textual representation of an assertion included
152 // in the minidump. Returns an empty string if this information
153 // does not exist or cannot be determined.
154 static string GetAssertion(Minidump* dump);
157 StackFrameSymbolizer* frame_symbolizer_;
158 // Indicate whether resolver_helper_ is owned by this instance.
159 bool own_frame_symbolizer_;
161 // This flag enables the exploitability scanner which attempts to
162 // guess how likely it is that the crash represents an exploitable
163 // memory corruption issue.
164 bool enable_exploitability_;
167 } // namespace google_breakpad
169 #endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__