OLD | NEW |
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 Loading... |
21 #include "minidump/minidump_memory_writer.h" | 21 #include "minidump/minidump_memory_writer.h" |
22 #include "util/file/file_writer.h" | 22 #include "util/file/file_writer.h" |
23 #include "util/numeric/safe_assignment.h" | 23 #include "util/numeric/safe_assignment.h" |
24 | 24 |
25 namespace crashpad { | 25 namespace crashpad { |
26 | 26 |
27 MinidumpThreadWriter::MinidumpThreadWriter() | 27 MinidumpThreadWriter::MinidumpThreadWriter() |
28 : MinidumpWritable(), thread_(), stack_(nullptr), context_(nullptr) { | 28 : MinidumpWritable(), thread_(), stack_(nullptr), context_(nullptr) { |
29 } | 29 } |
30 | 30 |
| 31 MinidumpThreadWriter::~MinidumpThreadWriter() { |
| 32 } |
| 33 |
31 const MINIDUMP_THREAD* MinidumpThreadWriter::MinidumpThread() const { | 34 const MINIDUMP_THREAD* MinidumpThreadWriter::MinidumpThread() const { |
32 DCHECK_EQ(state(), kStateWritable); | 35 DCHECK_EQ(state(), kStateWritable); |
33 | 36 |
34 return &thread_; | 37 return &thread_; |
35 } | 38 } |
36 | 39 |
37 void MinidumpThreadWriter::SetStack(MinidumpMemoryWriter* stack) { | 40 void MinidumpThreadWriter::SetStack(scoped_ptr<MinidumpMemoryWriter> stack) { |
38 DCHECK_EQ(state(), kStateMutable); | 41 DCHECK_EQ(state(), kStateMutable); |
39 | 42 |
40 stack_ = stack; | 43 stack_ = stack.Pass(); |
41 } | 44 } |
42 | 45 |
43 void MinidumpThreadWriter::SetContext(MinidumpContextWriter* context) { | 46 void MinidumpThreadWriter::SetContext( |
| 47 scoped_ptr<MinidumpContextWriter> context) { |
44 DCHECK_EQ(state(), kStateMutable); | 48 DCHECK_EQ(state(), kStateMutable); |
45 | 49 |
46 context_ = context; | 50 context_ = context.Pass(); |
47 } | 51 } |
48 | 52 |
49 bool MinidumpThreadWriter::Freeze() { | 53 bool MinidumpThreadWriter::Freeze() { |
50 DCHECK_EQ(state(), kStateMutable); | 54 DCHECK_EQ(state(), kStateMutable); |
51 CHECK(context_); | 55 CHECK(context_); |
52 | 56 |
53 if (!MinidumpWritable::Freeze()) { | 57 if (!MinidumpWritable::Freeze()) { |
54 return false; | 58 return false; |
55 } | 59 } |
56 | 60 |
(...skipping 14 matching lines...) Expand all Loading... |
71 // are responsible for writing themselves. | 75 // are responsible for writing themselves. |
72 return 0; | 76 return 0; |
73 } | 77 } |
74 | 78 |
75 std::vector<internal::MinidumpWritable*> MinidumpThreadWriter::Children() { | 79 std::vector<internal::MinidumpWritable*> MinidumpThreadWriter::Children() { |
76 DCHECK_GE(state(), kStateFrozen); | 80 DCHECK_GE(state(), kStateFrozen); |
77 DCHECK(context_); | 81 DCHECK(context_); |
78 | 82 |
79 std::vector<MinidumpWritable*> children; | 83 std::vector<MinidumpWritable*> children; |
80 if (stack_) { | 84 if (stack_) { |
81 children.push_back(stack_); | 85 children.push_back(stack_.get()); |
82 } | 86 } |
83 children.push_back(context_); | 87 children.push_back(context_.get()); |
84 | 88 |
85 return children; | 89 return children; |
86 } | 90 } |
87 | 91 |
88 bool MinidumpThreadWriter::WriteObject(FileWriterInterface* file_writer) { | 92 bool MinidumpThreadWriter::WriteObject(FileWriterInterface* file_writer) { |
89 DCHECK_EQ(state(), kStateWritable); | 93 DCHECK_EQ(state(), kStateWritable); |
90 | 94 |
91 // This object doesn’t directly write anything itself. Its MINIDUMP_THREAD is | 95 // This object doesn’t directly write anything itself. Its MINIDUMP_THREAD is |
92 // written by its parent as part of a MINIDUMP_THREAD_LIST, and its children | 96 // written by its parent as part of a MINIDUMP_THREAD_LIST, and its children |
93 // are responsible for writing themselves. | 97 // are responsible for writing themselves. |
(...skipping 11 matching lines...) Expand all Loading... |
105 } | 109 } |
106 | 110 |
107 void MinidumpThreadListWriter::SetMemoryListWriter( | 111 void MinidumpThreadListWriter::SetMemoryListWriter( |
108 MinidumpMemoryListWriter* memory_list_writer) { | 112 MinidumpMemoryListWriter* memory_list_writer) { |
109 DCHECK_EQ(state(), kStateMutable); | 113 DCHECK_EQ(state(), kStateMutable); |
110 DCHECK(threads_.empty()); | 114 DCHECK(threads_.empty()); |
111 | 115 |
112 memory_list_writer_ = memory_list_writer; | 116 memory_list_writer_ = memory_list_writer; |
113 } | 117 } |
114 | 118 |
115 void MinidumpThreadListWriter::AddThread(MinidumpThreadWriter* thread) { | 119 void MinidumpThreadListWriter::AddThread( |
| 120 scoped_ptr<MinidumpThreadWriter> thread) { |
116 DCHECK_EQ(state(), kStateMutable); | 121 DCHECK_EQ(state(), kStateMutable); |
117 | 122 |
118 threads_.push_back(thread); | |
119 | |
120 if (memory_list_writer_) { | 123 if (memory_list_writer_) { |
121 MinidumpMemoryWriter* stack = thread->Stack(); | 124 MinidumpMemoryWriter* stack = thread->Stack(); |
122 if (stack) { | 125 if (stack) { |
123 memory_list_writer_->AddExtraMemory(stack); | 126 memory_list_writer_->AddExtraMemory(stack); |
124 } | 127 } |
125 } | 128 } |
| 129 |
| 130 threads_.push_back(thread.release()); |
126 } | 131 } |
127 | 132 |
128 bool MinidumpThreadListWriter::Freeze() { | 133 bool MinidumpThreadListWriter::Freeze() { |
129 DCHECK_EQ(state(), kStateMutable); | 134 DCHECK_EQ(state(), kStateMutable); |
130 | 135 |
131 if (!MinidumpStreamWriter::Freeze()) { | 136 if (!MinidumpStreamWriter::Freeze()) { |
132 return false; | 137 return false; |
133 } | 138 } |
134 | 139 |
135 size_t thread_count = threads_.size(); | 140 size_t thread_count = threads_.size(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 178 } |
174 | 179 |
175 return file_writer->WriteIoVec(&iovecs); | 180 return file_writer->WriteIoVec(&iovecs); |
176 } | 181 } |
177 | 182 |
178 MinidumpStreamType MinidumpThreadListWriter::StreamType() const { | 183 MinidumpStreamType MinidumpThreadListWriter::StreamType() const { |
179 return kMinidumpStreamTypeThreadList; | 184 return kMinidumpStreamTypeThreadList; |
180 } | 185 } |
181 | 186 |
182 } // namespace crashpad | 187 } // namespace crashpad |
OLD | NEW |