| 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 #ifndef CRASHPAD_UTIL_MAC_MACH_O_IMAGE_READER_H_ | 15 #ifndef CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_READER_H_ |
| 16 #define CRASHPAD_UTIL_MAC_MACH_O_IMAGE_READER_H_ | 16 #define CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_READER_H_ |
| 17 | 17 |
| 18 #include <mach/mach.h> | 18 #include <mach/mach.h> |
| 19 #include <stdint.h> | 19 #include <stdint.h> |
| 20 | 20 |
| 21 #include <map> | 21 #include <map> |
| 22 #include <string> | 22 #include <string> |
| 23 | 23 |
| 24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
| 26 #include "snapshot/mac/process_types.h" |
| 26 #include "util/misc/initialization_state_dcheck.h" | 27 #include "util/misc/initialization_state_dcheck.h" |
| 27 #include "util/misc/uuid.h" | 28 #include "util/misc/uuid.h" |
| 28 #include "util/stdlib/pointer_container.h" | 29 #include "util/stdlib/pointer_container.h" |
| 29 #include "util/mac/process_types.h" | |
| 30 | 30 |
| 31 namespace crashpad { | 31 namespace crashpad { |
| 32 | 32 |
| 33 class MachOImageSegmentReader; | 33 class MachOImageSegmentReader; |
| 34 class MachOImageSymbolTableReader; | 34 class MachOImageSymbolTableReader; |
| 35 class ProcessReader; | 35 class ProcessReader; |
| 36 | 36 |
| 37 //! \brief A reader for Mach-O images mapped into another process. | 37 //! \brief A reader for Mach-O images mapped into another process. |
| 38 //! | 38 //! |
| 39 //! This class is capable of reading both 32-bit (`mach_header`/`MH_MAGIC`) and | 39 //! This class is capable of reading both 32-bit (`mach_header`/`MH_MAGIC`) and |
| 40 //! 64-bit (`mach_header_64`/`MH_MAGIC_64`) images based on the bitness of the | 40 //! 64-bit (`mach_header_64`/`MH_MAGIC_64`) images based on the bitness of the |
| 41 //! remote process. | 41 //! remote process. |
| 42 class MachOImageReader { | 42 class MachOImageReader { |
| 43 public: | 43 public: |
| 44 MachOImageReader(); | 44 MachOImageReader(); |
| 45 ~MachOImageReader(); | 45 ~MachOImageReader(); |
| 46 | 46 |
| 47 //! \brief Reads the Mach-O image file’s load commands from another process. | 47 //! \brief Reads the Mach-O image file’s load commands from another process. |
| 48 //! | 48 //! |
| 49 //! This method must only be called once on an object. This method must be | 49 //! This method must only be called once on an object. This method must be |
| 50 //! called successfully before any other method in this class may be called. | 50 //! called successfully before any other method in this class may be called. |
| 51 //! | 51 //! |
| 52 //! \param[in] process_reader The reader for the remote process. | 52 //! \param[in] process_reader The reader for the remote process. |
| 53 //! \param[in] address The address, in the remote process’ address space, | 53 //! \param[in] address The address, in the remote process’ address space, |
| 54 //! where the `mach_header` or `mach_header_64` at the beginning of the | 54 //! where the `mach_header` or `mach_header_64` at the beginning of the |
| 55 //! image to be read is located. This address can be determined by reading | 55 //! image to be read is located. This address can be determined by reading |
| 56 //! the remote process’ dyld information (see | 56 //! the remote process’ dyld information (see |
| 57 //! util/mac/process_types/dyld_images.proctype). | 57 //! snapshot/mac/process_types/dyld_images.proctype). |
| 58 //! \param[in] name The module’s name, a string to be used in logged messages. | 58 //! \param[in] name The module’s name, a string to be used in logged messages. |
| 59 //! This string is for diagnostic purposes only, and may be empty. | 59 //! This string is for diagnostic purposes only, and may be empty. |
| 60 //! | 60 //! |
| 61 //! \return `true` if the image was read successfully, including all load | 61 //! \return `true` if the image was read successfully, including all load |
| 62 //! commands. `false` otherwise, with an appropriate message logged. | 62 //! commands. `false` otherwise, with an appropriate message logged. |
| 63 bool Initialize(ProcessReader* process_reader, | 63 bool Initialize(ProcessReader* process_reader, |
| 64 mach_vm_address_t address, | 64 mach_vm_address_t address, |
| 65 const std::string& name); | 65 const std::string& name); |
| 66 | 66 |
| 67 //! \brief Returns the Mach-O file type. | 67 //! \brief Returns the Mach-O file type. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // symbol_table_initialized_ being valid doesn’t imply that symbol_table_ is | 333 // symbol_table_initialized_ being valid doesn’t imply that symbol_table_ is |
| 334 // set. symbol_table_initialized_ will be valid without symbol_table_ being | 334 // set. symbol_table_initialized_ will be valid without symbol_table_ being |
| 335 // set in modules that have no symbol table. | 335 // set in modules that have no symbol table. |
| 336 mutable InitializationState symbol_table_initialized_; | 336 mutable InitializationState symbol_table_initialized_; |
| 337 | 337 |
| 338 DISALLOW_COPY_AND_ASSIGN(MachOImageReader); | 338 DISALLOW_COPY_AND_ASSIGN(MachOImageReader); |
| 339 }; | 339 }; |
| 340 | 340 |
| 341 } // namespace crashpad | 341 } // namespace crashpad |
| 342 | 342 |
| 343 #endif // CRASHPAD_UTIL_MAC_MACH_O_IMAGE_READER_H_ | 343 #endif // CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_READER_H_ |
| OLD | NEW |