Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1007)

Side by Side Diff: snapshot/mac/mach_o_image_symbol_table_reader.cc

Issue 666483002: Create snapshot/mac and move some files from snapshot and util to there (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad/+/master
Patch Set: Move process_reader, process_types, and mach_o_image*_reader from util/mac to snapshot/mac Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « snapshot/mac/mach_o_image_symbol_table_reader.h ('k') | snapshot/mac/memory_snapshot_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "util/mac/mach_o_image_symbol_table_reader.h" 15 #include "snapshot/mac/mach_o_image_symbol_table_reader.h"
16 16
17 #include <mach-o/loader.h> 17 #include <mach-o/loader.h>
18 #include <mach-o/nlist.h> 18 #include <mach-o/nlist.h>
19 19
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "util/mac/checked_mach_address_range.h" 22 #include "util/mac/checked_mach_address_range.h"
23 #include "util/mach/task_memory.h" 23 #include "util/mach/task_memory.h"
24 24
25 namespace crashpad { 25 namespace crashpad {
(...skipping 10 matching lines...) Expand all
36 class MachOImageSymbolTableReaderInitializer { 36 class MachOImageSymbolTableReaderInitializer {
37 public: 37 public:
38 MachOImageSymbolTableReaderInitializer( 38 MachOImageSymbolTableReaderInitializer(
39 ProcessReader* process_reader, 39 ProcessReader* process_reader,
40 const MachOImageSegmentReader* linkedit_segment, 40 const MachOImageSegmentReader* linkedit_segment,
41 const std::string& module_info) 41 const std::string& module_info)
42 : module_info_(module_info), 42 : module_info_(module_info),
43 linkedit_range_(), 43 linkedit_range_(),
44 process_reader_(process_reader), 44 process_reader_(process_reader),
45 linkedit_segment_(linkedit_segment) { 45 linkedit_segment_(linkedit_segment) {
46 linkedit_range_.SetRange( 46 linkedit_range_.SetRange(process_reader_->Is64Bit(),
47 process_reader_, linkedit_segment->Address(), linkedit_segment->Size()); 47 linkedit_segment->Address(),
48 linkedit_segment->Size());
48 DCHECK(linkedit_range_.IsValid()); 49 DCHECK(linkedit_range_.IsValid());
49 } 50 }
50 51
51 ~MachOImageSymbolTableReaderInitializer() {} 52 ~MachOImageSymbolTableReaderInitializer() {}
52 53
53 //! \brief Reads the symbol table from another process. 54 //! \brief Reads the symbol table from another process.
54 //! 55 //!
55 //! \sa MachOImageSymbolTableReader::Initialize() 56 //! \sa MachOImageSymbolTableReader::Initialize()
56 bool Initialize(const process_types::symtab_command* symtab_command, 57 bool Initialize(const process_types::symtab_command* symtab_command,
57 const process_types::dysymtab_command* dysymtab_command, 58 const process_types::dysymtab_command* dysymtab_command,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 //! \param[in] tag A string that identifies the range being checked. This is 192 //! \param[in] tag A string that identifies the range being checked. This is
192 //! used only for logging. 193 //! used only for logging.
193 //! 194 //!
194 //! \return `true` if the range identified by \a address + \a size lies 195 //! \return `true` if the range identified by \a address + \a size lies
195 //! entirely within the `__LINKEDIT` segment. `false` if that range is 196 //! entirely within the `__LINKEDIT` segment. `false` if that range is
196 //! invalid, or if that range is not contained by the `__LINKEDIT` 197 //! invalid, or if that range is not contained by the `__LINKEDIT`
197 //! segment, with an appropriate message logged. 198 //! segment, with an appropriate message logged.
198 bool IsInLinkEditSegment(mach_vm_address_t address, 199 bool IsInLinkEditSegment(mach_vm_address_t address,
199 mach_vm_size_t size, 200 mach_vm_size_t size,
200 const char* tag) const { 201 const char* tag) const {
201 CheckedMachAddressRange subrange(process_reader_, address, size); 202 CheckedMachAddressRange subrange(process_reader_->Is64Bit(), address, size);
202 if (!subrange.IsValid()) { 203 if (!subrange.IsValid()) {
203 LOG(WARNING) << base::StringPrintf("invalid %s range (0x%llx + 0x%llx)", 204 LOG(WARNING) << base::StringPrintf("invalid %s range (0x%llx + 0x%llx)",
204 tag, 205 tag,
205 address, 206 address,
206 size) << module_info_; 207 size) << module_info_;
207 return false; 208 return false;
208 } 209 }
209 210
210 if (!linkedit_range_.ContainsRange(subrange)) { 211 if (!linkedit_range_.ContainsRange(subrange)) {
211 LOG(WARNING) << base::StringPrintf( 212 LOG(WARNING) << base::StringPrintf(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 266 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
266 267
267 const auto& iterator = external_defined_symbols_.find(name); 268 const auto& iterator = external_defined_symbols_.find(name);
268 if (iterator == external_defined_symbols_.end()) { 269 if (iterator == external_defined_symbols_.end()) {
269 return nullptr; 270 return nullptr;
270 } 271 }
271 return &iterator->second; 272 return &iterator->second;
272 } 273 }
273 274
274 } // namespace crashpad 275 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/mac/mach_o_image_symbol_table_reader.h ('k') | snapshot/mac/memory_snapshot_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698