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

Side by Side Diff: minidump/minidump_thread_writer_test.cc

Issue 903603002: win: warning fixes in minidump_thread_writer_test.cc (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@minidump_test-9
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 minidump_file_writer.AddStream(thread_list_writer.Pass()); 81 minidump_file_writer.AddStream(thread_list_writer.Pass());
82 82
83 StringFileWriter file_writer; 83 StringFileWriter file_writer;
84 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 84 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
85 85
86 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 86 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
87 sizeof(MINIDUMP_THREAD_LIST), 87 sizeof(MINIDUMP_THREAD_LIST),
88 file_writer.string().size()); 88 file_writer.string().size());
89 89
90 const MINIDUMP_THREAD_LIST* thread_list; 90 const MINIDUMP_THREAD_LIST* thread_list = nullptr;
91 ASSERT_NO_FATAL_FAILURE( 91 ASSERT_NO_FATAL_FAILURE(
92 GetThreadListStream(file_writer.string(), &thread_list, nullptr)); 92 GetThreadListStream(file_writer.string(), &thread_list, nullptr));
93 93
94 EXPECT_EQ(0u, thread_list->NumberOfThreads); 94 EXPECT_EQ(0u, thread_list->NumberOfThreads);
95 } 95 }
96 96
97 // The MINIDUMP_THREADs |expected| and |observed| are compared against each 97 // The MINIDUMP_THREADs |expected| and |observed| are compared against each
98 // other using gtest assertions. If |stack| is not nullptr, |observed| is 98 // other using gtest assertions. If |stack| is not nullptr, |observed| is
99 // expected to contain a populated MINIDUMP_MEMORY_DESCRIPTOR in its Stack 99 // expected to contain a populated MINIDUMP_MEMORY_DESCRIPTOR in its Stack
100 // field, otherwise, its Stack field is expected to be zeroed out. The memory 100 // field, otherwise, its Stack field is expected to be zeroed out. The memory
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 minidump_file_writer.AddStream(thread_list_writer.Pass()); 161 minidump_file_writer.AddStream(thread_list_writer.Pass());
162 162
163 StringFileWriter file_writer; 163 StringFileWriter file_writer;
164 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 164 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
165 165
166 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 166 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
167 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + 167 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) +
168 1 * sizeof(MinidumpContextX86), 168 1 * sizeof(MinidumpContextX86),
169 file_writer.string().size()); 169 file_writer.string().size());
170 170
171 const MINIDUMP_THREAD_LIST* thread_list; 171 const MINIDUMP_THREAD_LIST* thread_list = nullptr;
172 ASSERT_NO_FATAL_FAILURE( 172 ASSERT_NO_FATAL_FAILURE(
173 GetThreadListStream(file_writer.string(), &thread_list, nullptr)); 173 GetThreadListStream(file_writer.string(), &thread_list, nullptr));
174 174
175 EXPECT_EQ(1u, thread_list->NumberOfThreads); 175 EXPECT_EQ(1u, thread_list->NumberOfThreads);
176 176
177 MINIDUMP_THREAD expected = {}; 177 MINIDUMP_THREAD expected = {};
178 expected.ThreadId = kThreadID; 178 expected.ThreadId = kThreadID;
179 expected.SuspendCount = kSuspendCount; 179 expected.SuspendCount = kSuspendCount;
180 expected.PriorityClass = kPriorityClass; 180 expected.PriorityClass = kPriorityClass;
181 expected.Priority = kPriority; 181 expected.Priority = kPriority;
182 expected.Teb = kTEB; 182 expected.Teb = kTEB;
183 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); 183 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86);
184 184
185 const MinidumpContextX86* observed_context; 185 const MinidumpContextX86* observed_context = nullptr;
186 ASSERT_NO_FATAL_FAILURE( 186 ASSERT_NO_FATAL_FAILURE(
187 ExpectThread(&expected, 187 ExpectThread(&expected,
188 &thread_list->Threads[0], 188 &thread_list->Threads[0],
189 file_writer.string(), 189 file_writer.string(),
190 nullptr, 190 nullptr,
191 reinterpret_cast<const void**>(&observed_context))); 191 reinterpret_cast<const void**>(&observed_context)));
192 192
193 ASSERT_NO_FATAL_FAILURE( 193 ASSERT_NO_FATAL_FAILURE(
194 ExpectMinidumpContextX86(kSeed, observed_context, false)); 194 ExpectMinidumpContextX86(kSeed, observed_context, false));
195 } 195 }
(...skipping 16 matching lines...) Expand all
212 thread_writer->SetThreadID(kThreadID); 212 thread_writer->SetThreadID(kThreadID);
213 thread_writer->SetSuspendCount(kSuspendCount); 213 thread_writer->SetSuspendCount(kSuspendCount);
214 thread_writer->SetPriorityClass(kPriorityClass); 214 thread_writer->SetPriorityClass(kPriorityClass);
215 thread_writer->SetPriority(kPriority); 215 thread_writer->SetPriority(kPriority);
216 thread_writer->SetTEB(kTEB); 216 thread_writer->SetTEB(kTEB);
217 217
218 auto memory_writer = make_scoped_ptr( 218 auto memory_writer = make_scoped_ptr(
219 new TestMinidumpMemoryWriter(kMemoryBase, kMemorySize, kMemoryValue)); 219 new TestMinidumpMemoryWriter(kMemoryBase, kMemorySize, kMemoryValue));
220 thread_writer->SetStack(memory_writer.Pass()); 220 thread_writer->SetStack(memory_writer.Pass());
221 221
222 #if defined(OS_WIN) && defined(ARCH_CPU_X86)
223 #pragma warning(push)
224 #pragma warning(disable: 4316) // Object allocated on heap may not be aligned.
Mark Mentovai 2015/02/05 14:27:41 And if this one shows up frequently, maybe we shou
scottmg 2015/02/05 17:50:42 Switched to shorter MSVC_SUPPRESS_WARNING. Hiding
225 #endif // OS_WIN && ARCH_CPU_X86
222 auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer()); 226 auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer());
227 #if defined(OS_WIN) && defined(ARCH_CPU_X86)
228 #pragma warning(pop)
229 #endif // OS_WIN && ARCH_CPU_X86
223 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); 230 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed);
224 thread_writer->SetContext(context_amd64_writer.Pass()); 231 thread_writer->SetContext(context_amd64_writer.Pass());
225 232
226 thread_list_writer->AddThread(thread_writer.Pass()); 233 thread_list_writer->AddThread(thread_writer.Pass());
227 minidump_file_writer.AddStream(thread_list_writer.Pass()); 234 minidump_file_writer.AddStream(thread_list_writer.Pass());
228 235
229 StringFileWriter file_writer; 236 StringFileWriter file_writer;
230 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 237 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
231 238
232 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 239 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
233 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + 240 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) +
234 1 * sizeof(MinidumpContextAMD64) + kMemorySize, 241 1 * sizeof(MinidumpContextAMD64) + kMemorySize,
235 file_writer.string().size()); 242 file_writer.string().size());
236 243
237 const MINIDUMP_THREAD_LIST* thread_list; 244 const MINIDUMP_THREAD_LIST* thread_list = nullptr;
238 ASSERT_NO_FATAL_FAILURE( 245 ASSERT_NO_FATAL_FAILURE(
239 GetThreadListStream(file_writer.string(), &thread_list, nullptr)); 246 GetThreadListStream(file_writer.string(), &thread_list, nullptr));
240 247
241 EXPECT_EQ(1u, thread_list->NumberOfThreads); 248 EXPECT_EQ(1u, thread_list->NumberOfThreads);
242 249
243 MINIDUMP_THREAD expected = {}; 250 MINIDUMP_THREAD expected = {};
244 expected.ThreadId = kThreadID; 251 expected.ThreadId = kThreadID;
245 expected.SuspendCount = kSuspendCount; 252 expected.SuspendCount = kSuspendCount;
246 expected.PriorityClass = kPriorityClass; 253 expected.PriorityClass = kPriorityClass;
247 expected.Priority = kPriority; 254 expected.Priority = kPriority;
248 expected.Teb = kTEB; 255 expected.Teb = kTEB;
249 expected.Stack.StartOfMemoryRange = kMemoryBase; 256 expected.Stack.StartOfMemoryRange = kMemoryBase;
250 expected.Stack.Memory.DataSize = kMemorySize; 257 expected.Stack.Memory.DataSize = kMemorySize;
251 expected.ThreadContext.DataSize = sizeof(MinidumpContextAMD64); 258 expected.ThreadContext.DataSize = sizeof(MinidumpContextAMD64);
252 259
253 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; 260 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr;
254 const MinidumpContextAMD64* observed_context; 261 const MinidumpContextAMD64* observed_context = nullptr;
255 ASSERT_NO_FATAL_FAILURE( 262 ASSERT_NO_FATAL_FAILURE(
256 ExpectThread(&expected, 263 ExpectThread(&expected,
257 &thread_list->Threads[0], 264 &thread_list->Threads[0],
258 file_writer.string(), 265 file_writer.string(),
259 &observed_stack, 266 &observed_stack,
260 reinterpret_cast<const void**>(&observed_context))); 267 reinterpret_cast<const void**>(&observed_context)));
261 268
262 ASSERT_NO_FATAL_FAILURE( 269 ASSERT_NO_FATAL_FAILURE(
263 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 270 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
264 observed_stack, 271 observed_stack,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 370 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
364 371
365 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + 2 * sizeof(MINIDUMP_DIRECTORY) + 372 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + 2 * sizeof(MINIDUMP_DIRECTORY) +
366 sizeof(MINIDUMP_THREAD_LIST) + 3 * sizeof(MINIDUMP_THREAD) + 373 sizeof(MINIDUMP_THREAD_LIST) + 3 * sizeof(MINIDUMP_THREAD) +
367 sizeof(MINIDUMP_MEMORY_LIST) + 374 sizeof(MINIDUMP_MEMORY_LIST) +
368 3 * sizeof(MINIDUMP_MEMORY_DESCRIPTOR) + 375 3 * sizeof(MINIDUMP_MEMORY_DESCRIPTOR) +
369 3 * sizeof(MinidumpContextX86) + kMemorySize0 + kMemorySize1 + 376 3 * sizeof(MinidumpContextX86) + kMemorySize0 + kMemorySize1 +
370 kMemorySize2 + 12, // 12 for alignment 377 kMemorySize2 + 12, // 12 for alignment
371 file_writer.string().size()); 378 file_writer.string().size());
372 379
373 const MINIDUMP_THREAD_LIST* thread_list; 380 const MINIDUMP_THREAD_LIST* thread_list = nullptr;
374 const MINIDUMP_MEMORY_LIST* memory_list; 381 const MINIDUMP_MEMORY_LIST* memory_list = nullptr;
375 ASSERT_NO_FATAL_FAILURE( 382 ASSERT_NO_FATAL_FAILURE(
376 GetThreadListStream(file_writer.string(), &thread_list, &memory_list)); 383 GetThreadListStream(file_writer.string(), &thread_list, &memory_list));
377 384
378 EXPECT_EQ(3u, thread_list->NumberOfThreads); 385 EXPECT_EQ(3u, thread_list->NumberOfThreads);
379 EXPECT_EQ(3u, memory_list->NumberOfMemoryRanges); 386 EXPECT_EQ(3u, memory_list->NumberOfMemoryRanges);
380 387
381 { 388 {
382 SCOPED_TRACE("thread 0"); 389 SCOPED_TRACE("thread 0");
383 390
384 MINIDUMP_THREAD expected = {}; 391 MINIDUMP_THREAD expected = {};
385 expected.ThreadId = kThreadID0; 392 expected.ThreadId = kThreadID0;
386 expected.SuspendCount = kSuspendCount0; 393 expected.SuspendCount = kSuspendCount0;
387 expected.PriorityClass = kPriorityClass0; 394 expected.PriorityClass = kPriorityClass0;
388 expected.Priority = kPriority0; 395 expected.Priority = kPriority0;
389 expected.Teb = kTEB0; 396 expected.Teb = kTEB0;
390 expected.Stack.StartOfMemoryRange = kMemoryBase0; 397 expected.Stack.StartOfMemoryRange = kMemoryBase0;
391 expected.Stack.Memory.DataSize = kMemorySize0; 398 expected.Stack.Memory.DataSize = kMemorySize0;
392 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); 399 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86);
393 400
394 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; 401 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr;
395 const MinidumpContextX86* observed_context; 402 const MinidumpContextX86* observed_context = nullptr;
396 ASSERT_NO_FATAL_FAILURE( 403 ASSERT_NO_FATAL_FAILURE(
397 ExpectThread(&expected, 404 ExpectThread(&expected,
398 &thread_list->Threads[0], 405 &thread_list->Threads[0],
399 file_writer.string(), 406 file_writer.string(),
400 &observed_stack, 407 &observed_stack,
401 reinterpret_cast<const void**>(&observed_context))); 408 reinterpret_cast<const void**>(&observed_context)));
402 409
403 ASSERT_NO_FATAL_FAILURE( 410 ASSERT_NO_FATAL_FAILURE(
404 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 411 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
405 observed_stack, 412 observed_stack,
(...skipping 12 matching lines...) Expand all
418 MINIDUMP_THREAD expected = {}; 425 MINIDUMP_THREAD expected = {};
419 expected.ThreadId = kThreadID1; 426 expected.ThreadId = kThreadID1;
420 expected.SuspendCount = kSuspendCount1; 427 expected.SuspendCount = kSuspendCount1;
421 expected.PriorityClass = kPriorityClass1; 428 expected.PriorityClass = kPriorityClass1;
422 expected.Priority = kPriority1; 429 expected.Priority = kPriority1;
423 expected.Teb = kTEB1; 430 expected.Teb = kTEB1;
424 expected.Stack.StartOfMemoryRange = kMemoryBase1; 431 expected.Stack.StartOfMemoryRange = kMemoryBase1;
425 expected.Stack.Memory.DataSize = kMemorySize1; 432 expected.Stack.Memory.DataSize = kMemorySize1;
426 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); 433 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86);
427 434
428 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; 435 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr;
429 const MinidumpContextX86* observed_context; 436 const MinidumpContextX86* observed_context = nullptr;
430 ASSERT_NO_FATAL_FAILURE( 437 ASSERT_NO_FATAL_FAILURE(
431 ExpectThread(&expected, 438 ExpectThread(&expected,
432 &thread_list->Threads[1], 439 &thread_list->Threads[1],
433 file_writer.string(), 440 file_writer.string(),
434 &observed_stack, 441 &observed_stack,
435 reinterpret_cast<const void**>(&observed_context))); 442 reinterpret_cast<const void**>(&observed_context)));
436 443
437 ASSERT_NO_FATAL_FAILURE( 444 ASSERT_NO_FATAL_FAILURE(
438 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 445 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
439 observed_stack, 446 observed_stack,
(...skipping 12 matching lines...) Expand all
452 MINIDUMP_THREAD expected = {}; 459 MINIDUMP_THREAD expected = {};
453 expected.ThreadId = kThreadID2; 460 expected.ThreadId = kThreadID2;
454 expected.SuspendCount = kSuspendCount2; 461 expected.SuspendCount = kSuspendCount2;
455 expected.PriorityClass = kPriorityClass2; 462 expected.PriorityClass = kPriorityClass2;
456 expected.Priority = kPriority2; 463 expected.Priority = kPriority2;
457 expected.Teb = kTEB2; 464 expected.Teb = kTEB2;
458 expected.Stack.StartOfMemoryRange = kMemoryBase2; 465 expected.Stack.StartOfMemoryRange = kMemoryBase2;
459 expected.Stack.Memory.DataSize = kMemorySize2; 466 expected.Stack.Memory.DataSize = kMemorySize2;
460 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); 467 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86);
461 468
462 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; 469 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr;
463 const MinidumpContextX86* observed_context; 470 const MinidumpContextX86* observed_context = nullptr;
464 ASSERT_NO_FATAL_FAILURE( 471 ASSERT_NO_FATAL_FAILURE(
465 ExpectThread(&expected, 472 ExpectThread(&expected,
466 &thread_list->Threads[2], 473 &thread_list->Threads[2],
467 file_writer.string(), 474 file_writer.string(),
468 &observed_stack, 475 &observed_stack,
469 reinterpret_cast<const void**>(&observed_context))); 476 reinterpret_cast<const void**>(&observed_context)));
470 477
471 ASSERT_NO_FATAL_FAILURE( 478 ASSERT_NO_FATAL_FAILURE(
472 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 479 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
473 observed_stack, 480 observed_stack,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 thread_ids[0] = 0x0123456700000001; 563 thread_ids[0] = 0x0123456700000001;
557 thread_ids[1] = 0x89abcdef00000001; 564 thread_ids[1] = 0x89abcdef00000001;
558 thread_ids[2] = 4; 565 thread_ids[2] = 4;
559 expect_threads[0].ThreadId = 0; 566 expect_threads[0].ThreadId = 0;
560 expect_threads[1].ThreadId = 1; 567 expect_threads[1].ThreadId = 1;
561 expect_threads[2].ThreadId = 2; 568 expect_threads[2].ThreadId = 2;
562 } else { 569 } else {
563 thread_ids[0] = 1; 570 thread_ids[0] = 1;
564 thread_ids[1] = 11; 571 thread_ids[1] = 11;
565 thread_ids[2] = 22; 572 thread_ids[2] = 22;
566 expect_threads[0].ThreadId = thread_ids[0]; 573 expect_threads[0].ThreadId = static_cast<uint32_t>(thread_ids[0]);
567 expect_threads[1].ThreadId = thread_ids[1]; 574 expect_threads[1].ThreadId = static_cast<uint32_t>(thread_ids[1]);
568 expect_threads[2].ThreadId = thread_ids[2]; 575 expect_threads[2].ThreadId = static_cast<uint32_t>(thread_ids[2]);
569 } 576 }
570 577
571 PointerVector<TestThreadSnapshot> thread_snapshots_owner; 578 PointerVector<TestThreadSnapshot> thread_snapshots_owner;
572 std::vector<const ThreadSnapshot*> thread_snapshots; 579 std::vector<const ThreadSnapshot*> thread_snapshots;
573 for (size_t index = 0; index < arraysize(expect_threads); ++index) { 580 for (size_t index = 0; index < arraysize(expect_threads); ++index) {
574 TestThreadSnapshot* thread_snapshot = new TestThreadSnapshot(); 581 TestThreadSnapshot* thread_snapshot = new TestThreadSnapshot();
575 thread_snapshots_owner.push_back(thread_snapshot); 582 thread_snapshots_owner.push_back(thread_snapshot);
576 583
577 thread_snapshot->SetThreadID(thread_ids[index]); 584 thread_snapshot->SetThreadID(thread_ids[index]);
578 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount); 585 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount);
(...skipping 21 matching lines...) Expand all
600 MinidumpThreadIDMap thread_id_map; 607 MinidumpThreadIDMap thread_id_map;
601 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map); 608 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map);
602 609
603 MinidumpFileWriter minidump_file_writer; 610 MinidumpFileWriter minidump_file_writer;
604 minidump_file_writer.AddStream(thread_list_writer.Pass()); 611 minidump_file_writer.AddStream(thread_list_writer.Pass());
605 minidump_file_writer.AddStream(memory_list_writer.Pass()); 612 minidump_file_writer.AddStream(memory_list_writer.Pass());
606 613
607 StringFileWriter file_writer; 614 StringFileWriter file_writer;
608 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); 615 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
609 616
610 const MINIDUMP_THREAD_LIST* thread_list; 617 const MINIDUMP_THREAD_LIST* thread_list = nullptr;
611 const MINIDUMP_MEMORY_LIST* memory_list; 618 const MINIDUMP_MEMORY_LIST* memory_list = nullptr;
612 ASSERT_NO_FATAL_FAILURE( 619 ASSERT_NO_FATAL_FAILURE(
613 GetThreadListStream(file_writer.string(), &thread_list, &memory_list)); 620 GetThreadListStream(file_writer.string(), &thread_list, &memory_list));
614 621
615 ASSERT_EQ(3u, thread_list->NumberOfThreads); 622 ASSERT_EQ(3u, thread_list->NumberOfThreads);
616 ASSERT_EQ(2u, memory_list->NumberOfMemoryRanges); 623 ASSERT_EQ(2u, memory_list->NumberOfMemoryRanges);
617 624
618 size_t memory_index = 0; 625 size_t memory_index = 0;
619 for (size_t index = 0; index < thread_list->NumberOfThreads; ++index) { 626 for (size_t index = 0; index < thread_list->NumberOfThreads; ++index) {
620 SCOPED_TRACE(base::StringPrintf("index %zu", index)); 627 SCOPED_TRACE(base::StringPrintf("index %zu", index));
621 628
622 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; 629 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr;
623 const MINIDUMP_MEMORY_DESCRIPTOR** observed_stack_p = 630 const MINIDUMP_MEMORY_DESCRIPTOR** observed_stack_p =
624 expect_threads[index].Stack.Memory.DataSize ? &observed_stack : nullptr; 631 expect_threads[index].Stack.Memory.DataSize ? &observed_stack : nullptr;
625 const MinidumpContextType* observed_context; 632 const MinidumpContextType* observed_context = nullptr;
626 ASSERT_NO_FATAL_FAILURE( 633 ASSERT_NO_FATAL_FAILURE(
627 ExpectThread(&expect_threads[index], 634 ExpectThread(&expect_threads[index],
628 &thread_list->Threads[index], 635 &thread_list->Threads[index],
629 file_writer.string(), 636 file_writer.string(),
630 observed_stack_p, 637 observed_stack_p,
631 reinterpret_cast<const void**>(&observed_context))); 638 reinterpret_cast<const void**>(&observed_context)));
632 639
633 ASSERT_NO_FATAL_FAILURE(Traits::ExpectMinidumpContext( 640 ASSERT_NO_FATAL_FAILURE(Traits::ExpectMinidumpContext(
634 context_seeds[index], observed_context, true)); 641 context_seeds[index], observed_context, true));
635 642
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 683
677 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { 684 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) {
678 ASSERT_DEATH( 685 ASSERT_DEATH(
679 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( 686 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>(
680 false), "context_"); 687 false), "context_");
681 } 688 }
682 689
683 } // namespace 690 } // namespace
684 } // namespace test 691 } // namespace test
685 } // namespace crashpad 692 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698