| 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 "util/mac/process_types.h" | 15 #include "snapshot/mac/process_types.h" |
| 16 | 16 |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 #include <uuid/uuid.h> | 18 #include <uuid/uuid.h> |
| 19 | 19 |
| 20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "util/mac/process_types/internal.h" | 21 #include "snapshot/mac/process_types/internal.h" |
| 22 #include "util/mach/task_memory.h" | 22 #include "util/mach/task_memory.h" |
| 23 | 23 |
| 24 namespace crashpad { | 24 namespace crashpad { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Assign() is used by each flavor's ReadInto implementation to copy data from a | 27 // Assign() is used by each flavor's ReadInto implementation to copy data from a |
| 28 // specific struct to a generic struct. For fundamental types, the assignment | 28 // specific struct to a generic struct. For fundamental types, the assignment |
| 29 // operator suffices. For other types such as arrays, an explicit Assign | 29 // operator suffices. For other types such as arrays, an explicit Assign |
| 30 // specialization is needed, typically performing a copy. | 30 // specialization is needed, typically performing a copy. |
| 31 | 31 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ | 129 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ |
| 130 Assign(&generic->member_name, member_name); | 130 Assign(&generic->member_name, member_name); |
| 131 | 131 |
| 132 #define PROCESS_TYPE_STRUCT_END(struct_name) \ | 132 #define PROCESS_TYPE_STRUCT_END(struct_name) \ |
| 133 } \ | 133 } \ |
| 134 } /* namespace internal */ \ | 134 } /* namespace internal */ \ |
| 135 } /* namespace process_types */ \ | 135 } /* namespace process_types */ \ |
| 136 } /* namespace crashpad */ | 136 } /* namespace crashpad */ |
| 137 | 137 |
| 138 #include "util/mac/process_types/all.proctype" | 138 #include "snapshot/mac/process_types/all.proctype" |
| 139 | 139 |
| 140 #undef PROCESS_TYPE_STRUCT_BEGIN | 140 #undef PROCESS_TYPE_STRUCT_BEGIN |
| 141 #undef PROCESS_TYPE_STRUCT_MEMBER | 141 #undef PROCESS_TYPE_STRUCT_MEMBER |
| 142 #undef PROCESS_TYPE_STRUCT_END | 142 #undef PROCESS_TYPE_STRUCT_END |
| 143 #undef PROCESS_TYPE_STRUCT_IMPLEMENT | 143 #undef PROCESS_TYPE_STRUCT_IMPLEMENT |
| 144 | 144 |
| 145 // Implement the specific crashpad::process_types::internal::struct_name<> | 145 // Implement the specific crashpad::process_types::internal::struct_name<> |
| 146 // ReadInto(). The default implementation simply reads the struct from the | 146 // ReadInto(). The default implementation simply reads the struct from the |
| 147 // remote process. This is separated from other method implementations because | 147 // remote process. This is separated from other method implementations because |
| 148 // some types may wish to provide custom readers. This can be done by guarding | 148 // some types may wish to provide custom readers. This can be done by guarding |
| 149 // such types’ proctype definitions against this macro and providing custom | 149 // such types’ proctype definitions against this macro and providing custom |
| 150 // implementations in util/mac/process_types/custom.cc. | 150 // implementations in snapshot/mac/process_types/custom.cc. |
| 151 #define PROCESS_TYPE_STRUCT_IMPLEMENT_INTERNAL_READ_INTO 1 | 151 #define PROCESS_TYPE_STRUCT_IMPLEMENT_INTERNAL_READ_INTO 1 |
| 152 | 152 |
| 153 #define PROCESS_TYPE_STRUCT_BEGIN(struct_name) \ | 153 #define PROCESS_TYPE_STRUCT_BEGIN(struct_name) \ |
| 154 namespace crashpad { \ | 154 namespace crashpad { \ |
| 155 namespace process_types { \ | 155 namespace process_types { \ |
| 156 namespace internal { \ | 156 namespace internal { \ |
| 157 \ | 157 \ |
| 158 template <typename Traits> \ | 158 template <typename Traits> \ |
| 159 bool struct_name<Traits>::ReadInto(ProcessReader* process_reader, \ | 159 bool struct_name<Traits>::ReadInto(ProcessReader* process_reader, \ |
| 160 mach_vm_address_t address, \ | 160 mach_vm_address_t address, \ |
| 161 struct_name<Traits>* specific) { \ | 161 struct_name<Traits>* specific) { \ |
| 162 return process_reader->Memory()->Read( \ | 162 return process_reader->Memory()->Read( \ |
| 163 address, sizeof(*specific), specific); \ | 163 address, sizeof(*specific), specific); \ |
| 164 } \ | 164 } \ |
| 165 } /* namespace internal */ \ | 165 } /* namespace internal */ \ |
| 166 } /* namespace process_types */ \ | 166 } /* namespace process_types */ \ |
| 167 } /* namespace crashpad */ | 167 } /* namespace crashpad */ |
| 168 | 168 |
| 169 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) | 169 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) |
| 170 | 170 |
| 171 #define PROCESS_TYPE_STRUCT_END(struct_name) | 171 #define PROCESS_TYPE_STRUCT_END(struct_name) |
| 172 | 172 |
| 173 #include "util/mac/process_types/all.proctype" | 173 #include "snapshot/mac/process_types/all.proctype" |
| 174 | 174 |
| 175 #undef PROCESS_TYPE_STRUCT_BEGIN | 175 #undef PROCESS_TYPE_STRUCT_BEGIN |
| 176 #undef PROCESS_TYPE_STRUCT_MEMBER | 176 #undef PROCESS_TYPE_STRUCT_MEMBER |
| 177 #undef PROCESS_TYPE_STRUCT_END | 177 #undef PROCESS_TYPE_STRUCT_END |
| 178 #undef PROCESS_TYPE_STRUCT_IMPLEMENT_INTERNAL_READ_INTO | 178 #undef PROCESS_TYPE_STRUCT_IMPLEMENT_INTERNAL_READ_INTO |
| 179 | 179 |
| 180 // Implement the array operations. These are separated from other method | 180 // Implement the array operations. These are separated from other method |
| 181 // implementations because some types are variable-length and are never stored | 181 // implementations because some types are variable-length and are never stored |
| 182 // as direct-access arrays. It would be incorrect to provide reader | 182 // as direct-access arrays. It would be incorrect to provide reader |
| 183 // implementations for such types. Types that wish to suppress array operations | 183 // implementations for such types. Types that wish to suppress array operations |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } \ | 229 } \ |
| 230 return true; \ | 230 return true; \ |
| 231 } \ | 231 } \ |
| 232 } /* namespace process_types */ \ | 232 } /* namespace process_types */ \ |
| 233 } /* namespace crashpad */ | 233 } /* namespace crashpad */ |
| 234 | 234 |
| 235 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) | 235 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) |
| 236 | 236 |
| 237 #define PROCESS_TYPE_STRUCT_END(struct_name) | 237 #define PROCESS_TYPE_STRUCT_END(struct_name) |
| 238 | 238 |
| 239 #include "util/mac/process_types/all.proctype" | 239 #include "snapshot/mac/process_types/all.proctype" |
| 240 | 240 |
| 241 #undef PROCESS_TYPE_STRUCT_BEGIN | 241 #undef PROCESS_TYPE_STRUCT_BEGIN |
| 242 #undef PROCESS_TYPE_STRUCT_MEMBER | 242 #undef PROCESS_TYPE_STRUCT_MEMBER |
| 243 #undef PROCESS_TYPE_STRUCT_END | 243 #undef PROCESS_TYPE_STRUCT_END |
| 244 #undef PROCESS_TYPE_STRUCT_IMPLEMENT_ARRAY | 244 #undef PROCESS_TYPE_STRUCT_IMPLEMENT_ARRAY |
| OLD | NEW |