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

Side by Side Diff: minidump/minidump_exception_writer.cc

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_exception_writer.h ('k') | minidump/minidump_exception_writer_test.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 #include "minidump/minidump_exception_writer.h"
16
17 #include "base/logging.h"
18
19 namespace crashpad {
20
21 MinidumpExceptionWriter::MinidumpExceptionWriter()
22 : MinidumpStreamWriter(), exception_(), context_(NULL) {
23 }
24
25 void MinidumpExceptionWriter::SetContext(MinidumpContextWriter* context) {
26 DCHECK_EQ(state(), kStateMutable);
27
28 context_ = context;
29 }
30
31 void MinidumpExceptionWriter::SetExceptionInformation(
32 const std::vector<uint64_t>& exception_information) {
33 DCHECK_EQ(state(), kStateMutable);
34
35 const size_t parameters = exception_information.size();
36 const size_t kMaxParameters =
37 arraysize(exception_.ExceptionRecord.ExceptionInformation);
38 CHECK_LE(parameters, kMaxParameters);
39
40 exception_.ExceptionRecord.NumberParameters = parameters;
41 size_t parameter = 0;
42 for (; parameter < parameters; ++parameter) {
43 exception_.ExceptionRecord.ExceptionInformation[parameter] =
44 exception_information[parameter];
45 }
46 for (; parameter < kMaxParameters; ++parameter) {
47 exception_.ExceptionRecord.ExceptionInformation[parameter] = 0;
48 }
49 }
50
51 bool MinidumpExceptionWriter::Freeze() {
52 DCHECK_EQ(state(), kStateMutable);
53 CHECK(context_);
54
55 if (!MinidumpStreamWriter::Freeze()) {
56 return false;
57 }
58
59 context_->RegisterLocationDescriptor(&exception_.ThreadContext);
60
61 return true;
62 }
63
64 size_t MinidumpExceptionWriter::SizeOfObject() {
65 DCHECK_GE(state(), kStateFrozen);
66
67 return sizeof(exception_);
68 }
69
70 std::vector<internal::MinidumpWritable*> MinidumpExceptionWriter::Children() {
71 DCHECK_GE(state(), kStateFrozen);
72 DCHECK(context_);
73
74 std::vector<MinidumpWritable*> children;
75 children.push_back(context_);
76
77 return children;
78 }
79
80 bool MinidumpExceptionWriter::WriteObject(FileWriterInterface* file_writer) {
81 DCHECK_EQ(state(), kStateWritable);
82
83 return file_writer->Write(&exception_, sizeof(exception_));
84 }
85
86 MinidumpStreamType MinidumpExceptionWriter::StreamType() const {
87 return kMinidumpStreamTypeException;
88 }
89
90 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_exception_writer.h ('k') | minidump/minidump_exception_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698