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 19 matching lines...) Expand all Loading... |
30 #include "minidump/minidump_thread_id_map.h" | 30 #include "minidump/minidump_thread_id_map.h" |
31 #include "minidump/test/minidump_context_test_util.h" | 31 #include "minidump/test/minidump_context_test_util.h" |
32 #include "minidump/test/minidump_memory_writer_test_util.h" | 32 #include "minidump/test/minidump_memory_writer_test_util.h" |
33 #include "minidump/test/minidump_file_writer_test_util.h" | 33 #include "minidump/test/minidump_file_writer_test_util.h" |
34 #include "minidump/test/minidump_writable_test_util.h" | 34 #include "minidump/test/minidump_writable_test_util.h" |
35 #include "snapshot/test/test_cpu_context.h" | 35 #include "snapshot/test/test_cpu_context.h" |
36 #include "snapshot/test/test_memory_snapshot.h" | 36 #include "snapshot/test/test_memory_snapshot.h" |
37 #include "snapshot/test/test_thread_snapshot.h" | 37 #include "snapshot/test/test_thread_snapshot.h" |
38 #include "test/gtest_death_check.h" | 38 #include "test/gtest_death_check.h" |
39 #include "util/file/string_file.h" | 39 #include "util/file/string_file.h" |
| 40 #include "util/stdlib/move.h" |
40 | 41 |
41 namespace crashpad { | 42 namespace crashpad { |
42 namespace test { | 43 namespace test { |
43 namespace { | 44 namespace { |
44 | 45 |
45 // This returns the MINIDUMP_THREAD_LIST stream in |thread_list|. If | 46 // This returns the MINIDUMP_THREAD_LIST stream in |thread_list|. If |
46 // |memory_list| is not nullptr, a MINIDUMP_MEMORY_LIST stream is also expected | 47 // |memory_list| is not nullptr, a MINIDUMP_MEMORY_LIST stream is also expected |
47 // in |file_contents|, and that stream will be returned in |memory_list|. | 48 // in |file_contents|, and that stream will be returned in |memory_list|. |
48 void GetThreadListStream(const std::string& file_contents, | 49 void GetThreadListStream(const std::string& file_contents, |
49 const MINIDUMP_THREAD_LIST** thread_list, | 50 const MINIDUMP_THREAD_LIST** thread_list, |
(...skipping 26 matching lines...) Expand all Loading... |
76 *memory_list = MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>( | 77 *memory_list = MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>( |
77 file_contents, directory[1].Location); | 78 file_contents, directory[1].Location); |
78 ASSERT_TRUE(*memory_list); | 79 ASSERT_TRUE(*memory_list); |
79 } | 80 } |
80 } | 81 } |
81 | 82 |
82 TEST(MinidumpThreadWriter, EmptyThreadList) { | 83 TEST(MinidumpThreadWriter, EmptyThreadList) { |
83 MinidumpFileWriter minidump_file_writer; | 84 MinidumpFileWriter minidump_file_writer; |
84 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 85 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); |
85 | 86 |
86 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 87 minidump_file_writer.AddStream(crashpad::move(thread_list_writer)); |
87 | 88 |
88 StringFile string_file; | 89 StringFile string_file; |
89 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 90 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
90 | 91 |
91 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + | 92 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + |
92 sizeof(MINIDUMP_THREAD_LIST), | 93 sizeof(MINIDUMP_THREAD_LIST), |
93 string_file.string().size()); | 94 string_file.string().size()); |
94 | 95 |
95 const MINIDUMP_THREAD_LIST* thread_list = nullptr; | 96 const MINIDUMP_THREAD_LIST* thread_list = nullptr; |
96 ASSERT_NO_FATAL_FAILURE( | 97 ASSERT_NO_FATAL_FAILURE( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 154 |
154 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); | 155 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); |
155 thread_writer->SetThreadID(kThreadID); | 156 thread_writer->SetThreadID(kThreadID); |
156 thread_writer->SetSuspendCount(kSuspendCount); | 157 thread_writer->SetSuspendCount(kSuspendCount); |
157 thread_writer->SetPriorityClass(kPriorityClass); | 158 thread_writer->SetPriorityClass(kPriorityClass); |
158 thread_writer->SetPriority(kPriority); | 159 thread_writer->SetPriority(kPriority); |
159 thread_writer->SetTEB(kTEB); | 160 thread_writer->SetTEB(kTEB); |
160 | 161 |
161 auto context_x86_writer = make_scoped_ptr(new MinidumpContextX86Writer()); | 162 auto context_x86_writer = make_scoped_ptr(new MinidumpContextX86Writer()); |
162 InitializeMinidumpContextX86(context_x86_writer->context(), kSeed); | 163 InitializeMinidumpContextX86(context_x86_writer->context(), kSeed); |
163 thread_writer->SetContext(context_x86_writer.Pass()); | 164 thread_writer->SetContext(crashpad::move(context_x86_writer)); |
164 | 165 |
165 thread_list_writer->AddThread(thread_writer.Pass()); | 166 thread_list_writer->AddThread(crashpad::move(thread_writer)); |
166 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 167 minidump_file_writer.AddStream(crashpad::move(thread_list_writer)); |
167 | 168 |
168 StringFile string_file; | 169 StringFile string_file; |
169 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 170 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
170 | 171 |
171 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + | 172 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + |
172 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + | 173 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + |
173 1 * sizeof(MinidumpContextX86), | 174 1 * sizeof(MinidumpContextX86), |
174 string_file.string().size()); | 175 string_file.string().size()); |
175 | 176 |
176 const MINIDUMP_THREAD_LIST* thread_list = nullptr; | 177 const MINIDUMP_THREAD_LIST* thread_list = nullptr; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 216 |
216 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); | 217 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); |
217 thread_writer->SetThreadID(kThreadID); | 218 thread_writer->SetThreadID(kThreadID); |
218 thread_writer->SetSuspendCount(kSuspendCount); | 219 thread_writer->SetSuspendCount(kSuspendCount); |
219 thread_writer->SetPriorityClass(kPriorityClass); | 220 thread_writer->SetPriorityClass(kPriorityClass); |
220 thread_writer->SetPriority(kPriority); | 221 thread_writer->SetPriority(kPriority); |
221 thread_writer->SetTEB(kTEB); | 222 thread_writer->SetTEB(kTEB); |
222 | 223 |
223 auto memory_writer = make_scoped_ptr( | 224 auto memory_writer = make_scoped_ptr( |
224 new TestMinidumpMemoryWriter(kMemoryBase, kMemorySize, kMemoryValue)); | 225 new TestMinidumpMemoryWriter(kMemoryBase, kMemorySize, kMemoryValue)); |
225 thread_writer->SetStack(memory_writer.Pass()); | 226 thread_writer->SetStack(crashpad::move(memory_writer)); |
226 | 227 |
227 MSVC_SUPPRESS_WARNING(4316); // Object allocated on heap may not be aligned. | 228 MSVC_SUPPRESS_WARNING(4316); // Object allocated on heap may not be aligned. |
228 auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer()); | 229 auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer()); |
229 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); | 230 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); |
230 thread_writer->SetContext(context_amd64_writer.Pass()); | 231 thread_writer->SetContext(crashpad::move(context_amd64_writer)); |
231 | 232 |
232 thread_list_writer->AddThread(thread_writer.Pass()); | 233 thread_list_writer->AddThread(crashpad::move(thread_writer)); |
233 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 234 minidump_file_writer.AddStream(crashpad::move(thread_list_writer)); |
234 | 235 |
235 StringFile string_file; | 236 StringFile string_file; |
236 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 237 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
237 | 238 |
238 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + | 239 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + |
239 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + | 240 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + |
240 1 * sizeof(MinidumpContextAMD64) + kMemorySize, | 241 1 * sizeof(MinidumpContextAMD64) + kMemorySize, |
241 string_file.string().size()); | 242 string_file.string().size()); |
242 | 243 |
243 const MINIDUMP_THREAD_LIST* thread_list = nullptr; | 244 const MINIDUMP_THREAD_LIST* thread_list = nullptr; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 294 |
294 auto thread_writer_0 = make_scoped_ptr(new MinidumpThreadWriter()); | 295 auto thread_writer_0 = make_scoped_ptr(new MinidumpThreadWriter()); |
295 thread_writer_0->SetThreadID(kThreadID0); | 296 thread_writer_0->SetThreadID(kThreadID0); |
296 thread_writer_0->SetSuspendCount(kSuspendCount0); | 297 thread_writer_0->SetSuspendCount(kSuspendCount0); |
297 thread_writer_0->SetPriorityClass(kPriorityClass0); | 298 thread_writer_0->SetPriorityClass(kPriorityClass0); |
298 thread_writer_0->SetPriority(kPriority0); | 299 thread_writer_0->SetPriority(kPriority0); |
299 thread_writer_0->SetTEB(kTEB0); | 300 thread_writer_0->SetTEB(kTEB0); |
300 | 301 |
301 auto memory_writer_0 = make_scoped_ptr( | 302 auto memory_writer_0 = make_scoped_ptr( |
302 new TestMinidumpMemoryWriter(kMemoryBase0, kMemorySize0, kMemoryValue0)); | 303 new TestMinidumpMemoryWriter(kMemoryBase0, kMemorySize0, kMemoryValue0)); |
303 thread_writer_0->SetStack(memory_writer_0.Pass()); | 304 thread_writer_0->SetStack(crashpad::move(memory_writer_0)); |
304 | 305 |
305 auto context_x86_writer_0 = make_scoped_ptr(new MinidumpContextX86Writer()); | 306 auto context_x86_writer_0 = make_scoped_ptr(new MinidumpContextX86Writer()); |
306 InitializeMinidumpContextX86(context_x86_writer_0->context(), kSeed0); | 307 InitializeMinidumpContextX86(context_x86_writer_0->context(), kSeed0); |
307 thread_writer_0->SetContext(context_x86_writer_0.Pass()); | 308 thread_writer_0->SetContext(crashpad::move(context_x86_writer_0)); |
308 | 309 |
309 thread_list_writer->AddThread(thread_writer_0.Pass()); | 310 thread_list_writer->AddThread(crashpad::move(thread_writer_0)); |
310 | 311 |
311 const uint32_t kThreadID1 = 2222222; | 312 const uint32_t kThreadID1 = 2222222; |
312 const uint32_t kSuspendCount1 = 222222; | 313 const uint32_t kSuspendCount1 = 222222; |
313 const uint32_t kPriorityClass1 = 22222; | 314 const uint32_t kPriorityClass1 = 22222; |
314 const uint32_t kPriority1 = 2222; | 315 const uint32_t kPriority1 = 2222; |
315 const uint64_t kTEB1 = 222; | 316 const uint64_t kTEB1 = 222; |
316 const uint64_t kMemoryBase1 = 0x2220; | 317 const uint64_t kMemoryBase1 = 0x2220; |
317 const size_t kMemorySize1 = 32; | 318 const size_t kMemorySize1 = 32; |
318 const uint8_t kMemoryValue1 = 22; | 319 const uint8_t kMemoryValue1 = 22; |
319 const uint32_t kSeed1 = 2; | 320 const uint32_t kSeed1 = 2; |
320 | 321 |
321 auto thread_writer_1 = make_scoped_ptr(new MinidumpThreadWriter()); | 322 auto thread_writer_1 = make_scoped_ptr(new MinidumpThreadWriter()); |
322 thread_writer_1->SetThreadID(kThreadID1); | 323 thread_writer_1->SetThreadID(kThreadID1); |
323 thread_writer_1->SetSuspendCount(kSuspendCount1); | 324 thread_writer_1->SetSuspendCount(kSuspendCount1); |
324 thread_writer_1->SetPriorityClass(kPriorityClass1); | 325 thread_writer_1->SetPriorityClass(kPriorityClass1); |
325 thread_writer_1->SetPriority(kPriority1); | 326 thread_writer_1->SetPriority(kPriority1); |
326 thread_writer_1->SetTEB(kTEB1); | 327 thread_writer_1->SetTEB(kTEB1); |
327 | 328 |
328 auto memory_writer_1 = make_scoped_ptr( | 329 auto memory_writer_1 = make_scoped_ptr( |
329 new TestMinidumpMemoryWriter(kMemoryBase1, kMemorySize1, kMemoryValue1)); | 330 new TestMinidumpMemoryWriter(kMemoryBase1, kMemorySize1, kMemoryValue1)); |
330 thread_writer_1->SetStack(memory_writer_1.Pass()); | 331 thread_writer_1->SetStack(crashpad::move(memory_writer_1)); |
331 | 332 |
332 auto context_x86_writer_1 = make_scoped_ptr(new MinidumpContextX86Writer()); | 333 auto context_x86_writer_1 = make_scoped_ptr(new MinidumpContextX86Writer()); |
333 InitializeMinidumpContextX86(context_x86_writer_1->context(), kSeed1); | 334 InitializeMinidumpContextX86(context_x86_writer_1->context(), kSeed1); |
334 thread_writer_1->SetContext(context_x86_writer_1.Pass()); | 335 thread_writer_1->SetContext(crashpad::move(context_x86_writer_1)); |
335 | 336 |
336 thread_list_writer->AddThread(thread_writer_1.Pass()); | 337 thread_list_writer->AddThread(crashpad::move(thread_writer_1)); |
337 | 338 |
338 const uint32_t kThreadID2 = 3333333; | 339 const uint32_t kThreadID2 = 3333333; |
339 const uint32_t kSuspendCount2 = 333333; | 340 const uint32_t kSuspendCount2 = 333333; |
340 const uint32_t kPriorityClass2 = 33333; | 341 const uint32_t kPriorityClass2 = 33333; |
341 const uint32_t kPriority2 = 3333; | 342 const uint32_t kPriority2 = 3333; |
342 const uint64_t kTEB2 = 333; | 343 const uint64_t kTEB2 = 333; |
343 const uint64_t kMemoryBase2 = 0x3330; | 344 const uint64_t kMemoryBase2 = 0x3330; |
344 const size_t kMemorySize2 = 48; | 345 const size_t kMemorySize2 = 48; |
345 const uint8_t kMemoryValue2 = 33; | 346 const uint8_t kMemoryValue2 = 33; |
346 const uint32_t kSeed2 = 3; | 347 const uint32_t kSeed2 = 3; |
347 | 348 |
348 auto thread_writer_2 = make_scoped_ptr(new MinidumpThreadWriter()); | 349 auto thread_writer_2 = make_scoped_ptr(new MinidumpThreadWriter()); |
349 thread_writer_2->SetThreadID(kThreadID2); | 350 thread_writer_2->SetThreadID(kThreadID2); |
350 thread_writer_2->SetSuspendCount(kSuspendCount2); | 351 thread_writer_2->SetSuspendCount(kSuspendCount2); |
351 thread_writer_2->SetPriorityClass(kPriorityClass2); | 352 thread_writer_2->SetPriorityClass(kPriorityClass2); |
352 thread_writer_2->SetPriority(kPriority2); | 353 thread_writer_2->SetPriority(kPriority2); |
353 thread_writer_2->SetTEB(kTEB2); | 354 thread_writer_2->SetTEB(kTEB2); |
354 | 355 |
355 auto memory_writer_2 = make_scoped_ptr( | 356 auto memory_writer_2 = make_scoped_ptr( |
356 new TestMinidumpMemoryWriter(kMemoryBase2, kMemorySize2, kMemoryValue2)); | 357 new TestMinidumpMemoryWriter(kMemoryBase2, kMemorySize2, kMemoryValue2)); |
357 thread_writer_2->SetStack(memory_writer_2.Pass()); | 358 thread_writer_2->SetStack(crashpad::move(memory_writer_2)); |
358 | 359 |
359 auto context_x86_writer_2 = make_scoped_ptr(new MinidumpContextX86Writer()); | 360 auto context_x86_writer_2 = make_scoped_ptr(new MinidumpContextX86Writer()); |
360 InitializeMinidumpContextX86(context_x86_writer_2->context(), kSeed2); | 361 InitializeMinidumpContextX86(context_x86_writer_2->context(), kSeed2); |
361 thread_writer_2->SetContext(context_x86_writer_2.Pass()); | 362 thread_writer_2->SetContext(crashpad::move(context_x86_writer_2)); |
362 | 363 |
363 thread_list_writer->AddThread(thread_writer_2.Pass()); | 364 thread_list_writer->AddThread(crashpad::move(thread_writer_2)); |
364 | 365 |
365 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 366 minidump_file_writer.AddStream(crashpad::move(thread_list_writer)); |
366 minidump_file_writer.AddStream(memory_list_writer.Pass()); | 367 minidump_file_writer.AddStream(crashpad::move(memory_list_writer)); |
367 | 368 |
368 StringFile string_file; | 369 StringFile string_file; |
369 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 370 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
370 | 371 |
371 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + 2 * sizeof(MINIDUMP_DIRECTORY) + | 372 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + 2 * sizeof(MINIDUMP_DIRECTORY) + |
372 sizeof(MINIDUMP_THREAD_LIST) + 3 * sizeof(MINIDUMP_THREAD) + | 373 sizeof(MINIDUMP_THREAD_LIST) + 3 * sizeof(MINIDUMP_THREAD) + |
373 sizeof(MINIDUMP_MEMORY_LIST) + | 374 sizeof(MINIDUMP_MEMORY_LIST) + |
374 3 * sizeof(MINIDUMP_MEMORY_DESCRIPTOR) + | 375 3 * sizeof(MINIDUMP_MEMORY_DESCRIPTOR) + |
375 3 * sizeof(MinidumpContextX86) + kMemorySize0 + kMemorySize1 + | 376 3 * sizeof(MinidumpContextX86) + kMemorySize0 + kMemorySize1 + |
376 kMemorySize2 + 12, // 12 for alignment | 377 kMemorySize2 + 12, // 12 for alignment |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount); | 594 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount); |
594 thread_snapshot->SetPriority(expect_threads[index].Priority); | 595 thread_snapshot->SetPriority(expect_threads[index].Priority); |
595 thread_snapshot->SetThreadSpecificDataAddress(expect_threads[index].Teb); | 596 thread_snapshot->SetThreadSpecificDataAddress(expect_threads[index].Teb); |
596 | 597 |
597 if (expect_threads[index].Stack.Memory.DataSize) { | 598 if (expect_threads[index].Stack.Memory.DataSize) { |
598 auto memory_snapshot = make_scoped_ptr(new TestMemorySnapshot()); | 599 auto memory_snapshot = make_scoped_ptr(new TestMemorySnapshot()); |
599 memory_snapshot->SetAddress( | 600 memory_snapshot->SetAddress( |
600 expect_threads[index].Stack.StartOfMemoryRange); | 601 expect_threads[index].Stack.StartOfMemoryRange); |
601 memory_snapshot->SetSize(expect_threads[index].Stack.Memory.DataSize); | 602 memory_snapshot->SetSize(expect_threads[index].Stack.Memory.DataSize); |
602 memory_snapshot->SetValue(memory_values[index]); | 603 memory_snapshot->SetValue(memory_values[index]); |
603 thread_snapshot->SetStack(memory_snapshot.Pass()); | 604 thread_snapshot->SetStack(crashpad::move(memory_snapshot)); |
604 } | 605 } |
605 | 606 |
606 Traits::InitializeCPUContext(thread_snapshot->MutableContext(), | 607 Traits::InitializeCPUContext(thread_snapshot->MutableContext(), |
607 context_seeds[index]); | 608 context_seeds[index]); |
608 | 609 |
609 auto teb_snapshot = make_scoped_ptr(new TestMemorySnapshot()); | 610 auto teb_snapshot = make_scoped_ptr(new TestMemorySnapshot()); |
610 teb_snapshot->SetAddress(expect_threads[index].Teb); | 611 teb_snapshot->SetAddress(expect_threads[index].Teb); |
611 teb_snapshot->SetSize(kTebSize); | 612 teb_snapshot->SetSize(kTebSize); |
612 teb_snapshot->SetValue(static_cast<char>('t' + index)); | 613 teb_snapshot->SetValue(static_cast<char>('t' + index)); |
613 thread_snapshot->AddExtraMemory(teb_snapshot.Pass()); | 614 thread_snapshot->AddExtraMemory(crashpad::move(teb_snapshot)); |
614 | 615 |
615 thread_snapshots.push_back(thread_snapshot); | 616 thread_snapshots.push_back(thread_snapshot); |
616 } | 617 } |
617 | 618 |
618 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 619 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); |
619 auto memory_list_writer = make_scoped_ptr(new MinidumpMemoryListWriter()); | 620 auto memory_list_writer = make_scoped_ptr(new MinidumpMemoryListWriter()); |
620 thread_list_writer->SetMemoryListWriter(memory_list_writer.get()); | 621 thread_list_writer->SetMemoryListWriter(memory_list_writer.get()); |
621 MinidumpThreadIDMap thread_id_map; | 622 MinidumpThreadIDMap thread_id_map; |
622 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map); | 623 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map); |
623 | 624 |
624 MinidumpFileWriter minidump_file_writer; | 625 MinidumpFileWriter minidump_file_writer; |
625 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 626 minidump_file_writer.AddStream(crashpad::move(thread_list_writer)); |
626 minidump_file_writer.AddStream(memory_list_writer.Pass()); | 627 minidump_file_writer.AddStream(crashpad::move(memory_list_writer)); |
627 | 628 |
628 StringFile string_file; | 629 StringFile string_file; |
629 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 630 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
630 | 631 |
631 const MINIDUMP_THREAD_LIST* thread_list = nullptr; | 632 const MINIDUMP_THREAD_LIST* thread_list = nullptr; |
632 const MINIDUMP_MEMORY_LIST* memory_list = nullptr; | 633 const MINIDUMP_MEMORY_LIST* memory_list = nullptr; |
633 ASSERT_NO_FATAL_FAILURE( | 634 ASSERT_NO_FATAL_FAILURE( |
634 GetThreadListStream(string_file.string(), &thread_list, &memory_list)); | 635 GetThreadListStream(string_file.string(), &thread_list, &memory_list)); |
635 | 636 |
636 ASSERT_EQ(3u, thread_list->NumberOfThreads); | 637 ASSERT_EQ(3u, thread_list->NumberOfThreads); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 TEST(MinidumpThreadWriter, InitializeFromSnapshot_ThreadIDCollision) { | 694 TEST(MinidumpThreadWriter, InitializeFromSnapshot_ThreadIDCollision) { |
694 RunInitializeFromSnapshotTest<InitializeFromSnapshotX86Traits>(true); | 695 RunInitializeFromSnapshotTest<InitializeFromSnapshotX86Traits>(true); |
695 } | 696 } |
696 | 697 |
697 TEST(MinidumpThreadWriterDeathTest, NoContext) { | 698 TEST(MinidumpThreadWriterDeathTest, NoContext) { |
698 MinidumpFileWriter minidump_file_writer; | 699 MinidumpFileWriter minidump_file_writer; |
699 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 700 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); |
700 | 701 |
701 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); | 702 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); |
702 | 703 |
703 thread_list_writer->AddThread(thread_writer.Pass()); | 704 thread_list_writer->AddThread(crashpad::move(thread_writer)); |
704 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 705 minidump_file_writer.AddStream(crashpad::move(thread_list_writer)); |
705 | 706 |
706 StringFile string_file; | 707 StringFile string_file; |
707 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), | 708 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), |
708 "context_"); | 709 "context_"); |
709 } | 710 } |
710 | 711 |
711 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { | 712 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { |
712 ASSERT_DEATH_CHECK( | 713 ASSERT_DEATH_CHECK( |
713 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( | 714 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( |
714 false), "context_"); | 715 false), "context_"); |
715 } | 716 } |
716 | 717 |
717 } // namespace | 718 } // namespace |
718 } // namespace test | 719 } // namespace test |
719 } // namespace crashpad | 720 } // namespace crashpad |
OLD | NEW |