OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_context_writer.h" |
| 16 |
| 17 #include "base/logging.h" |
| 18 |
| 19 namespace crashpad { |
| 20 |
| 21 MinidumpContextWriter::~MinidumpContextWriter() { |
| 22 } |
| 23 |
| 24 size_t MinidumpContextWriter::SizeOfObject() { |
| 25 DCHECK_GE(state(), kStateFrozen); |
| 26 |
| 27 return ContextSize(); |
| 28 } |
| 29 |
| 30 MinidumpContextX86Writer::MinidumpContextX86Writer() |
| 31 : MinidumpContextWriter(), context_() { |
| 32 context_.context_flags = kMinidumpContextX86; |
| 33 } |
| 34 |
| 35 MinidumpContextX86Writer::~MinidumpContextX86Writer() { |
| 36 } |
| 37 |
| 38 bool MinidumpContextX86Writer::WriteObject(FileWriterInterface* file_writer) { |
| 39 DCHECK_EQ(state(), kStateWritable); |
| 40 |
| 41 return file_writer->Write(&context_, sizeof(context_)); |
| 42 } |
| 43 |
| 44 size_t MinidumpContextX86Writer::ContextSize() const { |
| 45 DCHECK_GE(state(), kStateFrozen); |
| 46 |
| 47 return sizeof(context_); |
| 48 } |
| 49 |
| 50 MinidumpContextAMD64Writer::MinidumpContextAMD64Writer() |
| 51 : MinidumpContextWriter(), context_() { |
| 52 context_.context_flags = kMinidumpContextAMD64; |
| 53 } |
| 54 |
| 55 MinidumpContextAMD64Writer::~MinidumpContextAMD64Writer() { |
| 56 } |
| 57 |
| 58 size_t MinidumpContextAMD64Writer::Alignment() { |
| 59 DCHECK_GE(state(), kStateFrozen); |
| 60 |
| 61 // Match the alignment of MinidumpContextAMD64. |
| 62 return 16; |
| 63 } |
| 64 |
| 65 bool MinidumpContextAMD64Writer::WriteObject(FileWriterInterface* file_writer) { |
| 66 DCHECK_EQ(state(), kStateWritable); |
| 67 |
| 68 return file_writer->Write(&context_, sizeof(context_)); |
| 69 } |
| 70 |
| 71 size_t MinidumpContextAMD64Writer::ContextSize() const { |
| 72 DCHECK_GE(state(), kStateFrozen); |
| 73 |
| 74 return sizeof(context_); |
| 75 } |
| 76 |
| 77 } // namespace crashpad |
OLD | NEW |