minidump: Ignore attempts to add user streams with type collisions

The unconditional CHECK() in MinidumpFileWriter::AddStream() made sense
when all streams were under the Minidump class family’s control, but
became hazardous upon the introduction of user streams with arbitrary
types under the crashy process’ control.

Bug: crashpad:171
Test: crashpad_minidump_test MinidumpFileWriter.SameStreamType
Change-Id: Iba5be08b330261286d11d22d8e9a2fef5fcc1070
Reviewed-on: https://chromium-review.googlesource.com/456056
Reviewed-by: Sigurður Ásgeirsson <siggi@chromium.org>
This commit is contained in:
Mark Mentovai 2017-03-15 15:35:36 -04:00
parent 82009cd14d
commit b10d9118de
14 changed files with 162 additions and 101 deletions

View File

@ -70,7 +70,7 @@ TEST(MinidumpCrashpadInfoWriter, Empty) {
base::WrapUnique(new MinidumpCrashpadInfoWriter());
EXPECT_FALSE(crashpad_info_writer->IsUseful());
minidump_file_writer.AddStream(std::move(crashpad_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -106,7 +106,7 @@ TEST(MinidumpCrashpadInfoWriter, ReportAndClientID) {
EXPECT_TRUE(crashpad_info_writer->IsUseful());
minidump_file_writer.AddStream(std::move(crashpad_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -148,7 +148,7 @@ TEST(MinidumpCrashpadInfoWriter, SimpleAnnotations) {
EXPECT_TRUE(crashpad_info_writer->IsUseful());
minidump_file_writer.AddStream(std::move(crashpad_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -189,7 +189,7 @@ TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) {
EXPECT_TRUE(crashpad_info_writer->IsUseful());
minidump_file_writer.AddStream(std::move(crashpad_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -265,7 +265,7 @@ TEST(MinidumpCrashpadInfoWriter, InitializeFromSnapshot) {
EXPECT_TRUE(info_writer->IsUseful());
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));

View File

@ -102,7 +102,7 @@ TEST(MinidumpExceptionWriter, Minimal) {
InitializeMinidumpContextX86(context_x86_writer->context(), kSeed);
exception_writer->SetContext(std::move(context_x86_writer));
minidump_file_writer.AddStream(std::move(exception_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -161,7 +161,7 @@ TEST(MinidumpExceptionWriter, Standard) {
exception_information.push_back(kExceptionInformation2);
exception_writer->SetExceptionInformation(exception_information);
minidump_file_writer.AddStream(std::move(exception_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -234,7 +234,7 @@ TEST(MinidumpExceptionWriter, InitializeFromSnapshot) {
exception_writer->InitializeFromSnapshot(&exception_snapshot, thread_id_map);
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(exception_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -256,7 +256,7 @@ TEST(MinidumpExceptionWriterDeathTest, NoContext) {
MinidumpFileWriter minidump_file_writer;
auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter());
minidump_file_writer.AddStream(std::move(exception_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
StringFile string_file;
ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),

View File

@ -74,11 +74,13 @@ void MinidumpFileWriter::InitializeFromSnapshot(
const SystemSnapshot* system_snapshot = process_snapshot->System();
auto system_info = base::WrapUnique(new MinidumpSystemInfoWriter());
system_info->InitializeFromSnapshot(system_snapshot);
AddStream(std::move(system_info));
bool add_stream_result = AddStream(std::move(system_info));
DCHECK(add_stream_result);
auto misc_info = base::WrapUnique(new MinidumpMiscInfoWriter());
misc_info->InitializeFromSnapshot(process_snapshot);
AddStream(std::move(misc_info));
add_stream_result = AddStream(std::move(misc_info));
DCHECK(add_stream_result);
auto memory_list = base::WrapUnique(new MinidumpMemoryListWriter());
auto thread_list = base::WrapUnique(new MinidumpThreadListWriter());
@ -86,33 +88,29 @@ void MinidumpFileWriter::InitializeFromSnapshot(
MinidumpThreadIDMap thread_id_map;
thread_list->InitializeFromSnapshot(process_snapshot->Threads(),
&thread_id_map);
AddStream(std::move(thread_list));
add_stream_result = AddStream(std::move(thread_list));
DCHECK(add_stream_result);
const ExceptionSnapshot* exception_snapshot = process_snapshot->Exception();
if (exception_snapshot) {
auto exception = base::WrapUnique(new MinidumpExceptionWriter());
exception->InitializeFromSnapshot(exception_snapshot, thread_id_map);
AddStream(std::move(exception));
add_stream_result = AddStream(std::move(exception));
DCHECK(add_stream_result);
}
auto module_list = base::WrapUnique(new MinidumpModuleListWriter());
module_list->InitializeFromSnapshot(process_snapshot->Modules());
AddStream(std::move(module_list));
for (const auto& module : process_snapshot->Modules()) {
for (const UserMinidumpStream* stream : module->CustomMinidumpStreams()) {
auto user_stream = base::WrapUnique(new MinidumpUserStreamWriter());
user_stream->InitializeFromSnapshot(stream);
AddStream(std::move(user_stream));
}
}
add_stream_result = AddStream(std::move(module_list));
DCHECK(add_stream_result);
auto unloaded_modules = process_snapshot->UnloadedModules();
if (!unloaded_modules.empty()) {
auto unloaded_module_list =
base::WrapUnique(new MinidumpUnloadedModuleListWriter());
unloaded_module_list->InitializeFromSnapshot(unloaded_modules);
AddStream(std::move(unloaded_module_list));
add_stream_result = AddStream(std::move(unloaded_module_list));
DCHECK(add_stream_result);
}
auto crashpad_info = base::WrapUnique(new MinidumpCrashpadInfoWriter());
@ -121,7 +119,8 @@ void MinidumpFileWriter::InitializeFromSnapshot(
// Since the MinidumpCrashpadInfo stream is an extension, its safe to not add
// it to the minidump file if it wouldnt carry any useful information.
if (crashpad_info->IsUseful()) {
AddStream(std::move(crashpad_info));
add_stream_result = AddStream(std::move(crashpad_info));
DCHECK(add_stream_result);
}
std::vector<const MemoryMapRegionSnapshot*> memory_map_snapshot =
@ -130,21 +129,46 @@ void MinidumpFileWriter::InitializeFromSnapshot(
auto memory_info_list =
base::WrapUnique(new MinidumpMemoryInfoListWriter());
memory_info_list->InitializeFromSnapshot(memory_map_snapshot);
AddStream(std::move(memory_info_list));
add_stream_result = AddStream(std::move(memory_info_list));
DCHECK(add_stream_result);
}
std::vector<HandleSnapshot> handles_snapshot = process_snapshot->Handles();
if (!handles_snapshot.empty()) {
auto handle_data_writer = base::WrapUnique(new MinidumpHandleDataWriter());
handle_data_writer->InitializeFromSnapshot(handles_snapshot);
AddStream(std::move(handle_data_writer));
add_stream_result = AddStream(std::move(handle_data_writer));
DCHECK(add_stream_result);
}
memory_list->AddFromSnapshot(process_snapshot->ExtraMemory());
if (exception_snapshot)
if (exception_snapshot) {
memory_list->AddFromSnapshot(exception_snapshot->ExtraMemory());
}
AddStream(std::move(memory_list));
// The memory list stream should be added last. This keeps the “extra memory”
// at the end so that if the minidump file is truncated, other, more critical
// data is more likely to be preserved. Note that non-“extra” memory regions
// will not have to ride at the end of the file. Thread stack memory, for
// example, exists as a children of threads, and appears alongside them in the
// file.
//
// It would be nice if this followed the user streams, but that would be
// hazardous. See below.
add_stream_result = AddStream(std::move(memory_list));
DCHECK(add_stream_result);
// These user streams must be added last. Otherwise, a user stream with the
// same type as a well-known stream could preempt the well-known stream. As it
// stands now, earlier-discovered user streams can still preempt
// later-discovered ones.
for (const auto& module : process_snapshot->Modules()) {
for (const UserMinidumpStream* stream : module->CustomMinidumpStreams()) {
auto user_stream = base::WrapUnique(new MinidumpUserStreamWriter());
user_stream->InitializeFromSnapshot(stream);
AddStream(std::move(user_stream));
}
}
}
void MinidumpFileWriter::SetTimestamp(time_t timestamp) {
@ -153,18 +177,22 @@ void MinidumpFileWriter::SetTimestamp(time_t timestamp) {
internal::MinidumpWriterUtil::AssignTimeT(&header_.TimeDateStamp, timestamp);
}
void MinidumpFileWriter::AddStream(
bool MinidumpFileWriter::AddStream(
std::unique_ptr<internal::MinidumpStreamWriter> stream) {
DCHECK_EQ(state(), kStateMutable);
MinidumpStreamType stream_type = stream->StreamType();
auto rv = stream_types_.insert(stream_type);
CHECK(rv.second) << "stream_type " << stream_type << " already present";
if (!rv.second) {
LOG(WARNING) << "discarding duplicate stream of type " << stream_type;
return false;
}
streams_.push_back(stream.release());
DCHECK_EQ(streams_.size(), stream_types_.size());
return true;
}
bool MinidumpFileWriter::WriteEverything(FileWriterInterface* file_writer) {

View File

@ -84,11 +84,16 @@ class MinidumpFileWriter final : public internal::MinidumpWritable {
//!
//! At most one object of each stream type (as obtained from
//! internal::MinidumpStreamWriter::StreamType()) may be added to a
//! MinidumpFileWriter object. It is an error to attempt to add multiple
//! streams with the same stream type.
//! MinidumpFileWriter object. If an attempt is made to add a stream whose
//! type matches an existing streams type, this method discards the new
//! stream.
//!
//! \note Valid in #kStateMutable.
void AddStream(std::unique_ptr<internal::MinidumpStreamWriter> stream);
//!
//! \return `true` on success. `false` on failure, as occurs when an attempt
//! is made to add a stream whose type matches an existing streams type,
//! with a message logged.
bool AddStream(std::unique_ptr<internal::MinidumpStreamWriter> stream);
// MinidumpWritable:

View File

@ -98,7 +98,7 @@ TEST(MinidumpFileWriter, OneStream) {
const uint8_t kStreamValue = 0x5a;
auto stream =
base::WrapUnique(new TestStream(kStreamType, kStreamSize, kStreamValue));
minidump_file.AddStream(std::move(stream));
ASSERT_TRUE(minidump_file.AddStream(std::move(stream)));
StringFile string_file;
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
@ -137,7 +137,7 @@ TEST(MinidumpFileWriter, ThreeStreams) {
const uint8_t kStream0Value = 0x5a;
auto stream0 = base::WrapUnique(
new TestStream(kStream0Type, kStream0Size, kStream0Value));
minidump_file.AddStream(std::move(stream0));
ASSERT_TRUE(minidump_file.AddStream(std::move(stream0)));
// Make the second streams type be a smaller quantity than the first streams
// to test that the streams show up in the order that they were added, not in
@ -147,14 +147,14 @@ TEST(MinidumpFileWriter, ThreeStreams) {
const uint8_t kStream1Value = 0xa5;
auto stream1 = base::WrapUnique(
new TestStream(kStream1Type, kStream1Size, kStream1Value));
minidump_file.AddStream(std::move(stream1));
ASSERT_TRUE(minidump_file.AddStream(std::move(stream1)));
const size_t kStream2Size = 1;
const MinidumpStreamType kStream2Type = static_cast<MinidumpStreamType>(0x7e);
const uint8_t kStream2Value = 0x36;
auto stream2 = base::WrapUnique(
new TestStream(kStream2Type, kStream2Size, kStream2Value));
minidump_file.AddStream(std::move(stream2));
ASSERT_TRUE(minidump_file.AddStream(std::move(stream2)));
StringFile string_file;
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
@ -221,7 +221,7 @@ TEST(MinidumpFileWriter, ZeroLengthStream) {
const size_t kStreamSize = 0;
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
auto stream = base::WrapUnique(new TestStream(kStreamType, kStreamSize, 0));
minidump_file.AddStream(std::move(stream));
ASSERT_TRUE(minidump_file.AddStream(std::move(stream)));
StringFile string_file;
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
@ -439,24 +439,48 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_CrashpadInfo) {
string_file.string(), directory[6].Location));
}
TEST(MinidumpFileWriterDeathTest, SameStreamType) {
TEST(MinidumpFileWriter, SameStreamType) {
MinidumpFileWriter minidump_file;
const size_t kStream0Size = 5;
const MinidumpStreamType kStream0Type = static_cast<MinidumpStreamType>(0x4d);
const size_t kStream0Size = 3;
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
const uint8_t kStream0Value = 0x5a;
auto stream0 = base::WrapUnique(
new TestStream(kStream0Type, kStream0Size, kStream0Value));
minidump_file.AddStream(std::move(stream0));
new TestStream(kStreamType, kStream0Size, kStream0Value));
ASSERT_TRUE(minidump_file.AddStream(std::move(stream0)));
// It is an error to add a second stream of the same type.
const size_t kStream1Size = 3;
const MinidumpStreamType kStream1Type = static_cast<MinidumpStreamType>(0x4d);
// An attempt to add a second stream of the same type should fail.
const size_t kStream1Size = 5;
const uint8_t kStream1Value = 0xa5;
auto stream1 = base::WrapUnique(
new TestStream(kStream1Type, kStream1Size, kStream1Value));
ASSERT_DEATH_CHECK(minidump_file.AddStream(std::move(stream1)),
"already present");
new TestStream(kStreamType, kStream1Size, kStream1Value));
ASSERT_FALSE(minidump_file.AddStream(std::move(stream1)));
StringFile string_file;
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
const size_t kStream0Offset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
const size_t kFileSize = kStream0Offset + kStream0Size;
ASSERT_EQ(kFileSize, string_file.string().size());
const MINIDUMP_DIRECTORY* directory;
const MINIDUMP_HEADER* header =
MinidumpHeaderAtStart(string_file.string(), &directory);
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
ASSERT_TRUE(directory);
EXPECT_EQ(kStreamType, directory[0].StreamType);
EXPECT_EQ(kStream0Size, directory[0].Location.DataSize);
EXPECT_EQ(kStream0Offset, directory[0].Location.Rva);
const uint8_t* stream_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
string_file.string(), directory[0].Location);
ASSERT_TRUE(stream_data);
std::string expected_stream(kStream0Size, kStream0Value);
EXPECT_EQ(0, memcmp(stream_data, expected_stream.c_str(), kStream0Size));
}
} // namespace

View File

@ -59,7 +59,7 @@ void GetHandleDataStream(
TEST(MinidumpHandleDataWriter, Empty) {
MinidumpFileWriter minidump_file_writer;
auto handle_data_writer = base::WrapUnique(new MinidumpHandleDataWriter());
minidump_file_writer.AddStream(std::move(handle_data_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(handle_data_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -92,7 +92,7 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
handle_data_writer->InitializeFromSnapshot(snapshot);
minidump_file_writer.AddStream(std::move(handle_data_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(handle_data_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -150,7 +150,7 @@ TEST(MinidumpHandleDataWriter, RepeatedTypeName) {
handle_data_writer->InitializeFromSnapshot(snapshot);
minidump_file_writer.AddStream(std::move(handle_data_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(handle_data_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));

View File

@ -60,7 +60,8 @@ TEST(MinidumpMemoryInfoWriter, Empty) {
MinidumpFileWriter minidump_file_writer;
auto memory_info_list_writer =
base::WrapUnique(new MinidumpMemoryInfoListWriter());
minidump_file_writer.AddStream(std::move(memory_info_list_writer));
ASSERT_TRUE(
minidump_file_writer.AddStream(std::move(memory_info_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -97,7 +98,8 @@ TEST(MinidumpMemoryInfoWriter, OneRegion) {
memory_map.push_back(memory_map_region.get());
memory_info_list_writer->InitializeFromSnapshot(memory_map);
minidump_file_writer.AddStream(std::move(memory_info_list_writer));
ASSERT_TRUE(
minidump_file_writer.AddStream(std::move(memory_info_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));

View File

@ -79,7 +79,7 @@ TEST(MinidumpMemoryWriter, EmptyMemoryList) {
MinidumpFileWriter minidump_file_writer;
auto memory_list_writer = base::WrapUnique(new MinidumpMemoryListWriter());
minidump_file_writer.AddStream(std::move(memory_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(memory_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -107,7 +107,7 @@ TEST(MinidumpMemoryWriter, OneMemoryRegion) {
new TestMinidumpMemoryWriter(kBaseAddress, kSize, kValue));
memory_list_writer->AddMemory(std::move(memory_writer));
minidump_file_writer.AddStream(std::move(memory_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(memory_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -148,7 +148,7 @@ TEST(MinidumpMemoryWriter, TwoMemoryRegions) {
new TestMinidumpMemoryWriter(kBaseAddress1, kSize1, kValue1));
memory_list_writer->AddMemory(std::move(memory_writer_1));
minidump_file_writer.AddStream(std::move(memory_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(memory_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -247,7 +247,7 @@ TEST(MinidumpMemoryWriter, ExtraMemory) {
auto memory_list_writer = base::WrapUnique(new MinidumpMemoryListWriter());
memory_list_writer->AddExtraMemory(test_memory_stream->memory());
minidump_file_writer.AddStream(std::move(test_memory_stream));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(test_memory_stream)));
const uint64_t kBaseAddress1 = 0x2000;
const size_t kSize1 = 0x0400;
@ -257,7 +257,7 @@ TEST(MinidumpMemoryWriter, ExtraMemory) {
new TestMinidumpMemoryWriter(kBaseAddress1, kSize1, kValue1));
memory_list_writer->AddMemory(std::move(memory_writer));
minidump_file_writer.AddStream(std::move(memory_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(memory_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -335,7 +335,7 @@ TEST(MinidumpMemoryWriter, AddFromSnapshot) {
memory_list_writer->AddFromSnapshot(memory_snapshots);
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(memory_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(memory_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));

View File

@ -193,7 +193,7 @@ TEST(MinidumpMiscInfoWriter, Empty) {
MinidumpFileWriter minidump_file_writer;
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -214,7 +214,7 @@ TEST(MinidumpMiscInfoWriter, ProcessId) {
misc_info_writer->SetProcessID(kProcessId);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -240,7 +240,7 @@ TEST(MinidumpMiscInfoWriter, ProcessTimes) {
misc_info_writer->SetProcessTimes(
kProcessCreateTime, kProcessUserTime, kProcessKernelTime);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -273,7 +273,7 @@ TEST(MinidumpMiscInfoWriter, ProcessorPowerInfo) {
kProcessorMaxIdleState,
kProcessorCurrentIdleState);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -300,7 +300,7 @@ TEST(MinidumpMiscInfoWriter, ProcessIntegrityLevel) {
misc_info_writer->SetProcessIntegrityLevel(kProcessIntegrityLevel);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -323,7 +323,7 @@ TEST(MinidumpMiscInfoWriter, ProcessExecuteFlags) {
misc_info_writer->SetProcessExecuteFlags(kProcessExecuteFlags);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -346,7 +346,7 @@ TEST(MinidumpMiscInfoWriter, ProtectedProcess) {
misc_info_writer->SetProtectedProcess(kProtectedProcess);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -383,7 +383,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
kDaylightDate,
kDaylightBias);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -444,7 +444,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
kSystemTimeZero,
kDaylightBias);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -485,7 +485,7 @@ TEST(MinidumpMiscInfoWriter, BuildStrings) {
misc_info_writer->SetBuildString(kBuildString, kDebugBuildString);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -522,7 +522,7 @@ TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) {
misc_info_writer->SetBuildString(build_string, debug_build_string);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -565,7 +565,7 @@ TEST(MinidumpMiscInfoWriter, XStateData) {
misc_info_writer->SetXStateData(kXStateData);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -587,7 +587,7 @@ TEST(MinidumpMiscInfoWriter, ProcessCookie) {
misc_info_writer->SetProcessCookie(kProcessCookie);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -649,7 +649,7 @@ TEST(MinidumpMiscInfoWriter, Everything) {
kDaylightBias);
misc_info_writer->SetBuildString(kBuildString, kDebugBuildString);
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -789,7 +789,7 @@ TEST(MinidumpMiscInfoWriter, InitializeFromSnapshot) {
misc_info_writer->InitializeFromSnapshot(&process_snapshot);
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(misc_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(misc_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));

View File

@ -67,7 +67,7 @@ TEST(MinidumpModuleWriter, EmptyModuleList) {
MinidumpFileWriter minidump_file_writer;
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
minidump_file_writer.AddStream(std::move(module_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -276,7 +276,7 @@ TEST(MinidumpModuleWriter, EmptyModule) {
module_writer->SetName(kModuleName);
module_list_writer->AddModule(std::move(module_writer));
minidump_file_writer.AddStream(std::move(module_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -367,7 +367,7 @@ TEST(MinidumpModuleWriter, OneModule) {
module_writer->SetMiscDebugRecord(std::move(misc_debug_writer));
module_list_writer->AddModule(std::move(module_writer));
minidump_file_writer.AddStream(std::move(module_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -442,7 +442,7 @@ TEST(MinidumpModuleWriter, OneModule_CodeViewUsesPDB20_MiscUsesUTF16) {
module_writer->SetMiscDebugRecord(std::move(misc_debug_writer));
module_list_writer->AddModule(std::move(module_writer));
minidump_file_writer.AddStream(std::move(module_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -534,7 +534,7 @@ TEST(MinidumpModuleWriter, ThreeModules) {
module_list_writer->AddModule(std::move(module_writer_2));
minidump_file_writer.AddStream(std::move(module_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -727,7 +727,7 @@ TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
module_list_writer->InitializeFromSnapshot(module_snapshots);
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(module_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -759,7 +759,7 @@ TEST(MinidumpModuleWriterDeathTest, NoModuleName) {
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
auto module_writer = base::WrapUnique(new MinidumpModuleWriter());
module_list_writer->AddModule(std::move(module_writer));
minidump_file_writer.AddStream(std::move(module_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
StringFile string_file;
ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),

View File

@ -82,7 +82,7 @@ TEST(MinidumpSystemInfoWriter, Empty) {
system_info_writer->SetCSDVersion(std::string());
minidump_file_writer.AddStream(std::move(system_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -153,7 +153,7 @@ TEST(MinidumpSystemInfoWriter, X86_Win) {
system_info_writer->SetCPUX86VersionAndFeatures(kCPUVersion, kCPUFeatures);
system_info_writer->SetCPUX86AMDExtendedFeatures(kAMDFeatures);
minidump_file_writer.AddStream(std::move(system_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -213,7 +213,7 @@ TEST(MinidumpSystemInfoWriter, AMD64_Mac) {
system_info_writer->SetCSDVersion(kCSDVersion);
system_info_writer->SetCPUOtherFeatures(kCPUFeatures[0], kCPUFeatures[1]);
minidump_file_writer.AddStream(std::move(system_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -255,7 +255,7 @@ TEST(MinidumpSystemInfoWriter, X86_CPUVendorFromRegisters) {
kCPUVendor[0], kCPUVendor[1], kCPUVendor[2]);
system_info_writer->SetCSDVersion(std::string());
minidump_file_writer.AddStream(std::move(system_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -335,7 +335,7 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_X86) {
system_info_writer->InitializeFromSnapshot(&system_snapshot);
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(system_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -431,7 +431,7 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_AMD64) {
system_info_writer->InitializeFromSnapshot(&system_snapshot);
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(system_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -469,7 +469,7 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_AMD64) {
TEST(MinidumpSystemInfoWriterDeathTest, NoCSDVersion) {
MinidumpFileWriter minidump_file_writer;
auto system_info_writer = base::WrapUnique(new MinidumpSystemInfoWriter());
minidump_file_writer.AddStream(std::move(system_info_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(system_info_writer)));
StringFile string_file;
ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),

View File

@ -81,7 +81,7 @@ TEST(MinidumpThreadWriter, EmptyThreadList) {
MinidumpFileWriter minidump_file_writer;
auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter());
minidump_file_writer.AddStream(std::move(thread_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(thread_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -161,7 +161,7 @@ TEST(MinidumpThreadWriter, OneThread_x86_NoStack) {
thread_writer->SetContext(std::move(context_x86_writer));
thread_list_writer->AddThread(std::move(thread_writer));
minidump_file_writer.AddStream(std::move(thread_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(thread_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -231,7 +231,7 @@ TEST(MinidumpThreadWriter, OneThread_AMD64_Stack) {
thread_writer->SetContext(std::move(context_amd64_writer));
thread_list_writer->AddThread(std::move(thread_writer));
minidump_file_writer.AddStream(std::move(thread_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(thread_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -363,8 +363,8 @@ TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) {
thread_list_writer->AddThread(std::move(thread_writer_2));
minidump_file_writer.AddStream(std::move(thread_list_writer));
minidump_file_writer.AddStream(std::move(memory_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(thread_list_writer)));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(memory_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -623,8 +623,8 @@ void RunInitializeFromSnapshotTest(bool thread_id_collision) {
thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map);
MinidumpFileWriter minidump_file_writer;
minidump_file_writer.AddStream(std::move(thread_list_writer));
minidump_file_writer.AddStream(std::move(memory_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(thread_list_writer)));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(memory_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -702,7 +702,7 @@ TEST(MinidumpThreadWriterDeathTest, NoContext) {
auto thread_writer = base::WrapUnique(new MinidumpThreadWriter());
thread_list_writer->AddThread(std::move(thread_writer));
minidump_file_writer.AddStream(std::move(thread_list_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(thread_list_writer)));
StringFile string_file;
ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),

View File

@ -82,7 +82,8 @@ TEST(MinidumpUnloadedModuleWriter, EmptyModule) {
unloaded_module_list_writer->AddUnloadedModule(
std::move(unloaded_module_writer));
minidump_file_writer.AddStream(std::move(unloaded_module_list_writer));
ASSERT_TRUE(
minidump_file_writer.AddStream(std::move(unloaded_module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -128,7 +129,8 @@ TEST(MinidumpUnloadedModuleWriter, OneModule) {
unloaded_module_list_writer->AddUnloadedModule(
std::move(unloaded_module_writer));
minidump_file_writer.AddStream(std::move(unloaded_module_list_writer));
ASSERT_TRUE(
minidump_file_writer.AddStream(std::move(unloaded_module_list_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));

View File

@ -57,7 +57,7 @@ TEST(MinidumpUserStreamWriter, NoData) {
auto stream =
base::WrapUnique(new UserMinidumpStream(kTestStreamId, nullptr));
user_stream_writer->InitializeFromSnapshot(stream.get());
minidump_file_writer.AddStream(std::move(user_stream_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(user_stream_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
@ -84,7 +84,7 @@ TEST(MinidumpUserStreamWriter, OneStream) {
auto stream =
base::WrapUnique(new UserMinidumpStream(kTestStreamId, test_data));
user_stream_writer->InitializeFromSnapshot(stream.get());
minidump_file_writer.AddStream(std::move(user_stream_writer));
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(user_stream_writer)));
StringFile string_file;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));