1 /* Copyright (C) 2007 Free Software Foundation, Inc.
3 This file is part of GDB.
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 2 of the License, or
8 (at your option) any later version.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA. */
21 #include "win32-low.h"
26 #define FLAG_TRACE_BIT 0x100
28 static unsigned dr
[8];
33 memset (&dr
, 0, sizeof (dr
));
37 store_debug_registers (win32_thread_info
*th
)
39 dr
[0] = th
->context
.Dr0
;
40 dr
[1] = th
->context
.Dr1
;
41 dr
[2] = th
->context
.Dr2
;
42 dr
[3] = th
->context
.Dr3
;
43 dr
[6] = th
->context
.Dr6
;
44 dr
[7] = th
->context
.Dr7
;
48 load_debug_registers (win32_thread_info
*th
)
50 th
->context
.Dr0
= dr
[0];
51 th
->context
.Dr1
= dr
[1];
52 th
->context
.Dr2
= dr
[2];
53 th
->context
.Dr3
= dr
[3];
54 /* th->context.Dr6 = dr[6];
55 FIXME: should we set dr6 also ?? */
56 th
->context
.Dr7
= dr
[7];
59 /* Fetch register(s) from gdbserver regcache data. */
61 do_fetch_inferior_registers (win32_thread_info
*th
, int r
)
63 char *context_offset
= regptr (&th
->context
, r
);
68 l
= *((long *) context_offset
) & 0xffff;
69 supply_register (r
, (char *) &l
);
71 else if (r
== FOP_REGNUM
)
73 l
= (*((long *) context_offset
) >> 16) & ((1 << 11) - 1);
74 supply_register (r
, (char *) &l
);
77 supply_register (r
, context_offset
);
81 single_step (win32_thread_info
*th
)
83 th
->context
.EFlags
|= FLAG_TRACE_BIT
;
86 /* An array of offset mappings into a Win32 Context structure.
87 This is a one-to-one mapping which is indexed by gdb's register
88 numbers. It retrieves an offset into the context structure where
89 the 4 byte register is located.
90 An offset value of -1 indicates that Win32 does not provide this
91 register in it's CONTEXT structure. In this case regptr will return
92 a pointer into a dummy register. */
93 #define context_offset(x) ((int)&(((CONTEXT *)NULL)->x))
94 static const int mappings
[] = {
100 context_offset (Ebp
),
101 context_offset (Esi
),
102 context_offset (Edi
),
103 context_offset (Eip
),
104 context_offset (EFlags
),
105 context_offset (SegCs
),
106 context_offset (SegSs
),
107 context_offset (SegDs
),
108 context_offset (SegEs
),
109 context_offset (SegFs
),
110 context_offset (SegGs
),
111 context_offset (FloatSave
.RegisterArea
[0 * 10]),
112 context_offset (FloatSave
.RegisterArea
[1 * 10]),
113 context_offset (FloatSave
.RegisterArea
[2 * 10]),
114 context_offset (FloatSave
.RegisterArea
[3 * 10]),
115 context_offset (FloatSave
.RegisterArea
[4 * 10]),
116 context_offset (FloatSave
.RegisterArea
[5 * 10]),
117 context_offset (FloatSave
.RegisterArea
[6 * 10]),
118 context_offset (FloatSave
.RegisterArea
[7 * 10]),
119 context_offset (FloatSave
.ControlWord
),
120 context_offset (FloatSave
.StatusWord
),
121 context_offset (FloatSave
.TagWord
),
122 context_offset (FloatSave
.ErrorSelector
),
123 context_offset (FloatSave
.ErrorOffset
),
124 context_offset (FloatSave
.DataSelector
),
125 context_offset (FloatSave
.DataOffset
),
126 context_offset (FloatSave
.ErrorSelector
),
128 context_offset (ExtendedRegisters
[10 * 16]),
129 context_offset (ExtendedRegisters
[11 * 16]),
130 context_offset (ExtendedRegisters
[12 * 16]),
131 context_offset (ExtendedRegisters
[13 * 16]),
132 context_offset (ExtendedRegisters
[14 * 16]),
133 context_offset (ExtendedRegisters
[15 * 16]),
134 context_offset (ExtendedRegisters
[16 * 16]),
135 context_offset (ExtendedRegisters
[17 * 16]),
137 context_offset (ExtendedRegisters
[24])
139 #undef context_offset
141 struct win32_target_ops the_low_target
= {
143 sizeof (mappings
) / sizeof (mappings
[0]),
145 store_debug_registers
,
146 load_debug_registers
,
147 do_fetch_inferior_registers
,
149 (const char*)NULL
, /* breakpoint */
150 0, /* breakpoint_len */
151 "i386" /* arch_string */