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

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

Issue 2705373005: Revert of Update Crashpad to 6da9708e7cc93e2e1772439d51646e47583cb225 (Closed)
Patch Set: Created 3 years, 9 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>
19 #include <stdint.h> 17 #include <stdint.h>
20 #include <string.h> 18 #include <string.h>
21 19
22 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
23 #include "base/logging.h" 21 #include "base/logging.h"
24 #include "snapshot/cpu_context.h" 22 #include "snapshot/cpu_context.h"
25 #include "util/file/file_writer.h" 23 #include "util/file/file_writer.h"
26 24
27 namespace crashpad { 25 namespace crashpad {
28 26
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
51 MinidumpContextWriter::~MinidumpContextWriter() { 27 MinidumpContextWriter::~MinidumpContextWriter() {
52 } 28 }
53 29
54 // static 30 // static
55 std::unique_ptr<MinidumpContextWriter> 31 std::unique_ptr<MinidumpContextWriter>
56 MinidumpContextWriter::CreateFromSnapshot(const CPUContext* context_snapshot) { 32 MinidumpContextWriter::CreateFromSnapshot(const CPUContext* context_snapshot) {
57 std::unique_ptr<MinidumpContextWriter> context; 33 std::unique_ptr<MinidumpContextWriter> context;
58 34
59 switch (context_snapshot->architecture) { 35 switch (context_snapshot->architecture) {
60 case kCPUArchitectureX86: { 36 case kCPUArchitectureX86: {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 82
107 context_.context_flags = kMinidumpContextX86All; 83 context_.context_flags = kMinidumpContextX86All;
108 84
109 context_.dr0 = context_snapshot->dr0; 85 context_.dr0 = context_snapshot->dr0;
110 context_.dr1 = context_snapshot->dr1; 86 context_.dr1 = context_snapshot->dr1;
111 context_.dr2 = context_snapshot->dr2; 87 context_.dr2 = context_snapshot->dr2;
112 context_.dr3 = context_snapshot->dr3; 88 context_.dr3 = context_snapshot->dr3;
113 context_.dr6 = context_snapshot->dr6; 89 context_.dr6 = context_snapshot->dr6;
114 context_.dr7 = context_snapshot->dr7; 90 context_.dr7 = context_snapshot->dr7;
115 91
116 // The contents of context_.fsave effectively alias everything in 92 // The contents of context_.float_save effectively alias everything in
117 // context_.fxsave that’s related to x87 FPU state. context_.fsave doesn’t 93 // context_.fxsave that’s related to x87 FPU state. context_.float_save
118 // carry state specific to SSE (or later), such as mxcsr and the xmm 94 // doesn’t carry state specific to SSE (or later), such as mxcsr and the xmm
119 // registers. 95 // registers.
120 CPUContextX86::FxsaveToFsave(context_snapshot->fxsave, &context_.fsave); 96 context_.float_save.control_word = context_snapshot->fxsave.fcw;
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 }
121 114
122 context_.gs = context_snapshot->gs; 115 context_.gs = context_snapshot->gs;
123 context_.fs = context_snapshot->fs; 116 context_.fs = context_snapshot->fs;
124 context_.es = context_snapshot->es; 117 context_.es = context_snapshot->es;
125 context_.ds = context_snapshot->ds; 118 context_.ds = context_snapshot->ds;
126 context_.edi = context_snapshot->edi; 119 context_.edi = context_snapshot->edi;
127 context_.esi = context_snapshot->esi; 120 context_.esi = context_snapshot->esi;
128 context_.ebx = context_snapshot->ebx; 121 context_.ebx = context_snapshot->ebx;
129 context_.edx = context_snapshot->edx; 122 context_.edx = context_snapshot->edx;
130 context_.ecx = context_snapshot->ecx; 123 context_.ecx = context_snapshot->ecx;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return file_writer->Write(&context_, sizeof(context_)); 207 return file_writer->Write(&context_, sizeof(context_));
215 } 208 }
216 209
217 size_t MinidumpContextAMD64Writer::ContextSize() const { 210 size_t MinidumpContextAMD64Writer::ContextSize() const {
218 DCHECK_GE(state(), kStateFrozen); 211 DCHECK_GE(state(), kStateFrozen);
219 212
220 return sizeof(context_); 213 return sizeof(context_);
221 } 214 }
222 215
223 } // namespace crashpad 216 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698