OLD | NEW |
---|---|
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef CRASHPAD_SNAPSHOT_MAC_EXCEPTION_SNAPSHOT_MAC_H_ | 15 #ifndef CRASHPAD_SNAPSHOT_WIN_EXCEPTION_SNAPSHOT_WIN_H_ |
16 #define CRASHPAD_SNAPSHOT_MAC_EXCEPTION_SNAPSHOT_MAC_H_ | 16 #define CRASHPAD_SNAPSHOT_WIN_EXCEPTION_SNAPSHOT_WIN_H_ |
17 | 17 |
18 #include <mach/mach.h> | |
19 #include <stdint.h> | 18 #include <stdint.h> |
20 | 19 #include <windows.h> |
21 #include <vector> | |
22 | 20 |
23 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
24 #include "build/build_config.h" | 22 #include "build/build_config.h" |
25 #include "snapshot/cpu_context.h" | 23 #include "snapshot/cpu_context.h" |
26 #include "snapshot/exception_snapshot.h" | 24 #include "snapshot/exception_snapshot.h" |
27 #include "util/mach/mach_extensions.h" | |
28 #include "util/misc/initialization_state_dcheck.h" | 25 #include "util/misc/initialization_state_dcheck.h" |
26 #include "util/win/address_types.h" | |
29 | 27 |
30 namespace crashpad { | 28 namespace crashpad { |
31 | 29 |
32 class ProcessReader; | 30 class ProcessReaderWin; |
33 | 31 |
34 namespace internal { | 32 namespace internal { |
35 | 33 |
36 //! \brief An ExceptionSnapshot of an exception sustained by a running (or | 34 class ExceptionSnapshotWin final : public ExceptionSnapshot { |
37 //! crashed) process on a Mac OS X system. | |
38 class ExceptionSnapshotMac final : public ExceptionSnapshot { | |
39 public: | 35 public: |
40 ExceptionSnapshotMac(); | 36 ExceptionSnapshotWin(); |
41 ~ExceptionSnapshotMac() override; | 37 ~ExceptionSnapshotWin() override; |
42 | 38 |
43 //! \brief Initializes the object. | 39 //! \brief Initializes the object. |
44 //! | 40 //! |
45 //! Other than \a process_reader, the parameters may be passed directly | |
46 //! through from a Mach exception handler. | |
47 //! | |
48 //! \param[in] process_reader A ProcessReader for the task that sustained the | 41 //! \param[in] process_reader A ProcessReader for the task that sustained the |
Mark Mentovai
2015/08/18 16:17:19
Is “task” the right nomenclature on Windows?
scottmg
2015/08/18 16:56:00
Done.
| |
49 //! exception. | 42 //! exception. |
43 //! \param[in] thread_id The thread id in which the exception occurred. | |
Mark Mentovai
2015/08/18 16:17:20
Nits: ID here, `EXCEPTION_POINTERS` on the next li
scottmg
2015/08/18 16:56:00
Done.
| |
44 //! \param[in] exception_pointers_address The address of an EXCEPTION_POINTERS | |
45 //! record in the target process, passed through from the exception | |
46 //! handler. | |
50 //! | 47 //! |
51 //! \return `true` if the snapshot could be created, `false` otherwise with | 48 //! \return `true` if the snapshot could be created, `false` otherwise with |
52 //! an appropriate message logged. | 49 //! an appropriate message logged. |
53 bool Initialize(ProcessReader* process_reader, | 50 bool Initialize(ProcessReaderWin* process_reader, |
54 exception_behavior_t behavior, | 51 DWORD thread_id, |
55 thread_t exception_thread, | 52 WinVMAddress exception_pointers); |
56 exception_type_t exception, | |
57 const mach_exception_data_type_t* code, | |
58 mach_msg_type_number_t code_count, | |
59 thread_state_flavor_t flavor, | |
60 ConstThreadState state, | |
61 mach_msg_type_number_t state_count); | |
62 | 53 |
63 // ExceptionSnapshot: | 54 // ExceptionSnapshot: |
64 | 55 |
65 const CPUContext* Context() const override; | 56 const CPUContext* Context() const override; |
66 uint64_t ThreadID() const override; | 57 uint64_t ThreadID() const override; |
67 uint32_t Exception() const override; | 58 uint32_t Exception() const override; |
68 uint32_t ExceptionInfo() const override; | 59 uint32_t ExceptionInfo() const override; |
69 uint64_t ExceptionAddress() const override; | 60 uint64_t ExceptionAddress() const override; |
70 const std::vector<uint64_t>& Codes() const override; | 61 const std::vector<uint64_t>& Codes() const override; |
71 | 62 |
72 private: | 63 private: |
73 #if defined(ARCH_CPU_X86_FAMILY) | 64 #if defined(ARCH_CPU_X86_FAMILY) |
74 union { | 65 union { |
75 CPUContextX86 x86; | 66 CPUContextX86 x86; |
76 CPUContextX86_64 x86_64; | 67 CPUContextX86_64 x86_64; |
77 } context_union_; | 68 } context_union_; |
78 #endif | 69 #endif |
79 CPUContext context_; | 70 CPUContext context_; |
80 std::vector<uint64_t> codes_; | 71 std::vector<uint64_t> codes_; |
81 uint64_t thread_id_; | 72 uint64_t thread_id_; |
82 uint64_t exception_address_; | 73 uint64_t exception_address_; |
83 exception_type_t exception_; | 74 uint32_t exception_flags_; |
84 uint32_t exception_code_0_; | 75 DWORD exception_code_; |
85 InitializationStateDcheck initialized_; | 76 InitializationStateDcheck initialized_; |
86 | 77 |
87 DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotMac); | 78 DISALLOW_COPY_AND_ASSIGN(ExceptionSnapshotWin); |
88 }; | 79 }; |
89 | 80 |
90 } // namespace internal | 81 } // namespace internal |
91 } // namespace crashpad | 82 } // namespace crashpad |
92 | 83 |
93 #endif // CRASHPAD_SNAPSHOT_MAC_EXCEPTION_SNAPSHOT_MAC_H_ | 84 #endif // CRASHPAD_SNAPSHOT_WIN_EXCEPTION_SNAPSHOT_WIN_H_ |
OLD | NEW |