| 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, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include <time.h> | 22 #include <time.h> |
| 23 | 23 |
| 24 #include <string> | 24 #include <string> |
| 25 #include <vector> | 25 #include <vector> |
| 26 | 26 |
| 27 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
| 28 #include "base/memory/scoped_ptr.h" | 28 #include "base/memory/scoped_ptr.h" |
| 29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 30 #include "util/mach/task_memory.h" | 30 #include "util/mach/task_memory.h" |
| 31 #include "util/misc/initialization_state_dcheck.h" | 31 #include "util/misc/initialization_state_dcheck.h" |
| 32 #include "util/stdlib/pointer_container.h" |
| 32 | 33 |
| 33 namespace crashpad { | 34 namespace crashpad { |
| 34 | 35 |
| 36 class MachOImageReader; |
| 37 |
| 35 //! \brief Accesses information about another process, identified by a Mach | 38 //! \brief Accesses information about another process, identified by a Mach |
| 36 //! task. | 39 //! task. |
| 37 class ProcessReader { | 40 class ProcessReader { |
| 38 public: | 41 public: |
| 39 //! \brief Contains information about a thread that belongs to a task | 42 //! \brief Contains information about a thread that belongs to a task |
| 40 //! (process). | 43 //! (process). |
| 41 struct Thread { | 44 struct Thread { |
| 42 #if defined(ARCH_CPU_X86_FAMILY) | 45 #if defined(ARCH_CPU_X86_FAMILY) |
| 43 union ThreadContext { | 46 union ThreadContext { |
| 44 x86_thread_state64_t t64; | 47 x86_thread_state64_t t64; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 }; | 73 }; |
| 71 | 74 |
| 72 //! \brief Contains information about a module loaded into a process. | 75 //! \brief Contains information about a module loaded into a process. |
| 73 struct Module { | 76 struct Module { |
| 74 Module(); | 77 Module(); |
| 75 ~Module(); | 78 ~Module(); |
| 76 | 79 |
| 77 //! \brief The pathname used to load the module from disk. | 80 //! \brief The pathname used to load the module from disk. |
| 78 std::string name; | 81 std::string name; |
| 79 | 82 |
| 80 //! \brief The address where the base of the module is loaded in the remote | 83 //! \brief An image reader for the module. |
| 81 //! process. | 84 //! |
| 82 mach_vm_address_t address; | 85 //! The lifetime of this MachOImageReader is scoped to the lifetime of the |
| 86 //! ProcessReader that created it. |
| 87 const MachOImageReader* reader; |
| 83 | 88 |
| 84 //! \brief The module’s timestamp. | 89 //! \brief The module’s timestamp. |
| 85 //! | 90 //! |
| 86 //! This field will be `0` if its value cannot be determined. It can only be | 91 //! This field will be `0` if its value cannot be determined. It can only be |
| 87 //! determined for images that are loaded by dyld, so it will be `0` for the | 92 //! determined for images that are loaded by dyld, so it will be `0` for the |
| 88 //! main executable and for dyld itself. | 93 //! main executable and for dyld itself. |
| 89 time_t timestamp; | 94 time_t timestamp; |
| 90 }; | 95 }; |
| 91 | 96 |
| 92 ProcessReader(); | 97 ProcessReader(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 //! these initial values if the user tag is appropriate for stack memory | 202 //! these initial values if the user tag is appropriate for stack memory |
| 198 //! and the expanded region has the same user tag value. | 203 //! and the expanded region has the same user tag value. |
| 199 void LocateRedZone(mach_vm_address_t* start_address, | 204 void LocateRedZone(mach_vm_address_t* start_address, |
| 200 mach_vm_address_t* region_base, | 205 mach_vm_address_t* region_base, |
| 201 mach_vm_address_t* region_size, | 206 mach_vm_address_t* region_size, |
| 202 unsigned int user_tag); | 207 unsigned int user_tag); |
| 203 | 208 |
| 204 kinfo_proc kern_proc_info_; | 209 kinfo_proc kern_proc_info_; |
| 205 std::vector<Thread> threads_; // owns send rights | 210 std::vector<Thread> threads_; // owns send rights |
| 206 std::vector<Module> modules_; | 211 std::vector<Module> modules_; |
| 212 PointerVector<MachOImageReader> module_readers_; |
| 207 scoped_ptr<TaskMemory> task_memory_; | 213 scoped_ptr<TaskMemory> task_memory_; |
| 208 task_t task_; // weak | 214 task_t task_; // weak |
| 209 InitializationStateDcheck initialized_; | 215 InitializationStateDcheck initialized_; |
| 210 | 216 |
| 211 // This shadows a bit in kern_proc_info_, but it’s accessed so frequently that | 217 // This shadows a bit in kern_proc_info_, but it’s accessed so frequently that |
| 212 // it’s given a first-class field to save a few bit operations on each access. | 218 // it’s given a first-class field to save a few bit operations on each access. |
| 213 bool is_64_bit_; | 219 bool is_64_bit_; |
| 214 | 220 |
| 215 bool initialized_threads_; | 221 bool initialized_threads_; |
| 216 bool initialized_modules_; | 222 bool initialized_modules_; |
| 217 | 223 |
| 218 DISALLOW_COPY_AND_ASSIGN(ProcessReader); | 224 DISALLOW_COPY_AND_ASSIGN(ProcessReader); |
| 219 }; | 225 }; |
| 220 | 226 |
| 221 } // namespace crashpad | 227 } // namespace crashpad |
| 222 | 228 |
| 223 #endif // CRASHPAD_UTIL_MAC_PROCESS_READER_H_ | 229 #endif // CRASHPAD_UTIL_MAC_PROCESS_READER_H_ |
| OLD | NEW |