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

Side by Side Diff: minidump/minidump_file_writer.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_exception_writer_test.cc ('k') | minidump/minidump_file_writer_test.cc » ('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_file_writer.h" 15 #include "minidump/minidump_file_writer.h"
16 16
17 #include <utility>
18
17 #include "base/logging.h" 19 #include "base/logging.h"
18 #include "minidump/minidump_crashpad_info_writer.h" 20 #include "minidump/minidump_crashpad_info_writer.h"
19 #include "minidump/minidump_exception_writer.h" 21 #include "minidump/minidump_exception_writer.h"
20 #include "minidump/minidump_handle_writer.h" 22 #include "minidump/minidump_handle_writer.h"
21 #include "minidump/minidump_memory_info_writer.h" 23 #include "minidump/minidump_memory_info_writer.h"
22 #include "minidump/minidump_memory_writer.h" 24 #include "minidump/minidump_memory_writer.h"
23 #include "minidump/minidump_misc_info_writer.h" 25 #include "minidump/minidump_misc_info_writer.h"
24 #include "minidump/minidump_module_writer.h" 26 #include "minidump/minidump_module_writer.h"
25 #include "minidump/minidump_system_info_writer.h" 27 #include "minidump/minidump_system_info_writer.h"
26 #include "minidump/minidump_thread_id_map.h" 28 #include "minidump/minidump_thread_id_map.h"
27 #include "minidump/minidump_thread_writer.h" 29 #include "minidump/minidump_thread_writer.h"
28 #include "minidump/minidump_writer_util.h" 30 #include "minidump/minidump_writer_util.h"
29 #include "snapshot/process_snapshot.h" 31 #include "snapshot/process_snapshot.h"
30 #include "util/file/file_writer.h" 32 #include "util/file/file_writer.h"
31 #include "util/stdlib/move.h"
32 #include "util/numeric/safe_assignment.h" 33 #include "util/numeric/safe_assignment.h"
33 34
34 namespace crashpad { 35 namespace crashpad {
35 36
36 MinidumpFileWriter::MinidumpFileWriter() 37 MinidumpFileWriter::MinidumpFileWriter()
37 : MinidumpWritable(), header_(), streams_(), stream_types_() { 38 : MinidumpWritable(), header_(), streams_(), stream_types_() {
38 // Don’t set the signature field right away. Leave it set to 0, so that a 39 // Don’t set the signature field right away. Leave it set to 0, so that a
39 // partially-written minidump file isn’t confused for a complete and valid 40 // partially-written minidump file isn’t confused for a complete and valid
40 // one. The header will be rewritten in WriteToFile(). 41 // one. The header will be rewritten in WriteToFile().
41 header_.Signature = 0; 42 header_.Signature = 0;
(...skipping 19 matching lines...) Expand all
61 // done by MinidumpMiscInfoWriter::InitializeFromSnapshot(). Handling both 62 // done by MinidumpMiscInfoWriter::InitializeFromSnapshot(). Handling both
62 // timestamps in the same way allows the highest-fidelity computation of 63 // timestamps in the same way allows the highest-fidelity computation of
63 // process uptime as the difference between the two values. 64 // process uptime as the difference between the two values.
64 timeval snapshot_time; 65 timeval snapshot_time;
65 process_snapshot->SnapshotTime(&snapshot_time); 66 process_snapshot->SnapshotTime(&snapshot_time);
66 SetTimestamp(snapshot_time.tv_sec); 67 SetTimestamp(snapshot_time.tv_sec);
67 68
68 const SystemSnapshot* system_snapshot = process_snapshot->System(); 69 const SystemSnapshot* system_snapshot = process_snapshot->System();
69 auto system_info = make_scoped_ptr(new MinidumpSystemInfoWriter()); 70 auto system_info = make_scoped_ptr(new MinidumpSystemInfoWriter());
70 system_info->InitializeFromSnapshot(system_snapshot); 71 system_info->InitializeFromSnapshot(system_snapshot);
71 AddStream(crashpad::move(system_info)); 72 AddStream(std::move(system_info));
72 73
73 auto misc_info = make_scoped_ptr(new MinidumpMiscInfoWriter()); 74 auto misc_info = make_scoped_ptr(new MinidumpMiscInfoWriter());
74 misc_info->InitializeFromSnapshot(process_snapshot); 75 misc_info->InitializeFromSnapshot(process_snapshot);
75 AddStream(crashpad::move(misc_info)); 76 AddStream(std::move(misc_info));
76 77
77 auto memory_list = make_scoped_ptr(new MinidumpMemoryListWriter()); 78 auto memory_list = make_scoped_ptr(new MinidumpMemoryListWriter());
78 auto thread_list = make_scoped_ptr(new MinidumpThreadListWriter()); 79 auto thread_list = make_scoped_ptr(new MinidumpThreadListWriter());
79 thread_list->SetMemoryListWriter(memory_list.get()); 80 thread_list->SetMemoryListWriter(memory_list.get());
80 MinidumpThreadIDMap thread_id_map; 81 MinidumpThreadIDMap thread_id_map;
81 thread_list->InitializeFromSnapshot(process_snapshot->Threads(), 82 thread_list->InitializeFromSnapshot(process_snapshot->Threads(),
82 &thread_id_map); 83 &thread_id_map);
83 AddStream(crashpad::move(thread_list)); 84 AddStream(std::move(thread_list));
84 85
85 const ExceptionSnapshot* exception_snapshot = process_snapshot->Exception(); 86 const ExceptionSnapshot* exception_snapshot = process_snapshot->Exception();
86 if (exception_snapshot) { 87 if (exception_snapshot) {
87 auto exception = make_scoped_ptr(new MinidumpExceptionWriter()); 88 auto exception = make_scoped_ptr(new MinidumpExceptionWriter());
88 exception->InitializeFromSnapshot(exception_snapshot, thread_id_map); 89 exception->InitializeFromSnapshot(exception_snapshot, thread_id_map);
89 AddStream(crashpad::move(exception)); 90 AddStream(std::move(exception));
90 } 91 }
91 92
92 auto module_list = make_scoped_ptr(new MinidumpModuleListWriter()); 93 auto module_list = make_scoped_ptr(new MinidumpModuleListWriter());
93 module_list->InitializeFromSnapshot(process_snapshot->Modules()); 94 module_list->InitializeFromSnapshot(process_snapshot->Modules());
94 AddStream(crashpad::move(module_list)); 95 AddStream(std::move(module_list));
95 96
96 auto crashpad_info = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); 97 auto crashpad_info = make_scoped_ptr(new MinidumpCrashpadInfoWriter());
97 crashpad_info->InitializeFromSnapshot(process_snapshot); 98 crashpad_info->InitializeFromSnapshot(process_snapshot);
98 99
99 // Since the MinidumpCrashpadInfo stream is an extension, it’s safe to not add 100 // Since the MinidumpCrashpadInfo stream is an extension, it’s safe to not add
100 // it to the minidump file if it wouldn’t carry any useful information. 101 // it to the minidump file if it wouldn’t carry any useful information.
101 if (crashpad_info->IsUseful()) { 102 if (crashpad_info->IsUseful()) {
102 AddStream(crashpad::move(crashpad_info)); 103 AddStream(std::move(crashpad_info));
103 } 104 }
104 105
105 std::vector<const MemoryMapRegionSnapshot*> memory_map_snapshot = 106 std::vector<const MemoryMapRegionSnapshot*> memory_map_snapshot =
106 process_snapshot->MemoryMap(); 107 process_snapshot->MemoryMap();
107 if (!memory_map_snapshot.empty()) { 108 if (!memory_map_snapshot.empty()) {
108 auto memory_info_list = make_scoped_ptr(new MinidumpMemoryInfoListWriter()); 109 auto memory_info_list = make_scoped_ptr(new MinidumpMemoryInfoListWriter());
109 memory_info_list->InitializeFromSnapshot(memory_map_snapshot); 110 memory_info_list->InitializeFromSnapshot(memory_map_snapshot);
110 AddStream(crashpad::move(memory_info_list)); 111 AddStream(std::move(memory_info_list));
111 } 112 }
112 113
113 std::vector<HandleSnapshot> handles_snapshot = process_snapshot->Handles(); 114 std::vector<HandleSnapshot> handles_snapshot = process_snapshot->Handles();
114 if (!handles_snapshot.empty()) { 115 if (!handles_snapshot.empty()) {
115 auto handle_data_writer = make_scoped_ptr(new MinidumpHandleDataWriter()); 116 auto handle_data_writer = make_scoped_ptr(new MinidumpHandleDataWriter());
116 handle_data_writer->InitializeFromSnapshot(handles_snapshot); 117 handle_data_writer->InitializeFromSnapshot(handles_snapshot);
117 AddStream(crashpad::move(handle_data_writer)); 118 AddStream(std::move(handle_data_writer));
118 } 119 }
119 120
120 memory_list->AddFromSnapshot(process_snapshot->ExtraMemory()); 121 memory_list->AddFromSnapshot(process_snapshot->ExtraMemory());
121 122
122 AddStream(crashpad::move(memory_list)); 123 AddStream(std::move(memory_list));
123 } 124 }
124 125
125 void MinidumpFileWriter::SetTimestamp(time_t timestamp) { 126 void MinidumpFileWriter::SetTimestamp(time_t timestamp) {
126 DCHECK_EQ(state(), kStateMutable); 127 DCHECK_EQ(state(), kStateMutable);
127 128
128 internal::MinidumpWriterUtil::AssignTimeT(&header_.TimeDateStamp, timestamp); 129 internal::MinidumpWriterUtil::AssignTimeT(&header_.TimeDateStamp, timestamp);
129 } 130 }
130 131
131 void MinidumpFileWriter::AddStream( 132 void MinidumpFileWriter::AddStream(
132 scoped_ptr<internal::MinidumpStreamWriter> stream) { 133 scoped_ptr<internal::MinidumpStreamWriter> stream) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 for (internal::MinidumpStreamWriter* stream : streams_) { 241 for (internal::MinidumpStreamWriter* stream : streams_) {
241 iov.iov_base = stream->DirectoryListEntry(); 242 iov.iov_base = stream->DirectoryListEntry();
242 iov.iov_len = sizeof(MINIDUMP_DIRECTORY); 243 iov.iov_len = sizeof(MINIDUMP_DIRECTORY);
243 iovecs.push_back(iov); 244 iovecs.push_back(iov);
244 } 245 }
245 246
246 return file_writer->WriteIoVec(&iovecs); 247 return file_writer->WriteIoVec(&iovecs);
247 } 248 }
248 249
249 } // namespace crashpad 250 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_exception_writer_test.cc ('k') | minidump/minidump_file_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698