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

Side by Side Diff: minidump/minidump_file_writer_test.cc

Issue 1364053002: win: Save contents of PEB to minidump (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@save-teb
Patch Set: fixes Created 5 years, 2 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
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 10 matching lines...) Expand all
21 21
22 #include "base/basictypes.h" 22 #include "base/basictypes.h"
23 #include "base/compiler_specific.h" 23 #include "base/compiler_specific.h"
24 #include "gtest/gtest.h" 24 #include "gtest/gtest.h"
25 #include "minidump/minidump_stream_writer.h" 25 #include "minidump/minidump_stream_writer.h"
26 #include "minidump/minidump_writable.h" 26 #include "minidump/minidump_writable.h"
27 #include "minidump/test/minidump_file_writer_test_util.h" 27 #include "minidump/test/minidump_file_writer_test_util.h"
28 #include "minidump/test/minidump_writable_test_util.h" 28 #include "minidump/test/minidump_writable_test_util.h"
29 #include "snapshot/test/test_cpu_context.h" 29 #include "snapshot/test/test_cpu_context.h"
30 #include "snapshot/test/test_exception_snapshot.h" 30 #include "snapshot/test/test_exception_snapshot.h"
31 #include "snapshot/test/test_memory_snapshot.h"
31 #include "snapshot/test/test_module_snapshot.h" 32 #include "snapshot/test/test_module_snapshot.h"
32 #include "snapshot/test/test_process_snapshot.h" 33 #include "snapshot/test/test_process_snapshot.h"
33 #include "snapshot/test/test_system_snapshot.h" 34 #include "snapshot/test/test_system_snapshot.h"
34 #include "snapshot/test/test_thread_snapshot.h" 35 #include "snapshot/test/test_thread_snapshot.h"
35 #include "test/gtest_death_check.h" 36 #include "test/gtest_death_check.h"
36 #include "util/file/string_file.h" 37 #include "util/file/string_file.h"
37 38
38 namespace crashpad { 39 namespace crashpad {
39 namespace test { 40 namespace test {
40 namespace { 41 namespace {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 }; 246 const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 };
246 247
247 TestProcessSnapshot process_snapshot; 248 TestProcessSnapshot process_snapshot;
248 process_snapshot.SetSnapshotTime(kSnapshotTimeval); 249 process_snapshot.SetSnapshotTime(kSnapshotTimeval);
249 250
250 auto system_snapshot = make_scoped_ptr(new TestSystemSnapshot()); 251 auto system_snapshot = make_scoped_ptr(new TestSystemSnapshot());
251 system_snapshot->SetCPUArchitecture(kCPUArchitectureX86_64); 252 system_snapshot->SetCPUArchitecture(kCPUArchitectureX86_64);
252 system_snapshot->SetOperatingSystem(SystemSnapshot::kOperatingSystemMacOSX); 253 system_snapshot->SetOperatingSystem(SystemSnapshot::kOperatingSystemMacOSX);
253 process_snapshot.SetSystem(system_snapshot.Pass()); 254 process_snapshot.SetSystem(system_snapshot.Pass());
254 255
256 auto peb_snapshot = make_scoped_ptr(new TestMemorySnapshot());
257 const uint64_t kPebAddress = 0x07f90000;
258 peb_snapshot->SetAddress(kPebAddress);
259 const size_t kPebSize = 0x280;
260 peb_snapshot->SetSize(kPebSize);
261 peb_snapshot->SetValue('p');
262 process_snapshot.AddExtraMemory(peb_snapshot.Pass());
263
255 MinidumpFileWriter minidump_file_writer; 264 MinidumpFileWriter minidump_file_writer;
256 minidump_file_writer.InitializeFromSnapshot(&process_snapshot); 265 minidump_file_writer.InitializeFromSnapshot(&process_snapshot);
257 266
258 StringFile string_file; 267 StringFile string_file;
259 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 268 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
260 269
261 const MINIDUMP_DIRECTORY* directory; 270 const MINIDUMP_DIRECTORY* directory;
262 const MINIDUMP_HEADER* header = 271 const MINIDUMP_HEADER* header =
263 MinidumpHeaderAtStart(string_file.string(), &directory); 272 MinidumpHeaderAtStart(string_file.string(), &directory);
264 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 5, kSnapshotTime)); 273 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 5, kSnapshotTime));
(...skipping 11 matching lines...) Expand all
276 EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_THREAD_LIST>( 285 EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_THREAD_LIST>(
277 string_file.string(), directory[2].Location)); 286 string_file.string(), directory[2].Location));
278 287
279 EXPECT_EQ(kMinidumpStreamTypeModuleList, directory[3].StreamType); 288 EXPECT_EQ(kMinidumpStreamTypeModuleList, directory[3].StreamType);
280 EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MODULE_LIST>( 289 EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MODULE_LIST>(
281 string_file.string(), directory[3].Location)); 290 string_file.string(), directory[3].Location));
282 291
283 EXPECT_EQ(kMinidumpStreamTypeMemoryList, directory[4].StreamType); 292 EXPECT_EQ(kMinidumpStreamTypeMemoryList, directory[4].StreamType);
284 EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>( 293 EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>(
285 string_file.string(), directory[4].Location)); 294 string_file.string(), directory[4].Location));
295
296 const MINIDUMP_MEMORY_LIST* memory_list =
297 MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>(
298 string_file.string(), directory[4].Location);
299 EXPECT_EQ(1u, memory_list->NumberOfMemoryRanges);
300 EXPECT_EQ(kPebAddress, memory_list->MemoryRanges[0].StartOfMemoryRange);
301 EXPECT_EQ(kPebSize, memory_list->MemoryRanges[0].Memory.DataSize);
286 } 302 }
287 303
288 TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) { 304 TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) {
289 // In a 32-bit environment, this will give a “timestamp out of range” warning, 305 // In a 32-bit environment, this will give a “timestamp out of range” warning,
290 // but the test should complete without failure. 306 // but the test should complete without failure.
291 const uint32_t kSnapshotTime = 0xfd469ab8; 307 const uint32_t kSnapshotTime = 0xfd469ab8;
292 MSVC_SUPPRESS_WARNING(4309); // Truncation of constant value. 308 MSVC_SUPPRESS_WARNING(4309); // Truncation of constant value.
293 MSVC_SUPPRESS_WARNING(4838); // Narrowing conversion. 309 MSVC_SUPPRESS_WARNING(4838); // Narrowing conversion.
294 const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 }; 310 const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 };
295 311
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 const uint8_t kStream1Value = 0xa5; 453 const uint8_t kStream1Value = 0xa5;
438 auto stream1 = make_scoped_ptr( 454 auto stream1 = make_scoped_ptr(
439 new TestStream(kStream1Type, kStream1Size, kStream1Value)); 455 new TestStream(kStream1Type, kStream1Size, kStream1Value));
440 ASSERT_DEATH_CHECK(minidump_file.AddStream(stream1.Pass()), 456 ASSERT_DEATH_CHECK(minidump_file.AddStream(stream1.Pass()),
441 "already present"); 457 "already present");
442 } 458 }
443 459
444 } // namespace 460 } // namespace
445 } // namespace test 461 } // namespace test
446 } // namespace crashpad 462 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698