| 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 <assert.h> | |
| 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 | |
| 98 // Initializes the MinidumpProcessor with the option of | |
| 99 // enabling the exploitability framework to analyze dumps | |
| 100 // for probable security relevance. | |
| 101 MinidumpProcessor(SymbolSupplier *supplier, | |
| 102 SourceLineResolverInterface *resolver, | |
| 103 bool enable_exploitability); | |
| 104 | |
| 105 ~MinidumpProcessor(); | |
| 106 | |
| 107 // Processes the minidump file and fills process_state with the result. | |
| 108 ProcessResult Process(const string &minidump_file, | |
| 109 ProcessState *process_state); | |
| 110 | |
| 111 // Processes the minidump structure and fills process_state with the | |
| 112 // result. | |
| 113 ProcessResult Process(Minidump *minidump, | |
| 114 ProcessState *process_state); | |
| 115 // Populates the cpu_* fields of the |info| parameter with textual | |
| 116 // representations of the CPU type that the minidump in |dump| was | |
| 117 // produced on. Returns false if this information is not available in | |
| 118 // the minidump. | |
| 119 static bool GetCPUInfo(Minidump *dump, SystemInfo *info); | |
| 120 | |
| 121 // Populates the os_* fields of the |info| parameter with textual | |
| 122 // representations of the operating system that the minidump in |dump| | |
| 123 // was produced on. Returns false if this information is not available in | |
| 124 // the minidump. | |
| 125 static bool GetOSInfo(Minidump *dump, SystemInfo *info); | |
| 126 | |
| 127 // Returns a textual representation of the reason that a crash occurred, | |
| 128 // if the minidump in dump was produced as a result of a crash. Returns | |
| 129 // an empty string if this information cannot be determined. If address | |
| 130 // is non-NULL, it will be set to contain the address that caused the | |
| 131 // exception, if this information is available. This will be a code | |
| 132 // address when the crash was caused by problems such as illegal | |
| 133 // instructions or divisions by zero, or a data address when the crash | |
| 134 // was caused by a memory access violation. | |
| 135 static string GetCrashReason(Minidump *dump, u_int64_t *address); | |
| 136 | |
| 137 // This function returns true if the passed-in error code is | |
| 138 // something unrecoverable(i.e. retry should not happen). For | |
| 139 // instance, if the minidump is corrupt, then it makes no sense to | |
| 140 // retry as we won't be able to glean additional information. | |
| 141 // However, as an example of the other case, the symbol supplier can | |
| 142 // return an error code indicating it was 'interrupted', which can | |
| 143 // happen of the symbols are fetched from a remote store, and a | |
| 144 // retry might be successful later on. | |
| 145 // You should not call this method with PROCESS_OK! Test for | |
| 146 // that separately before calling this. | |
| 147 static bool IsErrorUnrecoverable(ProcessResult p) { | |
| 148 assert(p != PROCESS_OK); | |
| 149 return (p != PROCESS_SYMBOL_SUPPLIER_INTERRUPTED); | |
| 150 } | |
| 151 | |
| 152 // Returns a textual representation of an assertion included | |
| 153 // in the minidump. Returns an empty string if this information | |
| 154 // does not exist or cannot be determined. | |
| 155 static string GetAssertion(Minidump *dump); | |
| 156 | |
| 157 private: | |
| 158 SymbolSupplier *supplier_; | |
| 159 SourceLineResolverInterface *resolver_; | |
| 160 | |
| 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_; | |
| 165 }; | |
| 166 | |
| 167 } // namespace google_breakpad | |
| 168 | |
| 169 #endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__ | |
| OLD | NEW |