• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
36 #include "common/using_std_string.h"
37 #include "google_breakpad/common/breakpad_types.h"
38 #include "google_breakpad/processor/process_result.h"
39 
40 namespace google_breakpad {
41 
42 class Minidump;
43 class ProcessState;
44 class StackFrameSymbolizer;
45 class SourceLineResolverInterface;
46 class SymbolSupplier;
47 struct SystemInfo;
48 
49 class MinidumpProcessor {
50  public:
51   // Initializes this MinidumpProcessor.  supplier should be an
52   // implementation of the SymbolSupplier abstract base class.
53   MinidumpProcessor(SymbolSupplier* supplier,
54                     SourceLineResolverInterface* resolver);
55 
56   // Initializes the MinidumpProcessor with the option of
57   // enabling the exploitability framework to analyze dumps
58   // for probable security relevance.
59   MinidumpProcessor(SymbolSupplier* supplier,
60                     SourceLineResolverInterface* resolver,
61                     bool enable_exploitability);
62 
63   // Initializes the MinidumpProcessor with source line resolver helper, and
64   // the option of enabling the exploitability framework to analyze dumps
65   // for probable security relevance.
66   // Does not take ownership of resolver_helper, which must NOT be NULL.
67   MinidumpProcessor(StackFrameSymbolizer* stack_frame_symbolizer,
68                     bool enable_exploitability);
69 
70   ~MinidumpProcessor();
71 
72   // Processes the minidump file and fills process_state with the result.
73   ProcessResult Process(const string &minidump_file,
74                         ProcessState* process_state);
75 
76   // Processes the minidump structure and fills process_state with the
77   // result.
78   ProcessResult Process(Minidump* minidump,
79                         ProcessState* process_state);
80   // Populates the cpu_* fields of the |info| parameter with textual
81   // representations of the CPU type that the minidump in |dump| was
82   // produced on.  Returns false if this information is not available in
83   // the minidump.
84   static bool GetCPUInfo(Minidump* dump, SystemInfo* info);
85 
86   // Populates the os_* fields of the |info| parameter with textual
87   // representations of the operating system that the minidump in |dump|
88   // was produced on.  Returns false if this information is not available in
89   // the minidump.
90   static bool GetOSInfo(Minidump* dump, SystemInfo* info);
91 
92   // Populates the |process_create_time| parameter with the create time of the
93   // crashed process.  Returns false if this information is not available in
94   // the minidump |dump|.
95   static bool GetProcessCreateTime(Minidump* dump,
96                                    uint32_t* process_create_time);
97 
98   // Returns a textual representation of the reason that a crash occurred,
99   // if the minidump in dump was produced as a result of a crash.  Returns
100   // an empty string if this information cannot be determined.  If address
101   // is non-NULL, it will be set to contain the address that caused the
102   // exception, if this information is available.  This will be a code
103   // address when the crash was caused by problems such as illegal
104   // instructions or divisions by zero, or a data address when the crash
105   // was caused by a memory access violation.
106   static string GetCrashReason(Minidump* dump, uint64_t* address);
107 
108   // This function returns true if the passed-in error code is
109   // something unrecoverable(i.e. retry should not happen).  For
110   // instance, if the minidump is corrupt, then it makes no sense to
111   // retry as we won't be able to glean additional information.
112   // However, as an example of the other case, the symbol supplier can
113   // return an error code indicating it was 'interrupted', which can
114   // happen of the symbols are fetched from a remote store, and a
115   // retry might be successful later on.
116   // You should not call this method with PROCESS_OK! Test for
117   // that separately before calling this.
IsErrorUnrecoverable(ProcessResult p)118   static bool IsErrorUnrecoverable(ProcessResult p) {
119     assert(p !=  PROCESS_OK);
120     return (p != PROCESS_SYMBOL_SUPPLIER_INTERRUPTED);
121   }
122 
123   // Returns a textual representation of an assertion included
124   // in the minidump.  Returns an empty string if this information
125   // does not exist or cannot be determined.
126   static string GetAssertion(Minidump* dump);
127 
set_enable_objdump(bool enabled)128   void set_enable_objdump(bool enabled) { enable_objdump_ = enabled; }
129 
130  private:
131   StackFrameSymbolizer* frame_symbolizer_;
132   // Indicate whether resolver_helper_ is owned by this instance.
133   bool own_frame_symbolizer_;
134 
135   // This flag enables the exploitability scanner which attempts to
136   // guess how likely it is that the crash represents an exploitable
137   // memory corruption issue.
138   bool enable_exploitability_;
139 
140   // This flag permits the exploitability scanner to shell out to objdump
141   // for purposes of disassembly.
142   bool enable_objdump_;
143 };
144 
145 }  // namespace google_breakpad
146 
147 #endif  // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
148