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

Side by Side Diff: minidump/minidump_thread_writer_test.cc

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

Powered by Google App Engine
This is Rietveld 408576698