Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 MSVC_SUPPRESS_WARNING(4316) // Object allocated on heap may not be aligned. | |
|
Mark Mentovai
2015/02/05 18:21:31
A semicolon will make this look a little more code
| |
| 222 auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer()); | 223 auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer()); |
| 223 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); | 224 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); |
| 224 thread_writer->SetContext(context_amd64_writer.Pass()); | 225 thread_writer->SetContext(context_amd64_writer.Pass()); |
| 225 | 226 |
| 226 thread_list_writer->AddThread(thread_writer.Pass()); | 227 thread_list_writer->AddThread(thread_writer.Pass()); |
| 227 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 228 minidump_file_writer.AddStream(thread_list_writer.Pass()); |
| 228 | 229 |
| 229 StringFileWriter file_writer; | 230 StringFileWriter file_writer; |
| 230 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 231 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
| 231 | 232 |
| 232 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + | 233 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + |
| 233 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + | 234 sizeof(MINIDUMP_THREAD_LIST) + 1 * sizeof(MINIDUMP_THREAD) + |
| 234 1 * sizeof(MinidumpContextAMD64) + kMemorySize, | 235 1 * sizeof(MinidumpContextAMD64) + kMemorySize, |
| 235 file_writer.string().size()); | 236 file_writer.string().size()); |
| 236 | 237 |
| 237 const MINIDUMP_THREAD_LIST* thread_list; | 238 const MINIDUMP_THREAD_LIST* thread_list = nullptr; |
| 238 ASSERT_NO_FATAL_FAILURE( | 239 ASSERT_NO_FATAL_FAILURE( |
| 239 GetThreadListStream(file_writer.string(), &thread_list, nullptr)); | 240 GetThreadListStream(file_writer.string(), &thread_list, nullptr)); |
| 240 | 241 |
| 241 EXPECT_EQ(1u, thread_list->NumberOfThreads); | 242 EXPECT_EQ(1u, thread_list->NumberOfThreads); |
| 242 | 243 |
| 243 MINIDUMP_THREAD expected = {}; | 244 MINIDUMP_THREAD expected = {}; |
| 244 expected.ThreadId = kThreadID; | 245 expected.ThreadId = kThreadID; |
| 245 expected.SuspendCount = kSuspendCount; | 246 expected.SuspendCount = kSuspendCount; |
| 246 expected.PriorityClass = kPriorityClass; | 247 expected.PriorityClass = kPriorityClass; |
| 247 expected.Priority = kPriority; | 248 expected.Priority = kPriority; |
| 248 expected.Teb = kTEB; | 249 expected.Teb = kTEB; |
| 249 expected.Stack.StartOfMemoryRange = kMemoryBase; | 250 expected.Stack.StartOfMemoryRange = kMemoryBase; |
| 250 expected.Stack.Memory.DataSize = kMemorySize; | 251 expected.Stack.Memory.DataSize = kMemorySize; |
| 251 expected.ThreadContext.DataSize = sizeof(MinidumpContextAMD64); | 252 expected.ThreadContext.DataSize = sizeof(MinidumpContextAMD64); |
| 252 | 253 |
| 253 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; | 254 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr; |
| 254 const MinidumpContextAMD64* observed_context; | 255 const MinidumpContextAMD64* observed_context = nullptr; |
| 255 ASSERT_NO_FATAL_FAILURE( | 256 ASSERT_NO_FATAL_FAILURE( |
| 256 ExpectThread(&expected, | 257 ExpectThread(&expected, |
| 257 &thread_list->Threads[0], | 258 &thread_list->Threads[0], |
| 258 file_writer.string(), | 259 file_writer.string(), |
| 259 &observed_stack, | 260 &observed_stack, |
| 260 reinterpret_cast<const void**>(&observed_context))); | 261 reinterpret_cast<const void**>(&observed_context))); |
| 261 | 262 |
| 262 ASSERT_NO_FATAL_FAILURE( | 263 ASSERT_NO_FATAL_FAILURE( |
| 263 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, | 264 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, |
| 264 observed_stack, | 265 observed_stack, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 364 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
| 364 | 365 |
| 365 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + 2 * sizeof(MINIDUMP_DIRECTORY) + | 366 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + 2 * sizeof(MINIDUMP_DIRECTORY) + |
| 366 sizeof(MINIDUMP_THREAD_LIST) + 3 * sizeof(MINIDUMP_THREAD) + | 367 sizeof(MINIDUMP_THREAD_LIST) + 3 * sizeof(MINIDUMP_THREAD) + |
| 367 sizeof(MINIDUMP_MEMORY_LIST) + | 368 sizeof(MINIDUMP_MEMORY_LIST) + |
| 368 3 * sizeof(MINIDUMP_MEMORY_DESCRIPTOR) + | 369 3 * sizeof(MINIDUMP_MEMORY_DESCRIPTOR) + |
| 369 3 * sizeof(MinidumpContextX86) + kMemorySize0 + kMemorySize1 + | 370 3 * sizeof(MinidumpContextX86) + kMemorySize0 + kMemorySize1 + |
| 370 kMemorySize2 + 12, // 12 for alignment | 371 kMemorySize2 + 12, // 12 for alignment |
| 371 file_writer.string().size()); | 372 file_writer.string().size()); |
| 372 | 373 |
| 373 const MINIDUMP_THREAD_LIST* thread_list; | 374 const MINIDUMP_THREAD_LIST* thread_list = nullptr; |
| 374 const MINIDUMP_MEMORY_LIST* memory_list; | 375 const MINIDUMP_MEMORY_LIST* memory_list = nullptr; |
| 375 ASSERT_NO_FATAL_FAILURE( | 376 ASSERT_NO_FATAL_FAILURE( |
| 376 GetThreadListStream(file_writer.string(), &thread_list, &memory_list)); | 377 GetThreadListStream(file_writer.string(), &thread_list, &memory_list)); |
| 377 | 378 |
| 378 EXPECT_EQ(3u, thread_list->NumberOfThreads); | 379 EXPECT_EQ(3u, thread_list->NumberOfThreads); |
| 379 EXPECT_EQ(3u, memory_list->NumberOfMemoryRanges); | 380 EXPECT_EQ(3u, memory_list->NumberOfMemoryRanges); |
| 380 | 381 |
| 381 { | 382 { |
| 382 SCOPED_TRACE("thread 0"); | 383 SCOPED_TRACE("thread 0"); |
| 383 | 384 |
| 384 MINIDUMP_THREAD expected = {}; | 385 MINIDUMP_THREAD expected = {}; |
| 385 expected.ThreadId = kThreadID0; | 386 expected.ThreadId = kThreadID0; |
| 386 expected.SuspendCount = kSuspendCount0; | 387 expected.SuspendCount = kSuspendCount0; |
| 387 expected.PriorityClass = kPriorityClass0; | 388 expected.PriorityClass = kPriorityClass0; |
| 388 expected.Priority = kPriority0; | 389 expected.Priority = kPriority0; |
| 389 expected.Teb = kTEB0; | 390 expected.Teb = kTEB0; |
| 390 expected.Stack.StartOfMemoryRange = kMemoryBase0; | 391 expected.Stack.StartOfMemoryRange = kMemoryBase0; |
| 391 expected.Stack.Memory.DataSize = kMemorySize0; | 392 expected.Stack.Memory.DataSize = kMemorySize0; |
| 392 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); | 393 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); |
| 393 | 394 |
| 394 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; | 395 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr; |
| 395 const MinidumpContextX86* observed_context; | 396 const MinidumpContextX86* observed_context = nullptr; |
| 396 ASSERT_NO_FATAL_FAILURE( | 397 ASSERT_NO_FATAL_FAILURE( |
| 397 ExpectThread(&expected, | 398 ExpectThread(&expected, |
| 398 &thread_list->Threads[0], | 399 &thread_list->Threads[0], |
| 399 file_writer.string(), | 400 file_writer.string(), |
| 400 &observed_stack, | 401 &observed_stack, |
| 401 reinterpret_cast<const void**>(&observed_context))); | 402 reinterpret_cast<const void**>(&observed_context))); |
| 402 | 403 |
| 403 ASSERT_NO_FATAL_FAILURE( | 404 ASSERT_NO_FATAL_FAILURE( |
| 404 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, | 405 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, |
| 405 observed_stack, | 406 observed_stack, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 418 MINIDUMP_THREAD expected = {}; | 419 MINIDUMP_THREAD expected = {}; |
| 419 expected.ThreadId = kThreadID1; | 420 expected.ThreadId = kThreadID1; |
| 420 expected.SuspendCount = kSuspendCount1; | 421 expected.SuspendCount = kSuspendCount1; |
| 421 expected.PriorityClass = kPriorityClass1; | 422 expected.PriorityClass = kPriorityClass1; |
| 422 expected.Priority = kPriority1; | 423 expected.Priority = kPriority1; |
| 423 expected.Teb = kTEB1; | 424 expected.Teb = kTEB1; |
| 424 expected.Stack.StartOfMemoryRange = kMemoryBase1; | 425 expected.Stack.StartOfMemoryRange = kMemoryBase1; |
| 425 expected.Stack.Memory.DataSize = kMemorySize1; | 426 expected.Stack.Memory.DataSize = kMemorySize1; |
| 426 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); | 427 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); |
| 427 | 428 |
| 428 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; | 429 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr; |
| 429 const MinidumpContextX86* observed_context; | 430 const MinidumpContextX86* observed_context = nullptr; |
| 430 ASSERT_NO_FATAL_FAILURE( | 431 ASSERT_NO_FATAL_FAILURE( |
| 431 ExpectThread(&expected, | 432 ExpectThread(&expected, |
| 432 &thread_list->Threads[1], | 433 &thread_list->Threads[1], |
| 433 file_writer.string(), | 434 file_writer.string(), |
| 434 &observed_stack, | 435 &observed_stack, |
| 435 reinterpret_cast<const void**>(&observed_context))); | 436 reinterpret_cast<const void**>(&observed_context))); |
| 436 | 437 |
| 437 ASSERT_NO_FATAL_FAILURE( | 438 ASSERT_NO_FATAL_FAILURE( |
| 438 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, | 439 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, |
| 439 observed_stack, | 440 observed_stack, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 452 MINIDUMP_THREAD expected = {}; | 453 MINIDUMP_THREAD expected = {}; |
| 453 expected.ThreadId = kThreadID2; | 454 expected.ThreadId = kThreadID2; |
| 454 expected.SuspendCount = kSuspendCount2; | 455 expected.SuspendCount = kSuspendCount2; |
| 455 expected.PriorityClass = kPriorityClass2; | 456 expected.PriorityClass = kPriorityClass2; |
| 456 expected.Priority = kPriority2; | 457 expected.Priority = kPriority2; |
| 457 expected.Teb = kTEB2; | 458 expected.Teb = kTEB2; |
| 458 expected.Stack.StartOfMemoryRange = kMemoryBase2; | 459 expected.Stack.StartOfMemoryRange = kMemoryBase2; |
| 459 expected.Stack.Memory.DataSize = kMemorySize2; | 460 expected.Stack.Memory.DataSize = kMemorySize2; |
| 460 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); | 461 expected.ThreadContext.DataSize = sizeof(MinidumpContextX86); |
| 461 | 462 |
| 462 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; | 463 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr; |
| 463 const MinidumpContextX86* observed_context; | 464 const MinidumpContextX86* observed_context = nullptr; |
| 464 ASSERT_NO_FATAL_FAILURE( | 465 ASSERT_NO_FATAL_FAILURE( |
| 465 ExpectThread(&expected, | 466 ExpectThread(&expected, |
| 466 &thread_list->Threads[2], | 467 &thread_list->Threads[2], |
| 467 file_writer.string(), | 468 file_writer.string(), |
| 468 &observed_stack, | 469 &observed_stack, |
| 469 reinterpret_cast<const void**>(&observed_context))); | 470 reinterpret_cast<const void**>(&observed_context))); |
| 470 | 471 |
| 471 ASSERT_NO_FATAL_FAILURE( | 472 ASSERT_NO_FATAL_FAILURE( |
| 472 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, | 473 ExpectMinidumpMemoryDescriptorAndContents(&expected.Stack, |
| 473 observed_stack, | 474 observed_stack, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 thread_ids[0] = 0x0123456700000001; | 557 thread_ids[0] = 0x0123456700000001; |
| 557 thread_ids[1] = 0x89abcdef00000001; | 558 thread_ids[1] = 0x89abcdef00000001; |
| 558 thread_ids[2] = 4; | 559 thread_ids[2] = 4; |
| 559 expect_threads[0].ThreadId = 0; | 560 expect_threads[0].ThreadId = 0; |
| 560 expect_threads[1].ThreadId = 1; | 561 expect_threads[1].ThreadId = 1; |
| 561 expect_threads[2].ThreadId = 2; | 562 expect_threads[2].ThreadId = 2; |
| 562 } else { | 563 } else { |
| 563 thread_ids[0] = 1; | 564 thread_ids[0] = 1; |
| 564 thread_ids[1] = 11; | 565 thread_ids[1] = 11; |
| 565 thread_ids[2] = 22; | 566 thread_ids[2] = 22; |
| 566 expect_threads[0].ThreadId = thread_ids[0]; | 567 expect_threads[0].ThreadId = static_cast<uint32_t>(thread_ids[0]); |
| 567 expect_threads[1].ThreadId = thread_ids[1]; | 568 expect_threads[1].ThreadId = static_cast<uint32_t>(thread_ids[1]); |
| 568 expect_threads[2].ThreadId = thread_ids[2]; | 569 expect_threads[2].ThreadId = static_cast<uint32_t>(thread_ids[2]); |
| 569 } | 570 } |
| 570 | 571 |
| 571 PointerVector<TestThreadSnapshot> thread_snapshots_owner; | 572 PointerVector<TestThreadSnapshot> thread_snapshots_owner; |
| 572 std::vector<const ThreadSnapshot*> thread_snapshots; | 573 std::vector<const ThreadSnapshot*> thread_snapshots; |
| 573 for (size_t index = 0; index < arraysize(expect_threads); ++index) { | 574 for (size_t index = 0; index < arraysize(expect_threads); ++index) { |
| 574 TestThreadSnapshot* thread_snapshot = new TestThreadSnapshot(); | 575 TestThreadSnapshot* thread_snapshot = new TestThreadSnapshot(); |
| 575 thread_snapshots_owner.push_back(thread_snapshot); | 576 thread_snapshots_owner.push_back(thread_snapshot); |
| 576 | 577 |
| 577 thread_snapshot->SetThreadID(thread_ids[index]); | 578 thread_snapshot->SetThreadID(thread_ids[index]); |
| 578 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount); | 579 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 600 MinidumpThreadIDMap thread_id_map; | 601 MinidumpThreadIDMap thread_id_map; |
| 601 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map); | 602 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map); |
| 602 | 603 |
| 603 MinidumpFileWriter minidump_file_writer; | 604 MinidumpFileWriter minidump_file_writer; |
| 604 minidump_file_writer.AddStream(thread_list_writer.Pass()); | 605 minidump_file_writer.AddStream(thread_list_writer.Pass()); |
| 605 minidump_file_writer.AddStream(memory_list_writer.Pass()); | 606 minidump_file_writer.AddStream(memory_list_writer.Pass()); |
| 606 | 607 |
| 607 StringFileWriter file_writer; | 608 StringFileWriter file_writer; |
| 608 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 609 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
| 609 | 610 |
| 610 const MINIDUMP_THREAD_LIST* thread_list; | 611 const MINIDUMP_THREAD_LIST* thread_list = nullptr; |
| 611 const MINIDUMP_MEMORY_LIST* memory_list; | 612 const MINIDUMP_MEMORY_LIST* memory_list = nullptr; |
| 612 ASSERT_NO_FATAL_FAILURE( | 613 ASSERT_NO_FATAL_FAILURE( |
| 613 GetThreadListStream(file_writer.string(), &thread_list, &memory_list)); | 614 GetThreadListStream(file_writer.string(), &thread_list, &memory_list)); |
| 614 | 615 |
| 615 ASSERT_EQ(3u, thread_list->NumberOfThreads); | 616 ASSERT_EQ(3u, thread_list->NumberOfThreads); |
| 616 ASSERT_EQ(2u, memory_list->NumberOfMemoryRanges); | 617 ASSERT_EQ(2u, memory_list->NumberOfMemoryRanges); |
| 617 | 618 |
| 618 size_t memory_index = 0; | 619 size_t memory_index = 0; |
| 619 for (size_t index = 0; index < thread_list->NumberOfThreads; ++index) { | 620 for (size_t index = 0; index < thread_list->NumberOfThreads; ++index) { |
| 620 SCOPED_TRACE(base::StringPrintf("index %zu", index)); | 621 SCOPED_TRACE(base::StringPrintf("index %zu", index)); |
| 621 | 622 |
| 622 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack; | 623 const MINIDUMP_MEMORY_DESCRIPTOR* observed_stack = nullptr; |
| 623 const MINIDUMP_MEMORY_DESCRIPTOR** observed_stack_p = | 624 const MINIDUMP_MEMORY_DESCRIPTOR** observed_stack_p = |
| 624 expect_threads[index].Stack.Memory.DataSize ? &observed_stack : nullptr; | 625 expect_threads[index].Stack.Memory.DataSize ? &observed_stack : nullptr; |
| 625 const MinidumpContextType* observed_context; | 626 const MinidumpContextType* observed_context = nullptr; |
| 626 ASSERT_NO_FATAL_FAILURE( | 627 ASSERT_NO_FATAL_FAILURE( |
| 627 ExpectThread(&expect_threads[index], | 628 ExpectThread(&expect_threads[index], |
| 628 &thread_list->Threads[index], | 629 &thread_list->Threads[index], |
| 629 file_writer.string(), | 630 file_writer.string(), |
| 630 observed_stack_p, | 631 observed_stack_p, |
| 631 reinterpret_cast<const void**>(&observed_context))); | 632 reinterpret_cast<const void**>(&observed_context))); |
| 632 | 633 |
| 633 ASSERT_NO_FATAL_FAILURE(Traits::ExpectMinidumpContext( | 634 ASSERT_NO_FATAL_FAILURE(Traits::ExpectMinidumpContext( |
| 634 context_seeds[index], observed_context, true)); | 635 context_seeds[index], observed_context, true)); |
| 635 | 636 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 | 677 |
| 677 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { | 678 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { |
| 678 ASSERT_DEATH( | 679 ASSERT_DEATH( |
| 679 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( | 680 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( |
| 680 false), "context_"); | 681 false), "context_"); |
| 681 } | 682 } |
| 682 | 683 |
| 683 } // namespace | 684 } // namespace |
| 684 } // namespace test | 685 } // namespace test |
| 685 } // namespace crashpad | 686 } // namespace crashpad |
| OLD | NEW |