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 14 matching lines...) Expand all Loading... |
25 const MINIDUMP_DIRECTORY** directory) { | 25 const MINIDUMP_DIRECTORY** directory) { |
26 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; | 26 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; |
27 location_descriptor.DataSize = sizeof(MINIDUMP_HEADER); | 27 location_descriptor.DataSize = sizeof(MINIDUMP_HEADER); |
28 location_descriptor.Rva = 0; | 28 location_descriptor.Rva = 0; |
29 | 29 |
30 const MINIDUMP_HEADER* header = | 30 const MINIDUMP_HEADER* header = |
31 MinidumpWritableAtLocationDescriptor<MINIDUMP_HEADER>( | 31 MinidumpWritableAtLocationDescriptor<MINIDUMP_HEADER>( |
32 file_contents, location_descriptor); | 32 file_contents, location_descriptor); |
33 | 33 |
34 if (header) { | 34 if (header) { |
35 if (header->Signature != MINIDUMP_SIGNATURE) { | |
36 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_SIGNATURE), header->Signature); | |
37 return nullptr; | |
38 } | |
39 if (header->Version != MINIDUMP_VERSION) { | |
40 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_VERSION), header->Version); | |
41 return nullptr; | |
42 } | |
43 | |
44 location_descriptor.DataSize = | 35 location_descriptor.DataSize = |
45 header->NumberOfStreams * sizeof(MINIDUMP_DIRECTORY); | 36 header->NumberOfStreams * sizeof(MINIDUMP_DIRECTORY); |
46 location_descriptor.Rva = header->StreamDirectoryRva; | 37 location_descriptor.Rva = header->StreamDirectoryRva; |
47 *directory = MinidumpWritableAtLocationDescriptor<MINIDUMP_DIRECTORY>( | 38 *directory = MinidumpWritableAtLocationDescriptor<MINIDUMP_DIRECTORY>( |
48 file_contents, location_descriptor); | 39 file_contents, location_descriptor); |
49 } else { | 40 } else { |
50 *directory = nullptr; | 41 *directory = nullptr; |
51 } | 42 } |
52 | 43 |
53 return header; | 44 return header; |
54 } | 45 } |
55 | 46 |
56 void VerifyMinidumpHeader(const MINIDUMP_HEADER* header, | 47 void VerifyMinidumpHeader(const MINIDUMP_HEADER* header, |
57 uint32_t streams, | 48 uint32_t streams, |
58 uint32_t timestamp) { | 49 uint32_t timestamp) { |
59 ASSERT_TRUE(header); | 50 ASSERT_TRUE(header); |
60 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_SIGNATURE), header->Signature); | |
61 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_VERSION), header->Version); | |
62 ASSERT_EQ(streams, header->NumberOfStreams); | 51 ASSERT_EQ(streams, header->NumberOfStreams); |
63 ASSERT_EQ(streams ? sizeof(MINIDUMP_HEADER) : 0u, header->StreamDirectoryRva); | 52 ASSERT_EQ(streams ? sizeof(MINIDUMP_HEADER) : 0u, header->StreamDirectoryRva); |
64 EXPECT_EQ(0u, header->CheckSum); | 53 EXPECT_EQ(0u, header->CheckSum); |
65 EXPECT_EQ(timestamp, header->TimeDateStamp); | 54 EXPECT_EQ(timestamp, header->TimeDateStamp); |
66 EXPECT_EQ(MiniDumpNormal, header->Flags); | 55 EXPECT_EQ(MiniDumpNormal, header->Flags); |
67 } | 56 } |
68 | 57 |
69 } // namespace test | 58 } // namespace test |
70 } // namespace crashpad | 59 } // namespace crashpad |
OLD | NEW |