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 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_ |
| 16 #define CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_ |
| 17 |
| 18 #include <sys/types.h> |
| 19 |
| 20 #include "base/basictypes.h" |
| 21 #include "minidump/minidump_context.h" |
| 22 #include "minidump/minidump_writable.h" |
| 23 #include "util/file/file_writer.h" |
| 24 |
| 25 namespace crashpad { |
| 26 |
| 27 //! \brief The base class for writers of CPU context structures in minidump |
| 28 //! files. |
| 29 class MinidumpContextWriter : public internal::MinidumpWritable { |
| 30 public: |
| 31 virtual ~MinidumpContextWriter(); |
| 32 |
| 33 protected: |
| 34 MinidumpContextWriter() : MinidumpWritable() {} |
| 35 |
| 36 //! \brief Returns the size of the context structure that this object will |
| 37 //! write. |
| 38 //! |
| 39 //! \note This method will only be called in #kStateFrozen or a subsequent |
| 40 //! state. |
| 41 virtual size_t ContextSize() const = 0; |
| 42 |
| 43 // MinidumpWritable: |
| 44 virtual size_t SizeOfObject() override final; |
| 45 |
| 46 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(MinidumpContextWriter); |
| 48 }; |
| 49 |
| 50 //! \brief The writer for a MinidumpContextX86 structure in a minidump file. |
| 51 class MinidumpContextX86Writer final : public MinidumpContextWriter { |
| 52 public: |
| 53 MinidumpContextX86Writer(); |
| 54 virtual ~MinidumpContextX86Writer(); |
| 55 |
| 56 //! \brief Returns a pointer to the context structure that this object will |
| 57 //! write. |
| 58 //! |
| 59 //! \attention This returns a non-`const` pointer to this object’s private |
| 60 //! data so that a caller can populate the context structure directly. |
| 61 //! This is done because providing setter interfaces to each field in the |
| 62 //! context structure would be unwieldy and cumbersome. Care must be taken |
| 63 //! to populate the context structure correctly. The context structure |
| 64 //! must only be modified while this object is in the #kStateMutable |
| 65 //! state. |
| 66 MinidumpContextX86* context() { return &context_; } |
| 67 |
| 68 protected: |
| 69 // MinidumpWritable: |
| 70 virtual bool WriteObject(FileWriterInterface* file_writer) override; |
| 71 |
| 72 // MinidumpContextWriter: |
| 73 virtual size_t ContextSize() const override; |
| 74 |
| 75 private: |
| 76 MinidumpContextX86 context_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(MinidumpContextX86Writer); |
| 79 }; |
| 80 |
| 81 //! \brief The writer for a MinidumpContextAMD64 structure in a minidump file. |
| 82 class MinidumpContextAMD64Writer final : public MinidumpContextWriter { |
| 83 public: |
| 84 MinidumpContextAMD64Writer(); |
| 85 virtual ~MinidumpContextAMD64Writer(); |
| 86 |
| 87 //! \brief Returns a pointer to the context structure that this object will |
| 88 //! write. |
| 89 //! |
| 90 //! \attention This returns a non-`const` pointer to this object’s private |
| 91 //! data so that a caller can populate the context structure directly. |
| 92 //! This is done because providing setter interfaces to each field in the |
| 93 //! context structure would be unwieldy and cumbersome. Care must be taken |
| 94 //! to populate the context structure correctly. The context structure |
| 95 //! must only be modified while this object is in the #kStateMutable |
| 96 //! state. |
| 97 MinidumpContextAMD64* context() { return &context_; } |
| 98 |
| 99 protected: |
| 100 // MinidumpWritable: |
| 101 virtual size_t Alignment() override; |
| 102 virtual bool WriteObject(FileWriterInterface* file_writer) override; |
| 103 |
| 104 // MinidumpContextWriter: |
| 105 virtual size_t ContextSize() const override; |
| 106 |
| 107 private: |
| 108 MinidumpContextAMD64 context_; |
| 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(MinidumpContextAMD64Writer); |
| 111 }; |
| 112 |
| 113 } // namespace crashpad |
| 114 |
| 115 #endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_ |
OLD | NEW |