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, |
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_exception_writer.h" | 15 #include "minidump/minidump_exception_writer.h" |
16 | 16 |
17 #include <sys/types.h> | 17 #include <sys/types.h> |
18 | 18 |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "minidump/minidump_context_writer.h" | 20 #include "minidump/minidump_context_writer.h" |
21 #include "util/file/file_writer.h" | 21 #include "util/file/file_writer.h" |
22 | 22 |
23 namespace crashpad { | 23 namespace crashpad { |
24 | 24 |
25 MinidumpExceptionWriter::MinidumpExceptionWriter() | 25 MinidumpExceptionWriter::MinidumpExceptionWriter() |
26 : MinidumpStreamWriter(), exception_(), context_(nullptr) { | 26 : MinidumpStreamWriter(), exception_(), context_(nullptr) { |
27 } | 27 } |
28 | 28 |
29 void MinidumpExceptionWriter::SetContext(MinidumpContextWriter* context) { | 29 MinidumpExceptionWriter::~MinidumpExceptionWriter() { |
| 30 } |
| 31 |
| 32 void MinidumpExceptionWriter::SetContext( |
| 33 scoped_ptr<MinidumpContextWriter> context) { |
30 DCHECK_EQ(state(), kStateMutable); | 34 DCHECK_EQ(state(), kStateMutable); |
31 | 35 |
32 context_ = context; | 36 context_ = context.Pass(); |
33 } | 37 } |
34 | 38 |
35 void MinidumpExceptionWriter::SetExceptionInformation( | 39 void MinidumpExceptionWriter::SetExceptionInformation( |
36 const std::vector<uint64_t>& exception_information) { | 40 const std::vector<uint64_t>& exception_information) { |
37 DCHECK_EQ(state(), kStateMutable); | 41 DCHECK_EQ(state(), kStateMutable); |
38 | 42 |
39 const size_t parameters = exception_information.size(); | 43 const size_t parameters = exception_information.size(); |
40 const size_t kMaxParameters = | 44 const size_t kMaxParameters = |
41 arraysize(exception_.ExceptionRecord.ExceptionInformation); | 45 arraysize(exception_.ExceptionRecord.ExceptionInformation); |
42 CHECK_LE(parameters, kMaxParameters); | 46 CHECK_LE(parameters, kMaxParameters); |
(...skipping 26 matching lines...) Expand all Loading... |
69 DCHECK_GE(state(), kStateFrozen); | 73 DCHECK_GE(state(), kStateFrozen); |
70 | 74 |
71 return sizeof(exception_); | 75 return sizeof(exception_); |
72 } | 76 } |
73 | 77 |
74 std::vector<internal::MinidumpWritable*> MinidumpExceptionWriter::Children() { | 78 std::vector<internal::MinidumpWritable*> MinidumpExceptionWriter::Children() { |
75 DCHECK_GE(state(), kStateFrozen); | 79 DCHECK_GE(state(), kStateFrozen); |
76 DCHECK(context_); | 80 DCHECK(context_); |
77 | 81 |
78 std::vector<MinidumpWritable*> children; | 82 std::vector<MinidumpWritable*> children; |
79 children.push_back(context_); | 83 children.push_back(context_.get()); |
80 | 84 |
81 return children; | 85 return children; |
82 } | 86 } |
83 | 87 |
84 bool MinidumpExceptionWriter::WriteObject(FileWriterInterface* file_writer) { | 88 bool MinidumpExceptionWriter::WriteObject(FileWriterInterface* file_writer) { |
85 DCHECK_EQ(state(), kStateWritable); | 89 DCHECK_EQ(state(), kStateWritable); |
86 | 90 |
87 return file_writer->Write(&exception_, sizeof(exception_)); | 91 return file_writer->Write(&exception_, sizeof(exception_)); |
88 } | 92 } |
89 | 93 |
90 MinidumpStreamType MinidumpExceptionWriter::StreamType() const { | 94 MinidumpStreamType MinidumpExceptionWriter::StreamType() const { |
91 return kMinidumpStreamTypeException; | 95 return kMinidumpStreamTypeException; |
92 } | 96 } |
93 | 97 |
94 } // namespace crashpad | 98 } // namespace crashpad |
OLD | NEW |