| 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 "snapshot/exception_snapshot.h" |
| 21 #include "util/file/file_writer.h" | 22 #include "util/file/file_writer.h" |
| 22 | 23 |
| 23 namespace crashpad { | 24 namespace crashpad { |
| 24 | 25 |
| 25 MinidumpExceptionWriter::MinidumpExceptionWriter() | 26 MinidumpExceptionWriter::MinidumpExceptionWriter() |
| 26 : MinidumpStreamWriter(), exception_(), context_(nullptr) { | 27 : MinidumpStreamWriter(), exception_(), context_(nullptr) { |
| 27 } | 28 } |
| 28 | 29 |
| 29 MinidumpExceptionWriter::~MinidumpExceptionWriter() { | 30 MinidumpExceptionWriter::~MinidumpExceptionWriter() { |
| 30 } | 31 } |
| 31 | 32 |
| 33 void MinidumpExceptionWriter::InitializeFromSnapshot( |
| 34 const ExceptionSnapshot* exception_snapshot, |
| 35 const MinidumpThreadIDMap* thread_id_map) { |
| 36 DCHECK_EQ(state(), kStateMutable); |
| 37 DCHECK(!context_); |
| 38 |
| 39 auto thread_id_it = thread_id_map->find(exception_snapshot->ThreadID()); |
| 40 DCHECK(thread_id_it != thread_id_map->end()); |
| 41 SetThreadID(thread_id_it->second); |
| 42 |
| 43 SetExceptionCode(exception_snapshot->Exception()); |
| 44 SetExceptionFlags(exception_snapshot->ExceptionInfo()); |
| 45 SetExceptionAddress(exception_snapshot->ExceptionAddress()); |
| 46 SetExceptionInformation(exception_snapshot->Codes()); |
| 47 |
| 48 scoped_ptr<MinidumpContextWriter> context = |
| 49 MinidumpContextWriter::CreateFromSnapshot(exception_snapshot->Context()); |
| 50 SetContext(context.Pass()); |
| 51 } |
| 52 |
| 32 void MinidumpExceptionWriter::SetContext( | 53 void MinidumpExceptionWriter::SetContext( |
| 33 scoped_ptr<MinidumpContextWriter> context) { | 54 scoped_ptr<MinidumpContextWriter> context) { |
| 34 DCHECK_EQ(state(), kStateMutable); | 55 DCHECK_EQ(state(), kStateMutable); |
| 35 | 56 |
| 36 context_ = context.Pass(); | 57 context_ = context.Pass(); |
| 37 } | 58 } |
| 38 | 59 |
| 39 void MinidumpExceptionWriter::SetExceptionInformation( | 60 void MinidumpExceptionWriter::SetExceptionInformation( |
| 40 const std::vector<uint64_t>& exception_information) { | 61 const std::vector<uint64_t>& exception_information) { |
| 41 DCHECK_EQ(state(), kStateMutable); | 62 DCHECK_EQ(state(), kStateMutable); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 DCHECK_EQ(state(), kStateWritable); | 110 DCHECK_EQ(state(), kStateWritable); |
| 90 | 111 |
| 91 return file_writer->Write(&exception_, sizeof(exception_)); | 112 return file_writer->Write(&exception_, sizeof(exception_)); |
| 92 } | 113 } |
| 93 | 114 |
| 94 MinidumpStreamType MinidumpExceptionWriter::StreamType() const { | 115 MinidumpStreamType MinidumpExceptionWriter::StreamType() const { |
| 95 return kMinidumpStreamTypeException; | 116 return kMinidumpStreamTypeException; |
| 96 } | 117 } |
| 97 | 118 |
| 98 } // namespace crashpad | 119 } // namespace crashpad |
| OLD | NEW |