Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / breakpad / src / google_breakpad / processor / process_state.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 // process_state.h: A snapshot of a process, in a fully-digested state.
31 //
32 // Author: Mark Mentovai
33
34 #ifndef GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
35 #define GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
36
37 #include <string>
38 #include <vector>
39
40 #include "common/using_std_string.h"
41 #include "google_breakpad/common/breakpad_types.h"
42 #include "google_breakpad/processor/system_info.h"
43 #include "google_breakpad/processor/minidump.h"
44
45 namespace google_breakpad {
46
47 using std::vector;
48
49 class CallStack;
50 class CodeModules;
51
52 enum ExploitabilityRating {
53   EXPLOITABILITY_HIGH,                 // The crash likely represents
54                                        // a exploitable memory corruption
55                                        // vulnerability.
56
57   EXPLOITABILITY_MEDIUM,               // The crash appears to corrupt
58                                        // memory in a way which may be
59                                        // exploitable in some situations.
60
61   EXPLOITABLITY_MEDIUM = EXPLOITABILITY_MEDIUM,  // an old misspelling
62
63   EXPLOITABILITY_LOW,                  // The crash either does not corrupt
64                                        // memory directly or control over
65                                        // the affected data is limited. The
66                                        // issue may still be exploitable
67                                        // on certain platforms or situations.
68
69   EXPLOITABILITY_INTERESTING,          // The crash does not appear to be
70                                        // directly exploitable. However it
71                                        // represents a condition which should
72                                        // be further analyzed.
73
74   EXPLOITABILITY_NONE,                 // The crash does not appear to represent
75                                        // an exploitable condition.
76
77   EXPLOITABILITY_NOT_ANALYZED,         // The crash was not analyzed for
78                                        // exploitability because the engine
79                                        // was disabled.
80
81   EXPLOITABILITY_ERR_NOENGINE,         // The supplied minidump's platform does
82                                        // not have a exploitability engine
83                                        // associated with it.
84
85   EXPLOITABILITY_ERR_PROCESSING        // An error occured within the
86                                        // exploitability engine and no rating
87                                        // was calculated.
88 };
89
90 class ProcessState {
91  public:
92   ProcessState() : modules_(NULL) { Clear(); }
93   ~ProcessState();
94
95   // Resets the ProcessState to its default values
96   void Clear();
97
98   // Accessors.  See the data declarations below.
99   uint32_t time_date_stamp() const { return time_date_stamp_; }
100   bool crashed() const { return crashed_; }
101   string crash_reason() const { return crash_reason_; }
102   uint64_t crash_address() const { return crash_address_; }
103   string assertion() const { return assertion_; }
104   int requesting_thread() const { return requesting_thread_; }
105   const vector<CallStack*>* threads() const { return &threads_; }
106   const vector<MemoryRegion*>* thread_memory_regions() const {
107     return &thread_memory_regions_;
108   }
109   const SystemInfo* system_info() const { return &system_info_; }
110   const CodeModules* modules() const { return modules_; }
111   const vector<const CodeModule*>* modules_without_symbols() const {
112     return &modules_without_symbols_;
113   }
114   const vector<const CodeModule*>* modules_with_corrupt_symbols() const {
115     return &modules_with_corrupt_symbols_;
116   }
117   ExploitabilityRating exploitability() const { return exploitability_; }
118
119  private:
120   // MinidumpProcessor is responsible for building ProcessState objects.
121   friend class MinidumpProcessor;
122
123   // The time-date stamp of the minidump (time_t format)
124   uint32_t time_date_stamp_;
125
126   // True if the process crashed, false if the dump was produced outside
127   // of an exception handler.
128   bool crashed_;
129
130   // If the process crashed, the type of crash.  OS- and possibly CPU-
131   // specific.  For example, "EXCEPTION_ACCESS_VIOLATION" (Windows),
132   // "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS" (Mac OS X), "SIGSEGV"
133   // (other Unix).
134   string crash_reason_;
135
136   // If the process crashed, and if crash_reason implicates memory,
137   // the memory address that caused the crash.  For data access errors,
138   // this will be the data address that caused the fault.  For code errors,
139   // this will be the address of the instruction that caused the fault.
140   uint64_t crash_address_;
141
142   // If there was an assertion that was hit, a textual representation
143   // of that assertion, possibly including the file and line at which
144   // it occurred.
145   string assertion_;
146
147   // The index of the thread that requested a dump be written in the
148   // threads vector.  If a dump was produced as a result of a crash, this
149   // will point to the thread that crashed.  If the dump was produced as
150   // by user code without crashing, and the dump contains extended Breakpad
151   // information, this will point to the thread that requested the dump.
152   // If the dump was not produced as a result of an exception and no
153   // extended Breakpad information is present, this field will be set to -1,
154   // indicating that the dump thread is not available.
155   int requesting_thread_;
156
157   // Stacks for each thread (except possibly the exception handler
158   // thread) at the time of the crash.
159   vector<CallStack*> threads_;
160   vector<MemoryRegion*> thread_memory_regions_;
161
162   // OS and CPU information.
163   SystemInfo system_info_;
164
165   // The modules that were loaded into the process represented by the
166   // ProcessState.
167   const CodeModules *modules_;
168
169   // The modules that didn't have symbols when the report was processed.
170   vector<const CodeModule*> modules_without_symbols_;
171
172   // The modules that had corrupt symbols when the report was processed.
173   vector<const CodeModule*> modules_with_corrupt_symbols_;
174
175   // The exploitability rating as determined by the exploitability
176   // engine. When the exploitability engine is not enabled this
177   // defaults to EXPLOITABILITY_NONE.
178   ExploitabilityRating exploitability_;
179 };
180
181 }  // namespace google_breakpad
182
183 #endif  // GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__