| 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 17 matching lines...) Expand all Loading... |
| 28 #include "util/mac/process_types.h" | 28 #include "util/mac/process_types.h" |
| 29 #include "util/misc/scoped_forbid_return.h" | 29 #include "util/misc/scoped_forbid_return.h" |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 void MachTimeValueToTimeval(const time_value& mach, timeval* tv) { | 33 void MachTimeValueToTimeval(const time_value& mach, timeval* tv) { |
| 34 tv->tv_sec = mach.seconds; | 34 tv->tv_sec = mach.seconds; |
| 35 tv->tv_usec = mach.microseconds; | 35 tv->tv_usec = mach.microseconds; |
| 36 } | 36 } |
| 37 | 37 |
| 38 kern_return_t MachVMRegionRecurseDeepest(mach_port_t task, | 38 kern_return_t MachVMRegionRecurseDeepest(task_t task, |
| 39 mach_vm_address_t* address, | 39 mach_vm_address_t* address, |
| 40 mach_vm_size_t* size, | 40 mach_vm_size_t* size, |
| 41 natural_t* depth, | 41 natural_t* depth, |
| 42 vm_prot_t* protection, | 42 vm_prot_t* protection, |
| 43 unsigned int* user_tag) { | 43 unsigned int* user_tag) { |
| 44 vm_region_submap_short_info_64 submap_info; | 44 vm_region_submap_short_info_64 submap_info; |
| 45 mach_msg_type_number_t count = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64; | 45 mach_msg_type_number_t count = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64; |
| 46 while (true) { | 46 while (true) { |
| 47 kern_return_t kr = mach_vm_region_recurse( | 47 kern_return_t kr = mach_vm_region_recurse( |
| 48 task, | 48 task, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 initialized_modules_(false) { | 100 initialized_modules_(false) { |
| 101 } | 101 } |
| 102 | 102 |
| 103 ProcessReader::~ProcessReader() { | 103 ProcessReader::~ProcessReader() { |
| 104 for (const Thread& thread : threads_) { | 104 for (const Thread& thread : threads_) { |
| 105 kern_return_t kr = mach_port_deallocate(mach_task_self(), thread.port); | 105 kern_return_t kr = mach_port_deallocate(mach_task_self(), thread.port); |
| 106 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) << "mach_port_deallocate"; | 106 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) << "mach_port_deallocate"; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 bool ProcessReader::Initialize(mach_port_t task) { | 110 bool ProcessReader::Initialize(task_t task) { |
| 111 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 111 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
| 112 | 112 |
| 113 pid_t pid; | 113 pid_t pid; |
| 114 kern_return_t kr = pid_for_task(task, &pid); | 114 kern_return_t kr = pid_for_task(task, &pid); |
| 115 if (kr != KERN_SUCCESS) { | 115 if (kr != KERN_SUCCESS) { |
| 116 MACH_LOG(ERROR, kr) << "pid_for_task"; | 116 MACH_LOG(ERROR, kr) << "pid_for_task"; |
| 117 return false; | 117 return false; |
| 118 } | 118 } |
| 119 | 119 |
| 120 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}; | 120 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}; |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 // The red zone would go lower into another region in memory, but no | 631 // The red zone would go lower into another region in memory, but no |
| 632 // region was found. Memory can only be captured to an address as low as | 632 // region was found. Memory can only be captured to an address as low as |
| 633 // the base address of the region already found. | 633 // the base address of the region already found. |
| 634 *start_address = *region_base; | 634 *start_address = *region_base; |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 #endif | 637 #endif |
| 638 } | 638 } |
| 639 | 639 |
| 640 } // namespace crashpad | 640 } // namespace crashpad |
| OLD | NEW |