Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: minidump/minidump_exception_writer.h

Issue 639573002: Add MinidumpExceptionWriter and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Use ASSERT_NO_FATAL_FAILURE() Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « minidump/minidump.gyp ('k') | minidump/minidump_exception_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_EXCEPTION_WRITER_H_
16 #define CRASHPAD_MINIDUMP_MINIDUMP_EXCEPTION_WRITER_H_
17
18 #include <dbghelp.h>
19 #include <stdint.h>
20 #include <sys/types.h>
21
22 #include <vector>
23
24 #include "base/basictypes.h"
25 #include "minidump/minidump_context_writer.h"
26 #include "minidump/minidump_stream_writer.h"
27 #include "util/file/file_writer.h"
28
29 namespace crashpad {
30
31 //! \brief The writer for a MINIDUMP_EXCEPTION_STREAM stream in a minidump file.
32 class MinidumpExceptionWriter final : public internal::MinidumpStreamWriter {
33 public:
34 MinidumpExceptionWriter();
35 ~MinidumpExceptionWriter() {}
36
37 //! \brief Arranges for MINIDUMP_EXCEPTION_STREAM::ThreadContext to point to
38 //! the CPU context to be written by \a context.
39 //!
40 //! A context is required in all MINIDUMP_EXCEPTION_STREAM objects.
41 //!
42 //! \a context will become a child of this object in the overall tree of
43 //! internal::MinidumpWritable objects.
44 //!
45 //! \note Valid in #kStateMutable.
46 void SetContext(MinidumpContextWriter* context);
47
48 //! \brief Sets MINIDUMP_EXCEPTION_STREAM::ThreadId.
49 void SetThreadID(uint32_t thread_id) { exception_.ThreadId = thread_id; }
50
51 //! \brief Sets MINIDUMP_EXCEPTION::ExceptionCode.
52 void SetExceptionCode(uint32_t exception_code) {
53 exception_.ExceptionRecord.ExceptionCode = exception_code;
54 }
55
56 //! \brief Sets MINIDUMP_EXCEPTION::ExceptionFlags.
57 void SetExceptionFlags(uint32_t exception_flags) {
58 exception_.ExceptionRecord.ExceptionFlags = exception_flags;
59 }
60
61 //! \brief Sets MINIDUMP_EXCEPTION::ExceptionRecord.
62 void SetExceptionRecord(uint64_t exception_record) {
63 exception_.ExceptionRecord.ExceptionRecord = exception_record;
64 }
65
66 //! \brief Sets MINIDUMP_EXCEPTION::ExceptionAddress.
67 void SetExceptionAddress(uint64_t exception_address) {
68 exception_.ExceptionRecord.ExceptionAddress = exception_address;
69 }
70
71 //! \brief Sets MINIDUMP_EXCEPTION::ExceptionInformation and
72 //! MINIDUMP_EXCEPTION::NumberParameters.
73 //!
74 //! MINIDUMP_EXCEPTION::NumberParameters is set to the number of elements in
75 //! \a exception_information. The elements of
76 //! MINIDUMP_EXCEPTION::ExceptionInformation are set to the elements of \a
77 //! exception_information. Unused elements in
78 //! MINIDUMP_EXCEPTION::ExceptionInformation are set to `0`.
79 //!
80 //! \a exception_information must have no more than
81 //! #EXCEPTION_MAXIMUM_PARAMETERS elements.
82 //!
83 //! \note Valid in #kStateMutable.
84 void SetExceptionInformation(
85 const std::vector<uint64_t>& exception_information);
86
87 protected:
88 // MinidumpWritable:
89 virtual bool Freeze() override;
90 virtual size_t SizeOfObject() override;
91 virtual std::vector<MinidumpWritable*> Children() override;
92 virtual bool WriteObject(FileWriterInterface* file_writer) override;
93
94 // MinidumpStreamWriter:
95 virtual MinidumpStreamType StreamType() const override;
96
97 private:
98 MINIDUMP_EXCEPTION_STREAM exception_;
99 MinidumpContextWriter* context_; // weak
100
101 DISALLOW_COPY_AND_ASSIGN(MinidumpExceptionWriter);
102 };
103
104 } // namespace crashpad
105
106 #endif // CRASHPAD_MINIDUMP_MINIDUMP_EXCEPTION_WRITER_H_
OLDNEW
« no previous file with comments | « minidump/minidump.gyp ('k') | minidump/minidump_exception_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698