| 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/mach_o_image_segment_reader.h" | 15 #include "snapshot/mac/mach_o_image_segment_reader.h" |
| 16 | 16 |
| 17 #include <mach-o/loader.h> | 17 #include <mach-o/loader.h> |
| 18 | 18 |
| 19 #include <utility> |
| 20 |
| 19 #include "base/logging.h" | 21 #include "base/logging.h" |
| 20 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 21 #include "snapshot/mac/process_reader.h" | 23 #include "snapshot/mac/process_reader.h" |
| 22 #include "util/mac/checked_mach_address_range.h" | 24 #include "util/mac/checked_mach_address_range.h" |
| 23 #include "util/mac/mac_util.h" | 25 #include "util/mac/mac_util.h" |
| 24 #include "util/stdlib/strnlen.h" | 26 #include "util/stdlib/strnlen.h" |
| 25 | 27 |
| 26 namespace crashpad { | 28 namespace crashpad { |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 "section type 0x%x at 0x%llx has unexpected offset " | 180 "section type 0x%x at 0x%llx has unexpected offset " |
| 179 "0x%x in segment at 0x%llx with offset 0x%llx", | 181 "0x%x in segment at 0x%llx with offset 0x%llx", |
| 180 section_type, | 182 section_type, |
| 181 section.addr, | 183 section.addr, |
| 182 section.offset, | 184 section.offset, |
| 183 segment_command_.vmaddr, | 185 segment_command_.vmaddr, |
| 184 segment_command_.fileoff) << section_info; | 186 segment_command_.fileoff) << section_info; |
| 185 return false; | 187 return false; |
| 186 } | 188 } |
| 187 | 189 |
| 188 const auto& iterator = section_map_.find(section_name); | 190 const auto insert_result = |
| 189 if (iterator != section_map_.end()) { | 191 section_map_.insert(std::make_pair(section_name, section_index)); |
| 192 if (!insert_result.second) { |
| 190 LOG(WARNING) << base::StringPrintf("duplicate section name at %zu", | 193 LOG(WARNING) << base::StringPrintf("duplicate section name at %zu", |
| 191 iterator->second) << section_info; | 194 insert_result.first->second) |
| 195 << section_info; |
| 192 return false; | 196 return false; |
| 193 } | 197 } |
| 194 | |
| 195 section_map_[section_name] = section_index; | |
| 196 } | 198 } |
| 197 | 199 |
| 198 INITIALIZATION_STATE_SET_VALID(initialized_); | 200 INITIALIZATION_STATE_SET_VALID(initialized_); |
| 199 return true; | 201 return true; |
| 200 } | 202 } |
| 201 | 203 |
| 202 std::string MachOImageSegmentReader::Name() const { | 204 std::string MachOImageSegmentReader::Name() const { |
| 203 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 205 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 204 return NameInternal(); | 206 return NameInternal(); |
| 205 } | 207 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 292 } |
| 291 | 293 |
| 292 void MachOImageSegmentReader::SetSlide(mach_vm_size_t slide) { | 294 void MachOImageSegmentReader::SetSlide(mach_vm_size_t slide) { |
| 293 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 295 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 294 INITIALIZATION_STATE_SET_INITIALIZING(initialized_slide_); | 296 INITIALIZATION_STATE_SET_INITIALIZING(initialized_slide_); |
| 295 slide_ = slide; | 297 slide_ = slide; |
| 296 INITIALIZATION_STATE_SET_VALID(initialized_slide_); | 298 INITIALIZATION_STATE_SET_VALID(initialized_slide_); |
| 297 } | 299 } |
| 298 | 300 |
| 299 } // namespace crashpad | 301 } // namespace crashpad |
| OLD | NEW |