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

Side by Side Diff: snapshot/win/cpu_context_win.cc

Issue 1336823002: win x86: Grab bag of restructuring to get tests working on x86-on-x86 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes Created 5 years, 3 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 | « no previous file | snapshot/win/cpu_context_win_test.cc » ('j') | snapshot/win/process_reader_win.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 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,
(...skipping 10 matching lines...) Expand all
21 21
22 namespace crashpad { 22 namespace crashpad {
23 23
24 #if defined(ARCH_CPU_64_BITS) 24 #if defined(ARCH_CPU_64_BITS)
25 25
26 void InitializeX86Context(const WOW64_CONTEXT& context, CPUContextX86* out) { 26 void InitializeX86Context(const WOW64_CONTEXT& context, CPUContextX86* out) {
27 CHECK(false) << "TODO(scottmg) InitializeX86Context()"; 27 CHECK(false) << "TODO(scottmg) InitializeX86Context()";
28 } 28 }
29 29
30 void InitializeX64Context(const CONTEXT& context, CPUContextX86_64* out) { 30 void InitializeX64Context(const CONTEXT& context, CPUContextX86_64* out) {
31 out->rax = context.Rax; 31 memset(out, 0, sizeof(*out));
32 out->rbx = context.Rbx;
33 out->rcx = context.Rcx;
34 out->rdx = context.Rdx;
35 out->rdi = context.Rdi;
36 out->rsi = context.Rsi;
37 out->rbp = context.Rbp;
38 out->rsp = context.Rsp;
39 out->r8 = context.R8;
40 out->r9 = context.R9;
41 out->r10 = context.R10;
42 out->r11 = context.R11;
43 out->r12 = context.R12;
44 out->r13 = context.R13;
45 out->r14 = context.R14;
46 out->r15 = context.R15;
47 out->rip = context.Rip;
48 out->rflags = context.EFlags;
49 out->cs = context.SegCs;
50 out->fs = context.SegFs;
51 out->gs = context.SegGs;
52 32
Mark Mentovai 2015/09/16 18:56:58 Maybe also LOG_IF(…, !(context.ContextFlags & CONT
scottmg 2015/09/16 19:38:21 Done. (I was confused at first why these don't tr
53 out->dr0 = context.Dr0; 33 if (context.ContextFlags & CONTEXT_CONTROL) {
54 out->dr1 = context.Dr1; 34 out->cs = context.SegCs;
55 out->dr2 = context.Dr2; 35 out->rflags = context.EFlags;
56 out->dr3 = context.Dr3; 36 out->rip = context.Rip;
57 // DR4 and DR5 are obsolete synonyms for DR6 and DR7, see 37 out->rsp = context.Rsp;
58 // http://en.wikipedia.org/wiki/X86_debug_register. 38 // SegSs ignored.
59 out->dr4 = context.Dr6; 39 }
60 out->dr5 = context.Dr7;
61 out->dr6 = context.Dr6;
62 out->dr7 = context.Dr7;
63 40
64 static_assert(sizeof(out->fxsave) == sizeof(context.FltSave), 41 if (context.ContextFlags & CONTEXT_INTEGER) {
65 "types must be equivalent"); 42 out->rax = context.Rax;
66 memcpy(&out->fxsave, &context.FltSave.ControlWord, sizeof(out->fxsave)); 43 out->rbx = context.Rbx;
44 out->rcx = context.Rcx;
45 out->rdx = context.Rdx;
46 out->rdi = context.Rdi;
47 out->rsi = context.Rsi;
48 out->rbp = context.Rbp;
49 out->r8 = context.R8;
50 out->r9 = context.R9;
51 out->r10 = context.R10;
52 out->r11 = context.R11;
53 out->r12 = context.R12;
54 out->r13 = context.R13;
55 out->r14 = context.R14;
56 out->r15 = context.R15;
57 }
58
59 if (context.ContextFlags & CONTEXT_SEGMENTS) {
60 out->fs = context.SegFs;
61 out->gs = context.SegGs;
62 // SegDs ignored.
63 // SegEs ignored.
64 }
65
66 if (context.ContextFlags & CONTEXT_DEBUG_REGISTERS) {
67 out->dr0 = context.Dr0;
68 out->dr1 = context.Dr1;
69 out->dr2 = context.Dr2;
70 out->dr3 = context.Dr3;
71 // DR4 and DR5 are obsolete synonyms for DR6 and DR7, see
72 // https://en.wikipedia.org/wiki/X86_debug_register.
73 out->dr4 = context.Dr6;
74 out->dr5 = context.Dr7;
75 out->dr6 = context.Dr6;
76 out->dr7 = context.Dr7;
77 }
78
79 if (context.ContextFlags & CONTEXT_FLOATING_POINT) {
80 static_assert(sizeof(out->fxsave) == sizeof(context.FltSave),
81 "types must be equivalent");
82 memcpy(&out->fxsave, &context.FltSave.ControlWord, sizeof(out->fxsave));
83 }
67 } 84 }
68 85
69 #else // ARCH_CPU_64_BITS 86 #else // ARCH_CPU_64_BITS
70 87
71 void InitializeX86Context(const CONTEXT& context, CPUContextX86* out) { 88 void InitializeX86Context(const CONTEXT& context, CPUContextX86* out) {
72 CHECK(false) << "TODO(scottmg) InitializeX86Context()"; 89 memset(out, 0, sizeof(*out));
90
91 if (context.ContextFlags & CONTEXT_CONTROL) {
92 out->ebp = context.Ebp;
93 out->eip = context.Eip;
94 out->cs = static_cast<uint16_t>(context.SegCs);
95 out->eflags = context.EFlags;
96 out->esp = context.Esp;
97 out->ss = static_cast<uint16_t>(context.SegSs);
98 }
99
100 if (context.ContextFlags & CONTEXT_INTEGER) {
101 out->eax = context.Eax;
102 out->ebx = context.Ebx;
103 out->ecx = context.Ecx;
104 out->edx = context.Edx;
105 out->edi = context.Edi;
106 out->esi = context.Esi;
107 }
108
109 if (context.ContextFlags & CONTEXT_SEGMENTS) {
110 out->ds = static_cast<uint16_t>(context.SegDs);
111 out->es = static_cast<uint16_t>(context.SegEs);
112 out->fs = static_cast<uint16_t>(context.SegFs);
113 out->gs = static_cast<uint16_t>(context.SegGs);
114 }
115
116 if (context.ContextFlags & CONTEXT_DEBUG_REGISTERS) {
117 out->dr0 = context.Dr0;
118 out->dr1 = context.Dr1;
119 out->dr2 = context.Dr2;
120 out->dr3 = context.Dr3;
121 // DR4 and DR5 are obsolete synonyms for DR6 and DR7, see
122 // https://en.wikipedia.org/wiki/X86_debug_register.
123 out->dr4 = context.Dr6;
124 out->dr5 = context.Dr7;
125 out->dr6 = context.Dr6;
126 out->dr7 = context.Dr7;
127 }
128
129 if (context.ContextFlags & CONTEXT_EXTENDED_REGISTERS) {
130 static_assert(sizeof(out->fxsave) == sizeof(context.ExtendedRegisters),
131 "types must be equivalent");
132 memcpy(&out->fxsave, &context.ExtendedRegisters, sizeof(out->fxsave));
133 } else if (context.ContextFlags & CONTEXT_FLOATING_POINT) {
134 CHECK(false) << "TODO(scottmg): extract x87 data";
135 }
73 } 136 }
74 137
75 #endif // ARCH_CPU_64_BITS 138 #endif // ARCH_CPU_64_BITS
76 139
77 } // namespace crashpad 140 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | snapshot/win/cpu_context_win_test.cc » ('j') | snapshot/win/process_reader_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698