| 1 | /* Copyright (C) 2008-2013 Free Software Foundation, Inc. |
| 2 | |
| 3 | This file is part of GDB. |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 17 | |
| 18 | #include "defs.h" |
| 19 | #include "windows-nat.h" |
| 20 | #include "i386-nat.h" |
| 21 | #include "amd64-tdep.h" |
| 22 | |
| 23 | #include <windows.h> |
| 24 | |
| 25 | #define context_offset(x) (offsetof (CONTEXT, x)) |
| 26 | static const int mappings[] = |
| 27 | { |
| 28 | context_offset (Rax), |
| 29 | context_offset (Rbx), |
| 30 | context_offset (Rcx), |
| 31 | context_offset (Rdx), |
| 32 | context_offset (Rsi), |
| 33 | context_offset (Rdi), |
| 34 | context_offset (Rbp), |
| 35 | context_offset (Rsp), |
| 36 | context_offset (R8), |
| 37 | context_offset (R9), |
| 38 | context_offset (R10), |
| 39 | context_offset (R11), |
| 40 | context_offset (R12), |
| 41 | context_offset (R13), |
| 42 | context_offset (R14), |
| 43 | context_offset (R15), |
| 44 | context_offset (Rip), |
| 45 | context_offset (EFlags), |
| 46 | context_offset (SegCs), |
| 47 | context_offset (SegSs), |
| 48 | context_offset (SegDs), |
| 49 | context_offset (SegEs), |
| 50 | context_offset (SegFs), |
| 51 | context_offset (SegGs), |
| 52 | context_offset (FloatSave.FloatRegisters[0]), |
| 53 | context_offset (FloatSave.FloatRegisters[1]), |
| 54 | context_offset (FloatSave.FloatRegisters[2]), |
| 55 | context_offset (FloatSave.FloatRegisters[3]), |
| 56 | context_offset (FloatSave.FloatRegisters[4]), |
| 57 | context_offset (FloatSave.FloatRegisters[5]), |
| 58 | context_offset (FloatSave.FloatRegisters[6]), |
| 59 | context_offset (FloatSave.FloatRegisters[7]), |
| 60 | context_offset (FloatSave.ControlWord), |
| 61 | context_offset (FloatSave.StatusWord), |
| 62 | context_offset (FloatSave.TagWord), |
| 63 | context_offset (FloatSave.ErrorSelector), |
| 64 | context_offset (FloatSave.ErrorOffset), |
| 65 | context_offset (FloatSave.DataSelector), |
| 66 | context_offset (FloatSave.DataOffset), |
| 67 | context_offset (FloatSave.ErrorSelector) |
| 68 | /* XMM0-7 */ , |
| 69 | context_offset (Xmm0), |
| 70 | context_offset (Xmm1), |
| 71 | context_offset (Xmm2), |
| 72 | context_offset (Xmm3), |
| 73 | context_offset (Xmm4), |
| 74 | context_offset (Xmm5), |
| 75 | context_offset (Xmm6), |
| 76 | context_offset (Xmm7), |
| 77 | context_offset (Xmm8), |
| 78 | context_offset (Xmm9), |
| 79 | context_offset (Xmm10), |
| 80 | context_offset (Xmm11), |
| 81 | context_offset (Xmm12), |
| 82 | context_offset (Xmm13), |
| 83 | context_offset (Xmm14), |
| 84 | context_offset (Xmm15), |
| 85 | /* MXCSR */ |
| 86 | context_offset (FloatSave.MxCsr) |
| 87 | }; |
| 88 | #undef context_offset |
| 89 | |
| 90 | /* segment_register_p_ftype implementation for amd64. */ |
| 91 | |
| 92 | static int |
| 93 | amd64_windows_segment_register_p (int regnum) |
| 94 | { |
| 95 | return regnum >= AMD64_CS_REGNUM && regnum <= AMD64_GS_REGNUM; |
| 96 | } |
| 97 | |
| 98 | /* -Wmissing-prototypes */ |
| 99 | extern initialize_file_ftype _initialize_amd64_windows_nat; |
| 100 | |
| 101 | void |
| 102 | _initialize_amd64_windows_nat (void) |
| 103 | { |
| 104 | windows_set_context_register_offsets (mappings); |
| 105 | windows_set_segment_register_p (amd64_windows_segment_register_p); |
| 106 | i386_set_debug_register_length (8); |
| 107 | } |