OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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 #include "snapshot/mac/module_snapshot_mac.h" | 15 #include "snapshot/mac/module_snapshot_mac.h" |
16 | 16 |
17 #include <mach/mach.h> | 17 #include <mach/mach.h> |
18 #include <mach-o/loader.h> | 18 #include <mach-o/loader.h> |
19 | 19 |
20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
21 #include "snapshot/mac/mach_o_image_annotations_reader.h" | 21 #include "snapshot/mac/mach_o_image_annotations_reader.h" |
22 #include "snapshot/mac/mach_o_image_reader.h" | 22 #include "snapshot/mac/mach_o_image_reader.h" |
| 23 #include "util/misc/tri_state.h" |
23 #include "util/misc/uuid.h" | 24 #include "util/misc/uuid.h" |
24 #include "util/stdlib/strnlen.h" | 25 #include "util/stdlib/strnlen.h" |
25 | 26 |
26 namespace crashpad { | 27 namespace crashpad { |
27 namespace internal { | 28 namespace internal { |
28 | 29 |
29 ModuleSnapshotMac::ModuleSnapshotMac() | 30 ModuleSnapshotMac::ModuleSnapshotMac() |
30 : ModuleSnapshot(), | 31 : ModuleSnapshot(), |
31 name_(), | 32 name_(), |
32 timestamp_(0), | 33 timestamp_(0), |
(...skipping 15 matching lines...) Expand all Loading... |
48 timestamp_ = process_reader_module.timestamp; | 49 timestamp_ = process_reader_module.timestamp; |
49 mach_o_image_reader_ = process_reader_module.reader; | 50 mach_o_image_reader_ = process_reader_module.reader; |
50 if (!mach_o_image_reader_) { | 51 if (!mach_o_image_reader_) { |
51 return false; | 52 return false; |
52 } | 53 } |
53 | 54 |
54 INITIALIZATION_STATE_SET_VALID(initialized_); | 55 INITIALIZATION_STATE_SET_VALID(initialized_); |
55 return true; | 56 return true; |
56 } | 57 } |
57 | 58 |
| 59 void ModuleSnapshotMac::GetCrashpadOptions(CrashpadInfoClientOptions* options) { |
| 60 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 61 |
| 62 process_types::CrashpadInfo crashpad_info; |
| 63 if (!mach_o_image_reader_->GetCrashpadInfo(&crashpad_info)) { |
| 64 options->crashpad_handler_behavior = TriState::kUnset; |
| 65 options->system_crash_reporter_forwarding = TriState::kUnset; |
| 66 return; |
| 67 } |
| 68 |
| 69 options->crashpad_handler_behavior = |
| 70 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
| 71 crashpad_info.crashpad_handler_behavior); |
| 72 |
| 73 options->system_crash_reporter_forwarding = |
| 74 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
| 75 crashpad_info.system_crash_reporter_forwarding); |
| 76 } |
| 77 |
58 std::string ModuleSnapshotMac::Name() const { | 78 std::string ModuleSnapshotMac::Name() const { |
59 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 79 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
60 return name_; | 80 return name_; |
61 } | 81 } |
62 | 82 |
63 uint64_t ModuleSnapshotMac::Address() const { | 83 uint64_t ModuleSnapshotMac::Address() const { |
64 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 84 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
65 return mach_o_image_reader_->Address(); | 85 return mach_o_image_reader_->Address(); |
66 } | 86 } |
67 | 87 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 std::map<std::string, std::string> ModuleSnapshotMac::AnnotationsSimpleMap() | 165 std::map<std::string, std::string> ModuleSnapshotMac::AnnotationsSimpleMap() |
146 const { | 166 const { |
147 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 167 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
148 MachOImageAnnotationsReader annotations_reader( | 168 MachOImageAnnotationsReader annotations_reader( |
149 process_reader_, mach_o_image_reader_, name_); | 169 process_reader_, mach_o_image_reader_, name_); |
150 return annotations_reader.SimpleMap(); | 170 return annotations_reader.SimpleMap(); |
151 } | 171 } |
152 | 172 |
153 } // namespace internal | 173 } // namespace internal |
154 } // namespace crashpad | 174 } // namespace crashpad |
OLD | NEW |