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

Side by Side Diff: minidump/minidump_memory_info_writer.cc

Issue 1379873005: win: Write memory map info as MINIDUMP_MEMORY_INFO[_LIST] (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@save-peb-more-2
Patch Set: typo 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
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "minidump/minidump_memory_info_writer.h"
16
17 #include "base/logging.h"
18 #include "snapshot/memory_map_region_snapshot.h"
19 #include "util/file/file_writer.h"
20
21 namespace crashpad {
22
23 MinidumpMemoryInfoListWriter::MinidumpMemoryInfoListWriter()
24 : memory_info_list_(), items_(), total_size_(0) {
25 }
26
27 MinidumpMemoryInfoListWriter::~MinidumpMemoryInfoListWriter() {
28 }
29
30 void MinidumpMemoryInfoListWriter::InitializeFromSnapshot(
31 const std::vector<const MemoryMapRegionSnapshot*>& memory_map) {
32 DCHECK_EQ(state(), kStateMutable);
33
34 DCHECK(items_.empty());
35 for (const auto& region : memory_map)
36 items_.push_back(region->AsMinidumpMemoryInfo());
37 }
38
39 bool MinidumpMemoryInfoListWriter::Freeze() {
40 DCHECK_EQ(state(), kStateMutable);
41
42 if (!MinidumpStreamWriter::Freeze())
43 return false;
44
45 memory_info_list_.SizeOfHeader = sizeof(MINIDUMP_MEMORY_INFO_LIST);
46 memory_info_list_.SizeOfEntry = sizeof(MINIDUMP_MEMORY_INFO);
47 memory_info_list_.NumberOfEntries = items_.size();
48
49 total_size_ = sizeof(MINIDUMP_MEMORY_INFO_LIST) +
Mark Mentovai 2015/10/12 14:34:46 You don’t need total_size_ as a member, you can co
scottmg 2015/10/13 19:51:29 Done.
50 sizeof(MINIDUMP_MEMORY_INFO) * items_.size();
51
52 return true;
53 }
54
55 size_t MinidumpMemoryInfoListWriter::SizeOfObject() {
56 DCHECK_GE(state(), kStateFrozen);
57 return total_size_;
58 }
59
60 std::vector<internal::MinidumpWritable*>
61 MinidumpMemoryInfoListWriter::Children() {
62 DCHECK_GE(state(), kStateFrozen);
63 return std::vector<internal::MinidumpWritable*>();
64 }
65
66 bool MinidumpMemoryInfoListWriter::WriteObject(
67 FileWriterInterface* file_writer) {
68 DCHECK_EQ(state(), kStateWritable);
69
70 WritableIoVec iov;
71 iov.iov_base = &memory_info_list_;
72 iov.iov_len = sizeof(memory_info_list_);
73 std::vector<WritableIoVec> iovecs(1, iov);
74
75 for (const auto& minidump_memory_info : items_) {
76 iov.iov_base = &minidump_memory_info;
77 iov.iov_len = sizeof(minidump_memory_info);
78 iovecs.push_back(iov);
79 }
80
81 return file_writer->WriteIoVec(&iovecs);
82 }
83
84 MinidumpStreamType MinidumpMemoryInfoListWriter::StreamType() const {
85 return kMinidumpStreamTypeMemoryInfoList;
86 }
87
88 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698