Chromium Code Reviews| 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; | |
|
Robert Sesek
2014/09/24 15:42:15
Why require this instead of just use SizeOfObject(
Mark Mentovai
2014/09/24 16:58:28
rsesek wrote:
| |
| 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 state . | |
|
Robert Sesek
2014/09/24 15:42:15
nit: 80cols
| |
| 65 MinidumpContextX86* context() { return &context_; } | |
| 66 | |
| 67 protected: | |
| 68 // MinidumpWritable: | |
| 69 virtual bool WriteObject(FileWriterInterface* file_writer) override; | |
| 70 | |
| 71 // MinidumpContextWriter: | |
| 72 virtual size_t ContextSize() const override; | |
| 73 | |
| 74 private: | |
| 75 MinidumpContextX86 context_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(MinidumpContextX86Writer); | |
| 78 }; | |
| 79 | |
| 80 //! \brief The writer for a MinidumpContextAMD64 structure in a minidump file. | |
| 81 class MinidumpContextAMD64Writer final : public MinidumpContextWriter { | |
| 82 public: | |
| 83 MinidumpContextAMD64Writer(); | |
| 84 virtual ~MinidumpContextAMD64Writer(); | |
| 85 | |
| 86 //! \brief Returns a pointer to the context structure that this object will | |
| 87 //! write. | |
| 88 //! | |
| 89 //! \attention This returns a non-`const` pointer to this object’s private | |
| 90 //! data so that a caller can populate the context structure directly. | |
| 91 //! This is done because providing setter interfaces to each field in the | |
| 92 //! context structure would be unwieldy and cumbersome. Care must be taken | |
| 93 //! to populate the context structure correctly. The context structure | |
| 94 //! must only be modified while this object is in the #kStateMutable state . | |
| 95 MinidumpContextAMD64* context() { return &context_; } | |
| 96 | |
| 97 protected: | |
| 98 // MinidumpWritable: | |
| 99 virtual size_t Alignment() override; | |
| 100 virtual bool WriteObject(FileWriterInterface* file_writer) override; | |
| 101 | |
| 102 // MinidumpContextWriter: | |
| 103 virtual size_t ContextSize() const override; | |
| 104 | |
| 105 private: | |
| 106 MinidumpContextAMD64 context_; | |
| 107 | |
| 108 DISALLOW_COPY_AND_ASSIGN(MinidumpContextAMD64Writer); | |
| 109 }; | |
| 110 | |
| 111 } // namespace crashpad | |
| 112 | |
| 113 #endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_ | |
| OLD | NEW |