Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: minidump/minidump_module_crashpad_info_writer_test.cc

Issue 978463003: minidump: Reorganize MinidumpModuleCrashpadInfo to improve linking between structures (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Minor update Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "minidump/minidump_module_crashpad_info_writer.h" 15 #include "minidump/minidump_module_crashpad_info_writer.h"
16 16
17 #include <windows.h> 17 #include <windows.h>
18 #include <dbghelp.h> 18 #include <dbghelp.h>
19 19
20 #include "gtest/gtest.h" 20 #include "gtest/gtest.h"
21 #include "minidump/minidump_extensions.h" 21 #include "minidump/minidump_extensions.h"
22 #include "minidump/minidump_simple_string_dictionary_writer.h" 22 #include "minidump/minidump_simple_string_dictionary_writer.h"
23 #include "minidump/test/minidump_file_writer_test_util.h" 23 #include "minidump/test/minidump_file_writer_test_util.h"
24 #include "minidump/test/minidump_location_descriptor_list_test_util.h"
25 #include "minidump/test/minidump_string_writer_test_util.h" 24 #include "minidump/test/minidump_string_writer_test_util.h"
26 #include "minidump/test/minidump_writable_test_util.h" 25 #include "minidump/test/minidump_writable_test_util.h"
27 #include "snapshot/test/test_module_snapshot.h" 26 #include "snapshot/test/test_module_snapshot.h"
28 #include "util/file/string_file.h" 27 #include "util/file/string_file.h"
29 28
30 namespace crashpad { 29 namespace crashpad {
31 namespace test { 30 namespace test {
32 namespace { 31 namespace {
33 32
33 const MinidumpModuleCrashpadInfoList* MinidumpModuleCrashpadInfoListAtStart(
34 const std::string& file_contents,
35 size_t count) {
36 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
37 location_descriptor.DataSize = sizeof(MinidumpModuleCrashpadInfoList) +
38 count * sizeof(MinidumpModuleCrashpadInfoLink);
39 location_descriptor.Rva = 0;
40
41 const MinidumpModuleCrashpadInfoList* list =
42 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfoList>(
43 file_contents, location_descriptor);
44 if (!list) {
45 return nullptr;
46 }
47
48 if (list->count != count) {
49 EXPECT_EQ(count, list->count);
50 return nullptr;
51 }
52
53 return list;
54 }
55
34 TEST(MinidumpModuleCrashpadInfoWriter, EmptyList) { 56 TEST(MinidumpModuleCrashpadInfoWriter, EmptyList) {
35 StringFile string_file; 57 StringFile string_file;
36 58
37 MinidumpModuleCrashpadInfoListWriter module_list_writer; 59 auto module_list_writer =
38 EXPECT_FALSE(module_list_writer.IsUseful()); 60 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
61 EXPECT_FALSE(module_list_writer->IsUseful());
39 62
40 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file)); 63 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
41 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList), 64 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList),
42 string_file.string().size()); 65 string_file.string().size());
43 66
44 const MinidumpModuleCrashpadInfoList* module_list = 67 const MinidumpModuleCrashpadInfoList* module_list =
45 MinidumpLocationDescriptorListAtStart(string_file.string(), 0); 68 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 0);
46 ASSERT_TRUE(module_list); 69 ASSERT_TRUE(module_list);
47 } 70 }
48 71
49 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) { 72 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) {
50 StringFile string_file; 73 StringFile string_file;
51 74
52 MinidumpModuleCrashpadInfoListWriter module_list_writer; 75 auto module_list_writer =
53 auto module_writer = 76 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
54 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 77 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
55 EXPECT_FALSE(module_writer->IsUseful()); 78 EXPECT_FALSE(module_writer->IsUseful());
56 module_list_writer.AddModule(module_writer.Pass()); 79 module_list_writer->AddModule(module_writer.Pass(), 0);
57 80
58 EXPECT_TRUE(module_list_writer.IsUseful()); 81 EXPECT_TRUE(module_list_writer->IsUseful());
59 82
60 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file)); 83 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
61 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 84 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
62 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + 85 sizeof(MinidumpModuleCrashpadInfoLink) +
63 sizeof(MinidumpModuleCrashpadInfo), 86 sizeof(MinidumpModuleCrashpadInfo),
64 string_file.string().size()); 87 string_file.string().size());
65 88
66 const MinidumpModuleCrashpadInfoList* module_list = 89 const MinidumpModuleCrashpadInfoList* module_list =
67 MinidumpLocationDescriptorListAtStart(string_file.string(), 1); 90 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 1);
68 ASSERT_TRUE(module_list); 91 ASSERT_TRUE(module_list);
69 92
93 EXPECT_EQ(0u, module_list->modules[0].minidump_module_list_index);
70 const MinidumpModuleCrashpadInfo* module = 94 const MinidumpModuleCrashpadInfo* module =
71 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 95 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
72 string_file.string(), module_list->children[0]); 96 string_file.string(), module_list->modules[0].location);
73 ASSERT_TRUE(module); 97 ASSERT_TRUE(module);
74 98
75 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); 99 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version);
76 EXPECT_EQ(0u, module->minidump_module_list_index);
77 EXPECT_EQ(0u, module->list_annotations.DataSize); 100 EXPECT_EQ(0u, module->list_annotations.DataSize);
78 EXPECT_EQ(0u, module->list_annotations.Rva); 101 EXPECT_EQ(0u, module->list_annotations.Rva);
79 EXPECT_EQ(0u, module->simple_annotations.DataSize); 102 EXPECT_EQ(0u, module->simple_annotations.DataSize);
80 EXPECT_EQ(0u, module->simple_annotations.Rva); 103 EXPECT_EQ(0u, module->simple_annotations.Rva);
81 } 104 }
82 105
83 TEST(MinidumpModuleCrashpadInfoWriter, FullModule) { 106 TEST(MinidumpModuleCrashpadInfoWriter, FullModule) {
84 const uint32_t kMinidumpModuleListIndex = 1; 107 const uint32_t kMinidumpModuleListIndex = 1;
85 const char kKey[] = "key"; 108 const char kKey[] = "key";
86 const char kValue[] = "value"; 109 const char kValue[] = "value";
87 const char kEntry[] = "entry"; 110 const char kEntry[] = "entry";
88 std::vector<std::string> vector(1, std::string(kEntry)); 111 std::vector<std::string> vector(1, std::string(kEntry));
89 112
90 StringFile string_file; 113 StringFile string_file;
91 114
92 MinidumpModuleCrashpadInfoListWriter module_list_writer; 115 auto module_list_writer =
116 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
93 117
94 auto module_writer = 118 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
95 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
96 module_writer->SetMinidumpModuleListIndex(kMinidumpModuleListIndex);
97 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter()); 119 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter());
98 string_list_writer->InitializeFromVector(vector); 120 string_list_writer->InitializeFromVector(vector);
99 module_writer->SetListAnnotations(string_list_writer.Pass()); 121 module_writer->SetListAnnotations(string_list_writer.Pass());
100 auto simple_string_dictionary_writer = 122 auto simple_string_dictionary_writer =
101 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 123 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
102 auto simple_string_dictionary_entry_writer = 124 auto simple_string_dictionary_entry_writer =
103 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 125 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
104 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue); 126 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue);
105 simple_string_dictionary_writer->AddEntry( 127 simple_string_dictionary_writer->AddEntry(
106 simple_string_dictionary_entry_writer.Pass()); 128 simple_string_dictionary_entry_writer.Pass());
107 module_writer->SetSimpleAnnotations(simple_string_dictionary_writer.Pass()); 129 module_writer->SetSimpleAnnotations(simple_string_dictionary_writer.Pass());
108 EXPECT_TRUE(module_writer->IsUseful()); 130 EXPECT_TRUE(module_writer->IsUseful());
109 module_list_writer.AddModule(module_writer.Pass()); 131 module_list_writer->AddModule(module_writer.Pass(), kMinidumpModuleListIndex);
110 132
111 EXPECT_TRUE(module_list_writer.IsUseful()); 133 EXPECT_TRUE(module_list_writer->IsUseful());
112 134
113 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file)); 135 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
114 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 136 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
115 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + 137 sizeof(MinidumpModuleCrashpadInfoLink) +
116 sizeof(MinidumpModuleCrashpadInfo) + 138 sizeof(MinidumpModuleCrashpadInfo) +
117 sizeof(MinidumpRVAList) + 139 sizeof(MinidumpRVAList) +
118 sizeof(RVA) + 140 sizeof(RVA) +
119 sizeof(MinidumpSimpleStringDictionary) + 141 sizeof(MinidumpSimpleStringDictionary) +
120 sizeof(MinidumpSimpleStringDictionaryEntry) + 142 sizeof(MinidumpSimpleStringDictionaryEntry) +
121 sizeof(MinidumpUTF8String) + arraysize(kEntry) + 2 + // padding 143 sizeof(MinidumpUTF8String) + arraysize(kEntry) + 2 + // padding
122 sizeof(MinidumpUTF8String) + arraysize(kKey) + 144 sizeof(MinidumpUTF8String) + arraysize(kKey) +
123 sizeof(MinidumpUTF8String) + arraysize(kValue), 145 sizeof(MinidumpUTF8String) + arraysize(kValue),
124 string_file.string().size()); 146 string_file.string().size());
125 147
126 const MinidumpModuleCrashpadInfoList* module_list = 148 const MinidumpModuleCrashpadInfoList* module_list =
127 MinidumpLocationDescriptorListAtStart(string_file.string(), 1); 149 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 1);
128 ASSERT_TRUE(module_list); 150 ASSERT_TRUE(module_list);
129 151
152 EXPECT_EQ(kMinidumpModuleListIndex,
153 module_list->modules[0].minidump_module_list_index);
130 const MinidumpModuleCrashpadInfo* module = 154 const MinidumpModuleCrashpadInfo* module =
131 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 155 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
132 string_file.string(), module_list->children[0]); 156 string_file.string(), module_list->modules[0].location);
133 ASSERT_TRUE(module); 157 ASSERT_TRUE(module);
134 158
135 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); 159 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version);
136 EXPECT_EQ(kMinidumpModuleListIndex, module->minidump_module_list_index);
137 EXPECT_NE(0u, module->list_annotations.DataSize); 160 EXPECT_NE(0u, module->list_annotations.DataSize);
138 EXPECT_NE(0u, module->list_annotations.Rva); 161 EXPECT_NE(0u, module->list_annotations.Rva);
139 EXPECT_NE(0u, module->simple_annotations.DataSize); 162 EXPECT_NE(0u, module->simple_annotations.DataSize);
140 EXPECT_NE(0u, module->simple_annotations.Rva); 163 EXPECT_NE(0u, module->simple_annotations.Rva);
141 164
142 const MinidumpRVAList* list_annotations = 165 const MinidumpRVAList* list_annotations =
143 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 166 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
144 string_file.string(), module->list_annotations); 167 string_file.string(), module->list_annotations);
145 ASSERT_TRUE(list_annotations); 168 ASSERT_TRUE(list_annotations);
146 169
147 ASSERT_EQ(1u, list_annotations->count); 170 ASSERT_EQ(1u, list_annotations->count);
148 EXPECT_EQ(kEntry, MinidumpUTF8StringAtRVAAsString( 171 EXPECT_EQ(kEntry,
149 string_file.string(), list_annotations->children[0])); 172 MinidumpUTF8StringAtRVAAsString(string_file.string(),
173 list_annotations->children[0]));
150 174
151 const MinidumpSimpleStringDictionary* simple_annotations = 175 const MinidumpSimpleStringDictionary* simple_annotations =
152 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 176 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
153 string_file.string(), module->simple_annotations); 177 string_file.string(), module->simple_annotations);
154 ASSERT_TRUE(simple_annotations); 178 ASSERT_TRUE(simple_annotations);
155 179
156 ASSERT_EQ(1u, simple_annotations->count); 180 ASSERT_EQ(1u, simple_annotations->count);
157 EXPECT_EQ(kKey, 181 EXPECT_EQ(kKey,
158 MinidumpUTF8StringAtRVAAsString( 182 MinidumpUTF8StringAtRVAAsString(
159 string_file.string(), simple_annotations->entries[0].key)); 183 string_file.string(), simple_annotations->entries[0].key));
160 EXPECT_EQ(kValue, 184 EXPECT_EQ(kValue,
161 MinidumpUTF8StringAtRVAAsString( 185 MinidumpUTF8StringAtRVAAsString(
162 string_file.string(), simple_annotations->entries[0].value)); 186 string_file.string(), simple_annotations->entries[0].value));
163 } 187 }
164 188
165 TEST(MinidumpModuleCrashpadInfoWriter, ThreeModules) { 189 TEST(MinidumpModuleCrashpadInfoWriter, ThreeModules) {
166 const uint32_t kMinidumpModuleListIndex0 = 0; 190 const uint32_t kMinidumpModuleListIndex0 = 0;
167 const char kKey0[] = "key"; 191 const char kKey0[] = "key";
168 const char kValue0[] = "value"; 192 const char kValue0[] = "value";
169 const uint32_t kMinidumpModuleListIndex1 = 2; 193 const uint32_t kMinidumpModuleListIndex1 = 2;
170 const uint32_t kMinidumpModuleListIndex2 = 5; 194 const uint32_t kMinidumpModuleListIndex2 = 5;
171 const char kKey2A[] = "K"; 195 const char kKey2A[] = "K";
172 const char kValue2A[] = "VVV"; 196 const char kValue2A[] = "VVV";
173 const char kKey2B[] = "river"; 197 const char kKey2B[] = "river";
174 const char kValue2B[] = "hudson"; 198 const char kValue2B[] = "hudson";
175 199
176 StringFile string_file; 200 StringFile string_file;
177 201
178 MinidumpModuleCrashpadInfoListWriter module_list_writer; 202 auto module_list_writer =
203 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
179 204
180 auto module_writer_0 = 205 auto module_writer_0 =
181 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 206 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
182 module_writer_0->SetMinidumpModuleListIndex(kMinidumpModuleListIndex0);
183 auto simple_string_dictionary_writer_0 = 207 auto simple_string_dictionary_writer_0 =
184 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 208 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
185 auto simple_string_dictionary_entry_writer_0 = 209 auto simple_string_dictionary_entry_writer_0 =
186 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 210 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
187 simple_string_dictionary_entry_writer_0->SetKeyValue(kKey0, kValue0); 211 simple_string_dictionary_entry_writer_0->SetKeyValue(kKey0, kValue0);
188 simple_string_dictionary_writer_0->AddEntry( 212 simple_string_dictionary_writer_0->AddEntry(
189 simple_string_dictionary_entry_writer_0.Pass()); 213 simple_string_dictionary_entry_writer_0.Pass());
190 module_writer_0->SetSimpleAnnotations( 214 module_writer_0->SetSimpleAnnotations(
191 simple_string_dictionary_writer_0.Pass()); 215 simple_string_dictionary_writer_0.Pass());
192 EXPECT_TRUE(module_writer_0->IsUseful()); 216 EXPECT_TRUE(module_writer_0->IsUseful());
193 module_list_writer.AddModule(module_writer_0.Pass()); 217 module_list_writer->AddModule(module_writer_0.Pass(),
218 kMinidumpModuleListIndex0);
194 219
195 auto module_writer_1 = 220 auto module_writer_1 =
196 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 221 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
197 module_writer_1->SetMinidumpModuleListIndex(kMinidumpModuleListIndex1);
198 EXPECT_FALSE(module_writer_1->IsUseful()); 222 EXPECT_FALSE(module_writer_1->IsUseful());
199 module_list_writer.AddModule(module_writer_1.Pass()); 223 module_list_writer->AddModule(module_writer_1.Pass(),
224 kMinidumpModuleListIndex1);
200 225
201 auto module_writer_2 = 226 auto module_writer_2 =
202 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 227 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
203 module_writer_2->SetMinidumpModuleListIndex(kMinidumpModuleListIndex2);
204 auto simple_string_dictionary_writer_2 = 228 auto simple_string_dictionary_writer_2 =
205 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 229 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
206 auto simple_string_dictionary_entry_writer_2a = 230 auto simple_string_dictionary_entry_writer_2a =
207 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 231 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
208 simple_string_dictionary_entry_writer_2a->SetKeyValue(kKey2A, kValue2A); 232 simple_string_dictionary_entry_writer_2a->SetKeyValue(kKey2A, kValue2A);
209 simple_string_dictionary_writer_2->AddEntry( 233 simple_string_dictionary_writer_2->AddEntry(
210 simple_string_dictionary_entry_writer_2a.Pass()); 234 simple_string_dictionary_entry_writer_2a.Pass());
211 auto simple_string_dictionary_entry_writer_2b = 235 auto simple_string_dictionary_entry_writer_2b =
212 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 236 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
213 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B); 237 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B);
214 simple_string_dictionary_writer_2->AddEntry( 238 simple_string_dictionary_writer_2->AddEntry(
215 simple_string_dictionary_entry_writer_2b.Pass()); 239 simple_string_dictionary_entry_writer_2b.Pass());
216 module_writer_2->SetSimpleAnnotations( 240 module_writer_2->SetSimpleAnnotations(
217 simple_string_dictionary_writer_2.Pass()); 241 simple_string_dictionary_writer_2.Pass());
218 EXPECT_TRUE(module_writer_2->IsUseful()); 242 EXPECT_TRUE(module_writer_2->IsUseful());
219 module_list_writer.AddModule(module_writer_2.Pass()); 243 module_list_writer->AddModule(module_writer_2.Pass(),
244 kMinidumpModuleListIndex2);
220 245
221 EXPECT_TRUE(module_list_writer.IsUseful()); 246 EXPECT_TRUE(module_list_writer->IsUseful());
222 247
223 EXPECT_TRUE(module_list_writer.WriteEverything(&string_file)); 248 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
224 249
225 const MinidumpModuleCrashpadInfoList* module_list = 250 const MinidumpModuleCrashpadInfoList* module_list =
226 MinidumpLocationDescriptorListAtStart(string_file.string(), 3); 251 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 3);
227 ASSERT_TRUE(module_list); 252 ASSERT_TRUE(module_list);
228 253
254 EXPECT_EQ(kMinidumpModuleListIndex0,
255 module_list->modules[0].minidump_module_list_index);
229 const MinidumpModuleCrashpadInfo* module_0 = 256 const MinidumpModuleCrashpadInfo* module_0 =
230 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 257 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
231 string_file.string(), module_list->children[0]); 258 string_file.string(), module_list->modules[0].location);
232 ASSERT_TRUE(module_0); 259 ASSERT_TRUE(module_0);
233 260
234 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version); 261 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version);
235 EXPECT_EQ(kMinidumpModuleListIndex0, module_0->minidump_module_list_index);
236 262
237 const MinidumpRVAList* list_annotations_0 = 263 const MinidumpRVAList* list_annotations_0 =
238 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 264 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
239 string_file.string(), module_0->list_annotations); 265 string_file.string(), module_0->list_annotations);
240 EXPECT_FALSE(list_annotations_0); 266 EXPECT_FALSE(list_annotations_0);
241 267
242 const MinidumpSimpleStringDictionary* simple_annotations_0 = 268 const MinidumpSimpleStringDictionary* simple_annotations_0 =
243 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 269 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
244 string_file.string(), module_0->simple_annotations); 270 string_file.string(), module_0->simple_annotations);
245 ASSERT_TRUE(simple_annotations_0); 271 ASSERT_TRUE(simple_annotations_0);
246 272
247 ASSERT_EQ(1u, simple_annotations_0->count); 273 ASSERT_EQ(1u, simple_annotations_0->count);
248 EXPECT_EQ(kKey0, 274 EXPECT_EQ(kKey0,
249 MinidumpUTF8StringAtRVAAsString( 275 MinidumpUTF8StringAtRVAAsString(
250 string_file.string(), simple_annotations_0->entries[0].key)); 276 string_file.string(), simple_annotations_0->entries[0].key));
251 EXPECT_EQ(kValue0, 277 EXPECT_EQ(kValue0,
252 MinidumpUTF8StringAtRVAAsString( 278 MinidumpUTF8StringAtRVAAsString(
253 string_file.string(), simple_annotations_0->entries[0].value)); 279 string_file.string(), simple_annotations_0->entries[0].value));
254 280
281 EXPECT_EQ(kMinidumpModuleListIndex1,
282 module_list->modules[1].minidump_module_list_index);
255 const MinidumpModuleCrashpadInfo* module_1 = 283 const MinidumpModuleCrashpadInfo* module_1 =
256 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 284 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
257 string_file.string(), module_list->children[1]); 285 string_file.string(), module_list->modules[1].location);
258 ASSERT_TRUE(module_1); 286 ASSERT_TRUE(module_1);
259 287
260 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_1->version); 288 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_1->version);
261 EXPECT_EQ(kMinidumpModuleListIndex1, module_1->minidump_module_list_index);
262 289
263 const MinidumpRVAList* list_annotations_1 = 290 const MinidumpRVAList* list_annotations_1 =
264 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 291 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
265 string_file.string(), module_1->list_annotations); 292 string_file.string(), module_1->list_annotations);
266 EXPECT_FALSE(list_annotations_1); 293 EXPECT_FALSE(list_annotations_1);
267 294
268 const MinidumpSimpleStringDictionary* simple_annotations_1 = 295 const MinidumpSimpleStringDictionary* simple_annotations_1 =
269 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 296 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
270 string_file.string(), module_1->simple_annotations); 297 string_file.string(), module_1->simple_annotations);
271 EXPECT_FALSE(simple_annotations_1); 298 EXPECT_FALSE(simple_annotations_1);
272 299
300 EXPECT_EQ(kMinidumpModuleListIndex2,
301 module_list->modules[2].minidump_module_list_index);
273 const MinidumpModuleCrashpadInfo* module_2 = 302 const MinidumpModuleCrashpadInfo* module_2 =
274 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 303 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
275 string_file.string(), module_list->children[2]); 304 string_file.string(), module_list->modules[2].location);
276 ASSERT_TRUE(module_2); 305 ASSERT_TRUE(module_2);
277 306
278 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version); 307 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version);
279 EXPECT_EQ(kMinidumpModuleListIndex2, module_2->minidump_module_list_index);
280 308
281 const MinidumpRVAList* list_annotations_2 = 309 const MinidumpRVAList* list_annotations_2 =
282 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 310 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
283 string_file.string(), module_2->list_annotations); 311 string_file.string(), module_2->list_annotations);
284 EXPECT_FALSE(list_annotations_2); 312 EXPECT_FALSE(list_annotations_2);
285 313
286 const MinidumpSimpleStringDictionary* simple_annotations_2 = 314 const MinidumpSimpleStringDictionary* simple_annotations_2 =
287 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 315 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
288 string_file.string(), module_2->simple_annotations); 316 string_file.string(), module_2->simple_annotations);
289 ASSERT_TRUE(simple_annotations_2); 317 ASSERT_TRUE(simple_annotations_2);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 module_snapshot_2.SetAnnotationsSimpleMap(annotations_simple_map_2); 361 module_snapshot_2.SetAnnotationsSimpleMap(annotations_simple_map_2);
334 module_snapshots.push_back(&module_snapshot_2); 362 module_snapshots.push_back(&module_snapshot_2);
335 363
336 TestModuleSnapshot module_snapshot_3; 364 TestModuleSnapshot module_snapshot_3;
337 std::vector<std::string> annotations_vector_3; 365 std::vector<std::string> annotations_vector_3;
338 annotations_vector_3.push_back(kEntry3A); 366 annotations_vector_3.push_back(kEntry3A);
339 annotations_vector_3.push_back(kEntry3B); 367 annotations_vector_3.push_back(kEntry3B);
340 module_snapshot_3.SetAnnotationsVector(annotations_vector_3); 368 module_snapshot_3.SetAnnotationsVector(annotations_vector_3);
341 module_snapshots.push_back(&module_snapshot_3); 369 module_snapshots.push_back(&module_snapshot_3);
342 370
343 MinidumpModuleCrashpadInfoListWriter module_list_writer; 371 auto module_list_writer =
344 module_list_writer.InitializeFromSnapshot(module_snapshots); 372 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
345 EXPECT_TRUE(module_list_writer.IsUseful()); 373 module_list_writer->InitializeFromSnapshot(module_snapshots);
374 EXPECT_TRUE(module_list_writer->IsUseful());
346 375
347 StringFile string_file; 376 StringFile string_file;
348 ASSERT_TRUE(module_list_writer.WriteEverything(&string_file)); 377 ASSERT_TRUE(module_list_writer->WriteEverything(&string_file));
349 378
350 const MinidumpModuleCrashpadInfoList* module_list = 379 const MinidumpModuleCrashpadInfoList* module_list =
351 MinidumpLocationDescriptorListAtStart(string_file.string(), 3); 380 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 3);
352 ASSERT_TRUE(module_list); 381 ASSERT_TRUE(module_list);
353 382
383 EXPECT_EQ(0u, module_list->modules[0].minidump_module_list_index);
354 const MinidumpModuleCrashpadInfo* module_0 = 384 const MinidumpModuleCrashpadInfo* module_0 =
355 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 385 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
356 string_file.string(), module_list->children[0]); 386 string_file.string(), module_list->modules[0].location);
357 ASSERT_TRUE(module_0); 387 ASSERT_TRUE(module_0);
358 388
359 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version); 389 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_0->version);
360 EXPECT_EQ(0u, module_0->minidump_module_list_index);
361 390
362 const MinidumpRVAList* list_annotations_0 = 391 const MinidumpRVAList* list_annotations_0 =
363 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 392 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
364 string_file.string(), module_0->list_annotations); 393 string_file.string(), module_0->list_annotations);
365 EXPECT_FALSE(list_annotations_0); 394 EXPECT_FALSE(list_annotations_0);
366 395
367 const MinidumpSimpleStringDictionary* simple_annotations_0 = 396 const MinidumpSimpleStringDictionary* simple_annotations_0 =
368 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 397 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
369 string_file.string(), module_0->simple_annotations); 398 string_file.string(), module_0->simple_annotations);
370 ASSERT_TRUE(simple_annotations_0); 399 ASSERT_TRUE(simple_annotations_0);
371 400
372 ASSERT_EQ(annotations_simple_map_0.size(), simple_annotations_0->count); 401 ASSERT_EQ(annotations_simple_map_0.size(), simple_annotations_0->count);
373 EXPECT_EQ(kKey0B, 402 EXPECT_EQ(kKey0B,
374 MinidumpUTF8StringAtRVAAsString( 403 MinidumpUTF8StringAtRVAAsString(
375 string_file.string(), simple_annotations_0->entries[0].key)); 404 string_file.string(), simple_annotations_0->entries[0].key));
376 EXPECT_EQ(kValue0B, 405 EXPECT_EQ(kValue0B,
377 MinidumpUTF8StringAtRVAAsString( 406 MinidumpUTF8StringAtRVAAsString(
378 string_file.string(), simple_annotations_0->entries[0].value)); 407 string_file.string(), simple_annotations_0->entries[0].value));
379 EXPECT_EQ(kKey0A, 408 EXPECT_EQ(kKey0A,
380 MinidumpUTF8StringAtRVAAsString( 409 MinidumpUTF8StringAtRVAAsString(
381 string_file.string(), simple_annotations_0->entries[1].key)); 410 string_file.string(), simple_annotations_0->entries[1].key));
382 EXPECT_EQ(kValue0A, 411 EXPECT_EQ(kValue0A,
383 MinidumpUTF8StringAtRVAAsString( 412 MinidumpUTF8StringAtRVAAsString(
384 string_file.string(), simple_annotations_0->entries[1].value)); 413 string_file.string(), simple_annotations_0->entries[1].value));
385 414
415 EXPECT_EQ(2u, module_list->modules[1].minidump_module_list_index);
386 const MinidumpModuleCrashpadInfo* module_2 = 416 const MinidumpModuleCrashpadInfo* module_2 =
387 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 417 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
388 string_file.string(), module_list->children[1]); 418 string_file.string(), module_list->modules[1].location);
389 ASSERT_TRUE(module_2); 419 ASSERT_TRUE(module_2);
390 420
391 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version); 421 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_2->version);
392 EXPECT_EQ(2u, module_2->minidump_module_list_index);
393 422
394 const MinidumpRVAList* list_annotations_2 = 423 const MinidumpRVAList* list_annotations_2 =
395 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 424 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
396 string_file.string(), module_2->list_annotations); 425 string_file.string(), module_2->list_annotations);
397 EXPECT_FALSE(list_annotations_2); 426 EXPECT_FALSE(list_annotations_2);
398 427
399 const MinidumpSimpleStringDictionary* simple_annotations_2 = 428 const MinidumpSimpleStringDictionary* simple_annotations_2 =
400 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 429 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
401 string_file.string(), module_2->simple_annotations); 430 string_file.string(), module_2->simple_annotations);
402 ASSERT_TRUE(simple_annotations_2); 431 ASSERT_TRUE(simple_annotations_2);
403 432
404 ASSERT_EQ(annotations_simple_map_2.size(), simple_annotations_2->count); 433 ASSERT_EQ(annotations_simple_map_2.size(), simple_annotations_2->count);
405 EXPECT_EQ(kKey2, 434 EXPECT_EQ(kKey2,
406 MinidumpUTF8StringAtRVAAsString( 435 MinidumpUTF8StringAtRVAAsString(
407 string_file.string(), simple_annotations_2->entries[0].key)); 436 string_file.string(), simple_annotations_2->entries[0].key));
408 EXPECT_EQ(kValue2, 437 EXPECT_EQ(kValue2,
409 MinidumpUTF8StringAtRVAAsString( 438 MinidumpUTF8StringAtRVAAsString(
410 string_file.string(), simple_annotations_2->entries[0].value)); 439 string_file.string(), simple_annotations_2->entries[0].value));
411 440
441 EXPECT_EQ(3u, module_list->modules[2].minidump_module_list_index);
412 const MinidumpModuleCrashpadInfo* module_3 = 442 const MinidumpModuleCrashpadInfo* module_3 =
413 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 443 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
414 string_file.string(), module_list->children[2]); 444 string_file.string(), module_list->modules[2].location);
415 ASSERT_TRUE(module_3); 445 ASSERT_TRUE(module_3);
416 446
417 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_3->version); 447 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module_3->version);
418 EXPECT_EQ(3u, module_3->minidump_module_list_index);
419 448
420 const MinidumpRVAList* list_annotations_3 = 449 const MinidumpRVAList* list_annotations_3 =
421 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 450 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
422 string_file.string(), module_3->list_annotations); 451 string_file.string(), module_3->list_annotations);
423 ASSERT_TRUE(list_annotations_3); 452 ASSERT_TRUE(list_annotations_3);
424 453
425 ASSERT_EQ(annotations_vector_3.size(), list_annotations_3->count); 454 ASSERT_EQ(annotations_vector_3.size(), list_annotations_3->count);
426 EXPECT_EQ(kEntry3A, 455 EXPECT_EQ(kEntry3A,
427 MinidumpUTF8StringAtRVAAsString( 456 MinidumpUTF8StringAtRVAAsString(string_file.string(),
428 string_file.string(), list_annotations_3->children[0])); 457 list_annotations_3->children[0]));
429 EXPECT_EQ(kEntry3B, 458 EXPECT_EQ(kEntry3B,
430 MinidumpUTF8StringAtRVAAsString( 459 MinidumpUTF8StringAtRVAAsString(string_file.string(),
431 string_file.string(), list_annotations_3->children[1])); 460 list_annotations_3->children[1]));
432 461
433 const MinidumpSimpleStringDictionary* simple_annotations_3 = 462 const MinidumpSimpleStringDictionary* simple_annotations_3 =
434 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 463 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
435 string_file.string(), module_3->simple_annotations); 464 string_file.string(), module_3->simple_annotations);
436 EXPECT_FALSE(simple_annotations_3); 465 EXPECT_FALSE(simple_annotations_3);
437 } 466 }
438 467
439 } // namespace 468 } // namespace
440 } // namespace test 469 } // namespace test
441 } // namespace crashpad 470 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_module_crashpad_info_writer.cc ('k') | minidump/test/minidump_location_descriptor_list_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698