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_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_ | 15 #ifndef CRASHPAD_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_ |
16 #define CRASHPAD_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_ | 16 #define CRASHPAD_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_ |
17 | 17 |
18 #include <dbghelp.h> | 18 #include <dbghelp.h> |
19 #include <stdint.h> | 19 #include <stdint.h> |
| 20 #include <sys/types.h> |
20 | 21 |
21 #include <string> | 22 #include <string> |
22 | 23 |
| 24 #include "base/basictypes.h" |
23 #include "gtest/gtest.h" | 25 #include "gtest/gtest.h" |
24 #include "minidump/minidump_extensions.h" | 26 #include "minidump/minidump_extensions.h" |
| 27 #include "minidump/minidump_writable.h" |
25 | 28 |
26 namespace crashpad { | 29 namespace crashpad { |
| 30 |
| 31 class FileWriterInterface; |
| 32 |
27 namespace test { | 33 namespace test { |
28 | 34 |
29 //! \brief Returns an untyped minidump object located within a minidump file’s | 35 //! \brief Returns an untyped minidump object located within a minidump file’s |
30 //! contents, where the offset and size of the object are known. | 36 //! contents, where the offset and size of the object are known. |
31 //! | 37 //! |
32 //! \param[in] file_contents The contents of the minidump file. | 38 //! \param[in] file_contents The contents of the minidump file. |
33 //! \param[in] location A MINIDUMP_LOCATION_DESCRIPTOR giving the offset within | 39 //! \param[in] location A MINIDUMP_LOCATION_DESCRIPTOR giving the offset within |
34 //! the minidump file of the desired object, as well as its size. | 40 //! the minidump file of the desired object, as well as its size. |
35 //! \param[in] expected_size The expected size of the object. If \a | 41 //! \param[in] expected_size The expected size of the object. If \a |
36 //! allow_oversized_data is `true`, \a expected_size is treated as the | 42 //! allow_oversized_data is `true`, \a expected_size is treated as the |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 83 |
78 // This type appears only as a variable-sized list. | 84 // This type appears only as a variable-sized list. |
79 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_DIRECTORY); | 85 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_DIRECTORY); |
80 | 86 |
81 // These types are permitted to be oversized because their final fields are | 87 // These types are permitted to be oversized because their final fields are |
82 // variable-sized lists. | 88 // variable-sized lists. |
83 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_MEMORY_LIST); | 89 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_MEMORY_LIST); |
84 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_MODULE_LIST); | 90 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_MODULE_LIST); |
85 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_THREAD_LIST); | 91 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_THREAD_LIST); |
86 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpLocationDescriptorList); | 92 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpLocationDescriptorList); |
| 93 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpRVAList); |
87 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpSimpleStringDictionary); | 94 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpSimpleStringDictionary); |
88 | 95 |
89 // These types have final fields carrying variable-sized data (typically string | 96 // These types have final fields carrying variable-sized data (typically string |
90 // data). | 97 // data). |
91 MINIDUMP_ALLOW_OVERSIZED_DATA(IMAGE_DEBUG_MISC); | 98 MINIDUMP_ALLOW_OVERSIZED_DATA(IMAGE_DEBUG_MISC); |
92 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_STRING); | 99 MINIDUMP_ALLOW_OVERSIZED_DATA(MINIDUMP_STRING); |
93 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpModuleCodeViewRecordPDB20); | 100 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpModuleCodeViewRecordPDB20); |
94 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpModuleCodeViewRecordPDB70); | 101 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpModuleCodeViewRecordPDB70); |
95 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpUTF8String); | 102 MINIDUMP_ALLOW_OVERSIZED_DATA(MinidumpUTF8String); |
96 | 103 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 //! | 225 //! |
219 //! \sa MinidumpWritableAtLocationDescriptor<>() | 226 //! \sa MinidumpWritableAtLocationDescriptor<>() |
220 template <typename T> | 227 template <typename T> |
221 const T* MinidumpWritableAtRVA(const std::string& file_contents, RVA rva) { | 228 const T* MinidumpWritableAtRVA(const std::string& file_contents, RVA rva) { |
222 MINIDUMP_LOCATION_DESCRIPTOR location; | 229 MINIDUMP_LOCATION_DESCRIPTOR location; |
223 location.DataSize = sizeof(T); | 230 location.DataSize = sizeof(T); |
224 location.Rva = rva; | 231 location.Rva = rva; |
225 return MinidumpWritableAtLocationDescriptor<T>(file_contents, location); | 232 return MinidumpWritableAtLocationDescriptor<T>(file_contents, location); |
226 } | 233 } |
227 | 234 |
| 235 //! \brief An internal::MinidumpWritable that carries a `uint32_t` for testing. |
| 236 class TestUInt32MinidumpWritable final : public internal::MinidumpWritable { |
| 237 public: |
| 238 //! \brief Constructs the object to write a `uint32_t` with value \a value. |
| 239 explicit TestUInt32MinidumpWritable(uint32_t value); |
| 240 |
| 241 ~TestUInt32MinidumpWritable() override; |
| 242 |
| 243 protected: |
| 244 // MinidumpWritable: |
| 245 size_t SizeOfObject() override; |
| 246 bool WriteObject(FileWriterInterface* file_writer) override; |
| 247 |
| 248 private: |
| 249 uint32_t value_; |
| 250 |
| 251 DISALLOW_COPY_AND_ASSIGN(TestUInt32MinidumpWritable); |
| 252 }; |
| 253 |
228 } // namespace test | 254 } // namespace test |
229 } // namespace crashpad | 255 } // namespace crashpad |
230 | 256 |
231 #endif // CRASHPAD_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_ | 257 #endif // CRASHPAD_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_ |
OLD | NEW |