| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 const char* expected_pdb_name, | 93 const char* expected_pdb_name, |
| 94 const UUID* expected_pdb_uuid, | 94 const UUID* expected_pdb_uuid, |
| 95 time_t expected_pdb_timestamp, | 95 time_t expected_pdb_timestamp, |
| 96 uint32_t expected_pdb_age) { | 96 uint32_t expected_pdb_age) { |
| 97 if (expected_pdb_name) { | 97 if (expected_pdb_name) { |
| 98 EXPECT_NE(0u, codeview_record->Rva); | 98 EXPECT_NE(0u, codeview_record->Rva); |
| 99 | 99 |
| 100 std::string observed_pdb_name; | 100 std::string observed_pdb_name; |
| 101 if (expected_pdb_uuid) { | 101 if (expected_pdb_uuid) { |
| 102 // The CodeView record should be a PDB 7.0 link. | 102 // The CodeView record should be a PDB 7.0 link. |
| 103 const MinidumpModuleCodeViewRecordPDB70* codeview_pdb70_record = | 103 const CodeViewRecordPDB70* codeview_pdb70_record = |
| 104 MinidumpWritableAtLocationDescriptor< | 104 MinidumpWritableAtLocationDescriptor<CodeViewRecordPDB70>( |
| 105 MinidumpModuleCodeViewRecordPDB70>(file_contents, | 105 file_contents, *codeview_record); |
| 106 *codeview_record); | |
| 107 ASSERT_TRUE(codeview_pdb70_record); | 106 ASSERT_TRUE(codeview_pdb70_record); |
| 108 EXPECT_EQ(0, | 107 EXPECT_EQ(0, |
| 109 memcmp(expected_pdb_uuid, | 108 memcmp(expected_pdb_uuid, |
| 110 &codeview_pdb70_record->uuid, | 109 &codeview_pdb70_record->uuid, |
| 111 sizeof(codeview_pdb70_record->uuid))); | 110 sizeof(codeview_pdb70_record->uuid))); |
| 112 EXPECT_EQ(expected_pdb_age, codeview_pdb70_record->age); | 111 EXPECT_EQ(expected_pdb_age, codeview_pdb70_record->age); |
| 113 | 112 |
| 114 observed_pdb_name.assign( | 113 observed_pdb_name.assign( |
| 115 reinterpret_cast<const char*>(&codeview_pdb70_record->pdb_name[0]), | 114 reinterpret_cast<const char*>(&codeview_pdb70_record->pdb_name[0]), |
| 116 codeview_record->DataSize - | 115 codeview_record->DataSize - offsetof(CodeViewRecordPDB70, pdb_name)); |
| 117 offsetof(MinidumpModuleCodeViewRecordPDB70, pdb_name)); | |
| 118 } else { | 116 } else { |
| 119 // The CodeView record should be a PDB 2.0 link. | 117 // The CodeView record should be a PDB 2.0 link. |
| 120 const MinidumpModuleCodeViewRecordPDB20* codeview_pdb20_record = | 118 const CodeViewRecordPDB20* codeview_pdb20_record = |
| 121 MinidumpWritableAtLocationDescriptor< | 119 MinidumpWritableAtLocationDescriptor<CodeViewRecordPDB20>( |
| 122 MinidumpModuleCodeViewRecordPDB20>(file_contents, | 120 file_contents, *codeview_record); |
| 123 *codeview_record); | |
| 124 ASSERT_TRUE(codeview_pdb20_record); | 121 ASSERT_TRUE(codeview_pdb20_record); |
| 125 EXPECT_EQ(static_cast<uint32_t>(expected_pdb_timestamp), | 122 EXPECT_EQ(static_cast<uint32_t>(expected_pdb_timestamp), |
| 126 codeview_pdb20_record->timestamp); | 123 codeview_pdb20_record->timestamp); |
| 127 EXPECT_EQ(expected_pdb_age, codeview_pdb20_record->age); | 124 EXPECT_EQ(expected_pdb_age, codeview_pdb20_record->age); |
| 128 | 125 |
| 129 observed_pdb_name.assign( | 126 observed_pdb_name.assign( |
| 130 reinterpret_cast<const char*>(&codeview_pdb20_record->pdb_name[0]), | 127 reinterpret_cast<const char*>(&codeview_pdb20_record->pdb_name[0]), |
| 131 codeview_record->DataSize - | 128 codeview_record->DataSize - offsetof(CodeViewRecordPDB20, pdb_name)); |
| 132 offsetof(MinidumpModuleCodeViewRecordPDB20, pdb_name)); | |
| 133 } | 129 } |
| 134 | 130 |
| 135 // Check for, and then remove, the NUL terminator. | 131 // Check for, and then remove, the NUL terminator. |
| 136 EXPECT_EQ('\0', observed_pdb_name[observed_pdb_name.size() - 1]); | 132 EXPECT_EQ('\0', observed_pdb_name[observed_pdb_name.size() - 1]); |
| 137 observed_pdb_name.resize(observed_pdb_name.size() - 1); | 133 observed_pdb_name.resize(observed_pdb_name.size() - 1); |
| 138 | 134 |
| 139 EXPECT_EQ(expected_pdb_name, observed_pdb_name); | 135 EXPECT_EQ(expected_pdb_name, observed_pdb_name); |
| 140 } else { | 136 } else { |
| 141 // There should be no CodeView record. | 137 // There should be no CodeView record. |
| 142 EXPECT_EQ(0u, codeview_record->DataSize); | 138 EXPECT_EQ(0u, codeview_record->DataSize); |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 minidump_file_writer.AddStream(module_list_writer.Pass()); | 750 minidump_file_writer.AddStream(module_list_writer.Pass()); |
| 755 | 751 |
| 756 StringFile string_file; | 752 StringFile string_file; |
| 757 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), | 753 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), |
| 758 "name_"); | 754 "name_"); |
| 759 } | 755 } |
| 760 | 756 |
| 761 } // namespace | 757 } // namespace |
| 762 } // namespace test | 758 } // namespace test |
| 763 } // namespace crashpad | 759 } // namespace crashpad |
| OLD | NEW |