20277f9aaa3e6aa95c9db111ec94b2aa215f42cd
[platform/framework/web/crosswalk.git] / src / breakpad / src / google_breakpad / processor / minidump_processor.h
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   // Returns a textual representation of the reason that a crash occurred,
93   // if the minidump in dump was produced as a result of a crash.  Returns
94   // an empty string if this information cannot be determined.  If address
95   // is non-NULL, it will be set to contain the address that caused the
96   // exception, if this information is available.  This will be a code
97   // address when the crash was caused by problems such as illegal
98   // instructions or divisions by zero, or a data address when the crash
99   // was caused by a memory access violation.
100   static string GetCrashReason(Minidump* dump, uint64_t* address);
101
102   // This function returns true if the passed-in error code is
103   // something unrecoverable(i.e. retry should not happen).  For
104   // instance, if the minidump is corrupt, then it makes no sense to
105   // retry as we won't be able to glean additional information.
106   // However, as an example of the other case, the symbol supplier can
107   // return an error code indicating it was 'interrupted', which can
108   // happen of the symbols are fetched from a remote store, and a
109   // retry might be successful later on.
110   // You should not call this method with PROCESS_OK! Test for
111   // that separately before calling this.
112   static bool IsErrorUnrecoverable(ProcessResult p) {
113     assert(p !=  PROCESS_OK);
114     return (p != PROCESS_SYMBOL_SUPPLIER_INTERRUPTED);
115   }
116
117   // Returns a textual representation of an assertion included
118   // in the minidump.  Returns an empty string if this information
119   // does not exist or cannot be determined.
120   static string GetAssertion(Minidump* dump);
121
122  private:
123   StackFrameSymbolizer* frame_symbolizer_;
124   // Indicate whether resolver_helper_ is owned by this instance.
125   bool own_frame_symbolizer_;
126
127   // This flag enables the exploitability scanner which attempts to
128   // guess how likely it is that the crash represents an exploitable
129   // memory corruption issue.
130   bool enable_exploitability_;
131 };
132
133 }  // namespace google_breakpad
134
135 #endif  // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__