OLD | NEW |
---|---|
1 // Copyright 2015 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, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 sizeof(EXCEPTION_POINTERS), | 62 sizeof(EXCEPTION_POINTERS), |
63 &exception_pointers)) { | 63 &exception_pointers)) { |
64 LOG(ERROR) << "EXCEPTION_POINTERS read failed"; | 64 LOG(ERROR) << "EXCEPTION_POINTERS read failed"; |
65 return false; | 65 return false; |
66 } | 66 } |
67 if (!exception_pointers.ExceptionRecord) { | 67 if (!exception_pointers.ExceptionRecord) { |
68 LOG(ERROR) << "null ExceptionRecord"; | 68 LOG(ERROR) << "null ExceptionRecord"; |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 #if defined(ARCH_CPU_64_BITS) | |
72 if (process_reader->Is64Bit()) { | 73 if (process_reader->Is64Bit()) { |
73 EXCEPTION_RECORD64 first_record; | 74 EXCEPTION_RECORD64 first_record; |
74 if (!process_reader->ReadMemory( | 75 if (!process_reader->ReadMemory( |
75 reinterpret_cast<WinVMAddress>(exception_pointers.ExceptionRecord), | 76 reinterpret_cast<WinVMAddress>(exception_pointers.ExceptionRecord), |
76 sizeof(first_record), | 77 sizeof(first_record), |
77 &first_record)) { | 78 &first_record)) { |
78 LOG(ERROR) << "ExceptionRecord"; | 79 LOG(ERROR) << "ExceptionRecord"; |
79 return false; | 80 return false; |
80 } | 81 } |
81 exception_code_ = first_record.ExceptionCode; | 82 exception_code_ = first_record.ExceptionCode; |
(...skipping 16 matching lines...) Expand all Loading... | |
98 sizeof(context_record), | 99 sizeof(context_record), |
99 &context_record)) { | 100 &context_record)) { |
100 LOG(ERROR) << "ContextRecord"; | 101 LOG(ERROR) << "ContextRecord"; |
101 return false; | 102 return false; |
102 } | 103 } |
103 InitializeX64Context(context_record, context_.x86_64); | 104 InitializeX64Context(context_record, context_.x86_64); |
104 } else { | 105 } else { |
105 CHECK(false) << "TODO(scottmg) x86"; | 106 CHECK(false) << "TODO(scottmg) x86"; |
106 return false; | 107 return false; |
107 } | 108 } |
109 #else | |
110 EXCEPTION_RECORD32 first_record; | |
Mark Mentovai
2015/09/16 02:57:19
This is so similar to what’s above that it’s kind
scottmg
2015/09/16 18:05:06
Done.
| |
111 if (!process_reader->ReadMemory( | |
112 reinterpret_cast<WinVMAddress>(exception_pointers.ExceptionRecord), | |
113 sizeof(first_record), | |
114 &first_record)) { | |
115 LOG(ERROR) << "ExceptionRecord"; | |
116 return false; | |
117 } | |
118 exception_code_ = first_record.ExceptionCode; | |
119 exception_flags_ = first_record.ExceptionFlags; | |
120 exception_address_ = first_record.ExceptionAddress; | |
121 for (DWORD i = 0; i < first_record.NumberParameters; ++i) | |
122 codes_.push_back(first_record.ExceptionInformation[i]); | |
123 if (first_record.ExceptionRecord) { | |
124 // https://code.google.com/p/crashpad/issues/detail?id=43 | |
125 LOG(WARNING) << "dropping chained ExceptionRecord"; | |
126 } | |
127 | |
128 context_.architecture = kCPUArchitectureX86; | |
129 context_.x86 = &context_union_.x86; | |
130 // We assume 64-on-64 here in that we're relying on the CONTEXT definition | |
Mark Mentovai
2015/09/16 02:57:19
Well, the comment shouldn’t have been copied and p
scottmg
2015/09/16 18:05:06
Oops, I noticed that too, but forgot to upload the
| |
131 // to be the x64 one. | |
132 CONTEXT context_record; | |
133 if (!process_reader->ReadMemory( | |
134 reinterpret_cast<WinVMAddress>(exception_pointers.ContextRecord), | |
135 sizeof(context_record), | |
136 &context_record)) { | |
137 LOG(ERROR) << "ContextRecord"; | |
138 return false; | |
139 } | |
140 InitializeX86Context(context_record, context_.x86); | |
141 #endif // ARCH_CPU_64_BITS | |
108 | 142 |
109 INITIALIZATION_STATE_SET_VALID(initialized_); | 143 INITIALIZATION_STATE_SET_VALID(initialized_); |
110 return true; | 144 return true; |
111 } | 145 } |
112 | 146 |
113 const CPUContext* ExceptionSnapshotWin::Context() const { | 147 const CPUContext* ExceptionSnapshotWin::Context() const { |
114 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 148 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
115 return &context_; | 149 return &context_; |
116 } | 150 } |
117 | 151 |
(...skipping 17 matching lines...) Expand all Loading... | |
135 return exception_address_; | 169 return exception_address_; |
136 } | 170 } |
137 | 171 |
138 const std::vector<uint64_t>& ExceptionSnapshotWin::Codes() const { | 172 const std::vector<uint64_t>& ExceptionSnapshotWin::Codes() const { |
139 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 173 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
140 return codes_; | 174 return codes_; |
141 } | 175 } |
142 | 176 |
143 } // namespace internal | 177 } // namespace internal |
144 } // namespace crashpad | 178 } // namespace crashpad |
OLD | NEW |