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

Side by Side Diff: minidump/minidump_thread_writer_test.cc

Issue 686353004: Add MinidumpContextWriter::CreateFromSnapshot(), everything downstream, and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 1 month 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 | « minidump/minidump_exception_writer_test.cc ('k') | minidump/test/minidump_context_test_util.h » ('j') | 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); 177 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86);
178 178
179 const MinidumpContextX86* observed_context; 179 const MinidumpContextX86* observed_context;
180 ASSERT_NO_FATAL_FAILURE( 180 ASSERT_NO_FATAL_FAILURE(
181 ExpectThread(&expected, 181 ExpectThread(&expected,
182 &thread_list->Threads[0], 182 &thread_list->Threads[0],
183 file_writer.string(), 183 file_writer.string(),
184 nullptr, 184 nullptr,
185 reinterpret_cast<const void**>(&observed_context))); 185 reinterpret_cast<const void**>(&observed_context)));
186 186
187 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpContextX86(kSeed, observed_context)); 187 ASSERT_NO_FATAL_FAILURE(
188 ExpectMinidumpContextX86(kSeed, observed_context, false));
188 } 189 }
189 190
190 TEST(MinidumpThreadWriter, OneThread_AMD64_Stack) { 191 TEST(MinidumpThreadWriter, OneThread_AMD64_Stack) {
191 MinidumpFileWriter minidump_file_writer; 192 MinidumpFileWriter minidump_file_writer;
192 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); 193 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter());
193 194
194 const uint32_t kThreadID = 0x22222222; 195 const uint32_t kThreadID = 0x22222222;
195 const uint32_t kSuspendCount = 2; 196 const uint32_t kSuspendCount = 2;
196 const uint32_t kPriorityClass = 0x30; 197 const uint32_t kPriorityClass = 0x30;
197 const uint32_t kPriority = 20; 198 const uint32_t kPriority = 20;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 file_writer.string(), 252 file_writer.string(),
252 &observed_stack, 253 &observed_stack,
253 reinterpret_cast<const void**>(&observed_context))); 254 reinterpret_cast<const void**>(&observed_context)));
254 255
255 ASSERT_NO_FATAL_FAILURE( 256 ASSERT_NO_FATAL_FAILURE(
256 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 257 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
257 observed_stack, 258 observed_stack,
258 file_writer.string(), 259 file_writer.string(),
259 kMemoryValue, 260 kMemoryValue,
260 true)); 261 true));
261 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpContextAMD64(kSeed, observed_context)); 262 ASSERT_NO_FATAL_FAILURE(
263 ExpectMinidumpContextAMD64(kSeed, observed_context, false));
262 } 264 }
263 265
264 TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) { 266 TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) {
265 MinidumpFileWriter minidump_file_writer; 267 MinidumpFileWriter minidump_file_writer;
266 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); 268 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter());
267 auto memory_list_writer = make_scoped_ptr(new MinidumpMemoryListWriter()); 269 auto memory_list_writer = make_scoped_ptr(new MinidumpMemoryListWriter());
268 thread_list_writer->SetMemoryListWriter(memory_list_writer.get()); 270 thread_list_writer->SetMemoryListWriter(memory_list_writer.get());
269 271
270 const uint32_t kThreadID0 = 1111111; 272 const uint32_t kThreadID0 = 1111111;
271 const uint32_t kSuspendCount0 = 111111; 273 const uint32_t kSuspendCount0 = 111111;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 file_writer.string(), 393 file_writer.string(),
392 &observed_stack, 394 &observed_stack,
393 reinterpret_cast<const void**>(&observed_context))); 395 reinterpret_cast<const void**>(&observed_context)));
394 396
395 ASSERT_NO_FATAL_FAILURE( 397 ASSERT_NO_FATAL_FAILURE(
396 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 398 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
397 observed_stack, 399 observed_stack,
398 file_writer.string(), 400 file_writer.string(),
399 kMemoryValue0, 401 kMemoryValue0,
400 false)); 402 false));
401 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpContextX86(kSeed0, observed_context)); 403 ASSERT_NO_FATAL_FAILURE(
404 ExpectMinidumpContextX86(kSeed0, observed_context, false));
402 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor( 405 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor(
403 observed_stack, &memory_list->MemoryRanges[0])); 406 observed_stack, &memory_list->MemoryRanges[0]));
404 } 407 }
405 408
406 { 409 {
407 SCOPED_TRACE("thread 1"); 410 SCOPED_TRACE("thread 1");
408 411
409 MINIDUMP_THREAD expected = {}; 412 MINIDUMP_THREAD expected = {};
410 expected.ThreadId = kThreadID1; 413 expected.ThreadId = kThreadID1;
411 expected.SuspendCount = kSuspendCount1; 414 expected.SuspendCount = kSuspendCount1;
(...skipping 12 matching lines...) Expand all
424 file_writer.string(), 427 file_writer.string(),
425 &observed_stack, 428 &observed_stack,
426 reinterpret_cast<const void**>(&observed_context))); 429 reinterpret_cast<const void**>(&observed_context)));
427 430
428 ASSERT_NO_FATAL_FAILURE( 431 ASSERT_NO_FATAL_FAILURE(
429 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 432 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
430 observed_stack, 433 observed_stack,
431 file_writer.string(), 434 file_writer.string(),
432 kMemoryValue1, 435 kMemoryValue1,
433 false)); 436 false));
434 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpContextX86(kSeed1, observed_context)); 437 ASSERT_NO_FATAL_FAILURE(
438 ExpectMinidumpContextX86(kSeed1, observed_context, false));
435 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor( 439 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor(
436 observed_stack, &memory_list->MemoryRanges[1])); 440 observed_stack, &memory_list->MemoryRanges[1]));
437 } 441 }
438 442
439 { 443 {
440 SCOPED_TRACE("thread 2"); 444 SCOPED_TRACE("thread 2");
441 445
442 MINIDUMP_THREAD expected = {}; 446 MINIDUMP_THREAD expected = {};
443 expected.ThreadId = kThreadID2; 447 expected.ThreadId = kThreadID2;
444 expected.SuspendCount = kSuspendCount2; 448 expected.SuspendCount = kSuspendCount2;
(...skipping 12 matching lines...) Expand all
457 file_writer.string(), 461 file_writer.string(),
458 &observed_stack, 462 &observed_stack,
459 reinterpret_cast<const void**>(&observed_context))); 463 reinterpret_cast<const void**>(&observed_context)));
460 464
461 ASSERT_NO_FATAL_FAILURE( 465 ASSERT_NO_FATAL_FAILURE(
462 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, 466 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack,
463 observed_stack, 467 observed_stack,
464 file_writer.string(), 468 file_writer.string(),
465 kMemoryValue2, 469 kMemoryValue2,
466 true)); 470 true));
467 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpContextX86(kSeed2, observed_context)); 471 ASSERT_NO_FATAL_FAILURE(
472 ExpectMinidumpContextX86(kSeed2, observed_context, false));
468 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor( 473 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor(
469 observed_stack, &memory_list->MemoryRanges[2])); 474 observed_stack, &memory_list->MemoryRanges[2]));
470 } 475 }
471 } 476 }
472 477
473 TEST(MinidumpThreadWriterDeathTest, NoContext) { 478 TEST(MinidumpThreadWriterDeathTest, NoContext) {
474 MinidumpFileWriter minidump_file_writer; 479 MinidumpFileWriter minidump_file_writer;
475 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); 480 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter());
476 481
477 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); 482 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter());
478 483
479 thread_list_writer->AddThread(thread_writer.Pass()); 484 thread_list_writer->AddThread(thread_writer.Pass());
480 minidump_file_writer.AddStream(thread_list_writer.Pass()); 485 minidump_file_writer.AddStream(thread_list_writer.Pass());
481 486
482 StringFileWriter file_writer; 487 StringFileWriter file_writer;
483 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "context_"); 488 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "context_");
484 } 489 }
485 490
486 } // namespace 491 } // namespace
487 } // namespace test 492 } // namespace test
488 } // namespace crashpad 493 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_exception_writer_test.cc ('k') | minidump/test/minidump_context_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698