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

Side by Side Diff: third_party/crashpad/crashpad/minidump/minidump_context_writer.cc

Issue 2710663006: Update Crashpad to 4a2043ea65e2641ef1a921801c0aaa15ada02fc7 (Closed)
Patch Set: Update Crashpad to 4a2043ea65e2 Created 3 years, 10 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
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/minidump_context_writer.h" 15 #include "minidump/minidump_context_writer.h"
16 16
17 #include <windows.h>
18 #include <dbghelp.h>
17 #include <stdint.h> 19 #include <stdint.h>
18 #include <string.h> 20 #include <string.h>
19 21
20 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
21 #include "base/logging.h" 23 #include "base/logging.h"
22 #include "snapshot/cpu_context.h" 24 #include "snapshot/cpu_context.h"
23 #include "util/file/file_writer.h" 25 #include "util/file/file_writer.h"
24 26
25 namespace crashpad { 27 namespace crashpad {
26 28
29 namespace {
30
31 // Sanity-check complex structures to ensure interoperability.
32 static_assert(sizeof(MinidumpContextX86) == 716, "MinidumpContextX86 size");
33 static_assert(sizeof(MinidumpContextAMD64) == 1232,
34 "MinidumpContextAMD64 size");
35
36 // These structures can also be checked against definitions in the Windows SDK.
37 #if defined(OS_WIN)
38 #if defined(ARCH_CPU_X86_FAMILY)
39 static_assert(sizeof(MinidumpContextX86) == sizeof(WOW64_CONTEXT),
40 "WOW64_CONTEXT size");
41 #if defined(ARCH_CPU_X86)
42 static_assert(sizeof(MinidumpContextX86) == sizeof(CONTEXT), "CONTEXT size");
43 #elif defined(ARCH_CPU_X86_64)
44 static_assert(sizeof(MinidumpContextAMD64) == sizeof(CONTEXT), "CONTEXT size");
45 #endif
46 #endif // ARCH_CPU_X86_FAMILY
47 #endif // OS_WIN
48
49 } // namespace
50
27 MinidumpContextWriter::~MinidumpContextWriter() { 51 MinidumpContextWriter::~MinidumpContextWriter() {
28 } 52 }
29 53
30 // static 54 // static
31 std::unique_ptr<MinidumpContextWriter> 55 std::unique_ptr<MinidumpContextWriter>
32 MinidumpContextWriter::CreateFromSnapshot(const CPUContext* context_snapshot) { 56 MinidumpContextWriter::CreateFromSnapshot(const CPUContext* context_snapshot) {
33 std::unique_ptr<MinidumpContextWriter> context; 57 std::unique_ptr<MinidumpContextWriter> context;
34 58
35 switch (context_snapshot->architecture) { 59 switch (context_snapshot->architecture) {
36 case kCPUArchitectureX86: { 60 case kCPUArchitectureX86: {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 106
83 context_.context_flags = kMinidumpContextX86All; 107 context_.context_flags = kMinidumpContextX86All;
84 108
85 context_.dr0 = context_snapshot->dr0; 109 context_.dr0 = context_snapshot->dr0;
86 context_.dr1 = context_snapshot->dr1; 110 context_.dr1 = context_snapshot->dr1;
87 context_.dr2 = context_snapshot->dr2; 111 context_.dr2 = context_snapshot->dr2;
88 context_.dr3 = context_snapshot->dr3; 112 context_.dr3 = context_snapshot->dr3;
89 context_.dr6 = context_snapshot->dr6; 113 context_.dr6 = context_snapshot->dr6;
90 context_.dr7 = context_snapshot->dr7; 114 context_.dr7 = context_snapshot->dr7;
91 115
92 // The contents of context_.float_save effectively alias everything in 116 // The contents of context_.fsave effectively alias everything in
93 // context_.fxsave that’s related to x87 FPU state. context_.float_save 117 // context_.fxsave that’s related to x87 FPU state. context_.fsave doesn’t
94 // doesn’t carry state specific to SSE (or later), such as mxcsr and the xmm 118 // carry state specific to SSE (or later), such as mxcsr and the xmm
95 // registers. 119 // registers.
96 context_.float_save.control_word = context_snapshot->fxsave.fcw; 120 CPUContextX86::FxsaveToFsave(context_snapshot->fxsave, &context_.fsave);
97 context_.float_save.status_word = context_snapshot->fxsave.fsw;
98 context_.float_save.tag_word =
99 CPUContextX86::FxsaveToFsaveTagWord(context_snapshot->fxsave.fsw,
100 context_snapshot->fxsave.ftw,
101 context_snapshot->fxsave.st_mm);
102 context_.float_save.error_offset = context_snapshot->fxsave.fpu_ip;
103 context_.float_save.error_selector = context_snapshot->fxsave.fpu_cs;
104 context_.float_save.data_offset = context_snapshot->fxsave.fpu_dp;
105 context_.float_save.data_selector = context_snapshot->fxsave.fpu_ds;
106
107 for (size_t index = 0, offset = 0;
108 index < arraysize(context_snapshot->fxsave.st_mm);
109 offset += sizeof(context_snapshot->fxsave.st_mm[index].st), ++index) {
110 memcpy(&context_.float_save.register_area[offset],
111 &context_snapshot->fxsave.st_mm[index].st,
112 sizeof(context_snapshot->fxsave.st_mm[index].st));
113 }
114 121
115 context_.gs = context_snapshot->gs; 122 context_.gs = context_snapshot->gs;
116 context_.fs = context_snapshot->fs; 123 context_.fs = context_snapshot->fs;
117 context_.es = context_snapshot->es; 124 context_.es = context_snapshot->es;
118 context_.ds = context_snapshot->ds; 125 context_.ds = context_snapshot->ds;
119 context_.edi = context_snapshot->edi; 126 context_.edi = context_snapshot->edi;
120 context_.esi = context_snapshot->esi; 127 context_.esi = context_snapshot->esi;
121 context_.ebx = context_snapshot->ebx; 128 context_.ebx = context_snapshot->ebx;
122 context_.edx = context_snapshot->edx; 129 context_.edx = context_snapshot->edx;
123 context_.ecx = context_snapshot->ecx; 130 context_.ecx = context_snapshot->ecx;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return file_writer->Write(&context_, sizeof(context_)); 214 return file_writer->Write(&context_, sizeof(context_));
208 } 215 }
209 216
210 size_t MinidumpContextAMD64Writer::ContextSize() const { 217 size_t MinidumpContextAMD64Writer::ContextSize() const {
211 DCHECK_GE(state(), kStateFrozen); 218 DCHECK_GE(state(), kStateFrozen);
212 219
213 return sizeof(context_); 220 return sizeof(context_);
214 } 221 }
215 222
216 } // namespace crashpad 223 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698