| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 struct_name* generic); \ | 78 struct_name* generic); \ |
| 79 \ | 79 \ |
| 80 /* Returns the size of the object that was read. This is the size of the \ | 80 /* Returns the size of the object that was read. This is the size of the \ |
| 81 * storage in the process that the data is read from, and is not the same \ | 81 * storage in the process that the data is read from, and is not the same \ |
| 82 * as the size of the generic struct. */ \ | 82 * as the size of the generic struct. */ \ |
| 83 size_t Size() const { return size_; } \ | 83 size_t Size() const { return size_; } \ |
| 84 \ | 84 \ |
| 85 /* Similar to Size(), but computes the expected size of a structure based \ | 85 /* Similar to Size(), but computes the expected size of a structure based \ |
| 86 * on the process’ bitness. This can be used prior to reading any data \ | 86 * on the process’ bitness. This can be used prior to reading any data \ |
| 87 * from a process. */ \ | 87 * from a process. */ \ |
| 88 static size_t ExpectedSize(ProcessReader* process_reader); | 88 static size_t ExpectedSize(ProcessReader* process_reader); \ |
| 89 \ |
| 90 /* Similar to ExpectedSize(), but computes the expected size of a \ |
| 91 * structure based on the process’ bitness and a custom value, such as a \ |
| 92 * structure version number. This can be used prior to reading any data \ |
| 93 * from a process. */ \ |
| 94 static size_t ExpectedSizeForVersion(ProcessReader* process_reader, \ |
| 95 uint64_t version); |
| 89 | 96 |
| 90 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ | 97 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ |
| 91 member_type member_name __VA_ARGS__; | 98 member_type member_name __VA_ARGS__; |
| 92 | 99 |
| 93 #define PROCESS_TYPE_STRUCT_END(struct_name) \ | 100 #define PROCESS_TYPE_STRUCT_END(struct_name) \ |
| 94 private: \ | 101 private: \ |
| 95 /* The static form of Read(). Populates the struct at |generic|. */ \ | 102 /* The static form of Read(). Populates the struct at |generic|. */ \ |
| 96 static bool ReadInto(ProcessReader* process_reader, \ | 103 static bool ReadInto(ProcessReader* process_reader, \ |
| 97 mach_vm_address_t address, \ | 104 mach_vm_address_t address, \ |
| 98 struct_name* generic); \ | 105 struct_name* generic); \ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 template <typename Traits> \ | 143 template <typename Traits> \ |
| 137 struct struct_name { \ | 144 struct struct_name { \ |
| 138 public: \ | 145 public: \ |
| 139 using Long = typename Traits::Long; \ | 146 using Long = typename Traits::Long; \ |
| 140 using ULong = typename Traits::ULong; \ | 147 using ULong = typename Traits::ULong; \ |
| 141 using Pointer = typename Traits::Pointer; \ | 148 using Pointer = typename Traits::Pointer; \ |
| 142 using IntPtr = typename Traits::IntPtr; \ | 149 using IntPtr = typename Traits::IntPtr; \ |
| 143 using UIntPtr = typename Traits::UIntPtr; \ | 150 using UIntPtr = typename Traits::UIntPtr; \ |
| 144 using Reserved64Only = typename Traits::Reserved64Only; \ | 151 using Reserved64Only = typename Traits::Reserved64Only; \ |
| 145 \ | 152 \ |
| 146 /* Read(), ReadArrayInto(), and Size() are as in the generic user-visible \ | 153 /* Read(), ReadArrayInto(), Size(), and ExpectedSizeForVersion() are as in \ |
| 147 * struct above. */ \ | 154 * the generic user-visible struct above. */ \ |
| 148 bool Read(ProcessReader* process_reader, mach_vm_address_t address) { \ | 155 bool Read(ProcessReader* process_reader, mach_vm_address_t address) { \ |
| 149 return ReadInto(process_reader, address, this); \ | 156 return ReadInto(process_reader, address, this); \ |
| 150 } \ | 157 } \ |
| 151 static bool ReadArrayInto(ProcessReader* process_reader, \ | 158 static bool ReadArrayInto(ProcessReader* process_reader, \ |
| 152 mach_vm_address_t address, \ | 159 mach_vm_address_t address, \ |
| 153 size_t count, \ | 160 size_t count, \ |
| 154 struct_name<Traits>* specific); \ | 161 struct_name<Traits>* specific); \ |
| 155 static size_t Size() { return sizeof(struct_name<Traits>); } \ | 162 static size_t Size() { return sizeof(struct_name<Traits>); } \ |
| 163 static size_t ExpectedSizeForVersion(uint64_t version); \ |
| 156 \ | 164 \ |
| 157 /* Translates a struct from the representation used in the remote process \ | 165 /* Translates a struct from the representation used in the remote process \ |
| 158 * into the generic form. */ \ | 166 * into the generic form. */ \ |
| 159 void GenericizeInto(process_types::struct_name* generic, \ | 167 void GenericizeInto(process_types::struct_name* generic, \ |
| 160 size_t* specific_size); | 168 size_t* specific_size); |
| 161 | 169 |
| 162 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ | 170 #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ |
| 163 member_type member_name __VA_ARGS__; | 171 member_type member_name __VA_ARGS__; |
| 164 | 172 |
| 165 #define PROCESS_TYPE_STRUCT_END(struct_name) \ | 173 #define PROCESS_TYPE_STRUCT_END(struct_name) \ |
| 166 private: \ | 174 private: \ |
| 167 /* ReadInto() is as in the generic user-visible struct above. */ \ | 175 /* ReadInto() is as in the generic user-visible struct above. */ \ |
| 168 static bool ReadInto(ProcessReader* process_reader, \ | 176 static bool ReadInto(ProcessReader* process_reader, \ |
| 169 mach_vm_address_t address, \ | 177 mach_vm_address_t address, \ |
| 170 struct_name<Traits>* specific); \ | 178 struct_name<Traits>* specific); \ |
| 171 }; \ | 179 }; \ |
| 172 } /* namespace internal */ \ | 180 } /* namespace internal */ \ |
| 173 } /* namespace process_types */ \ | 181 } /* namespace process_types */ \ |
| 174 } /* namespace crashpad */ | 182 } /* namespace crashpad */ |
| 175 | 183 |
| 176 #include "snapshot/mac/process_types/all.proctype" | 184 #include "snapshot/mac/process_types/all.proctype" |
| 177 | 185 |
| 178 #undef PROCESS_TYPE_STRUCT_BEGIN | 186 #undef PROCESS_TYPE_STRUCT_BEGIN |
| 179 #undef PROCESS_TYPE_STRUCT_MEMBER | 187 #undef PROCESS_TYPE_STRUCT_MEMBER |
| 180 #undef PROCESS_TYPE_STRUCT_END | 188 #undef PROCESS_TYPE_STRUCT_END |
| 181 #undef PROCESS_TYPE_STRUCT_DECLARE_INTERNAL | 189 #undef PROCESS_TYPE_STRUCT_DECLARE_INTERNAL |
| 182 | 190 |
| 183 #endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_H_ | 191 #endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_H_ |
| OLD | NEW |